Skip to content

Commit

Permalink
Workaround out of bound error
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Jul 29, 2019
1 parent 7d42ff7 commit 04ea9d7
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 97 deletions.
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"@types/node": "12.6.8",
"@types/request": "^2.48.2",
"@types/ws": "^6.0.1",
"husky": "^3.0.1",
"husky": "^3.0.2",
"npm-run-all": "^4.1.5",
"prebuild": "^9.0.1",
"prettier": "^1.18.2",
"pretty-quick": "^1.11.1",
"tree-sitter-cli": "^0.15.6",
"tree-sitter-elm": "^2.5.0",
"tree-sitter-cli": "^0.15.7",
"tree-sitter-elm": "^2.5.6",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
Expand Down
3 changes: 2 additions & 1 deletion src/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export class Imports implements IImports {
),
);
} else {
const exposedOperators = exposingList.descendantsOfType(
const exposedOperators = TreeUtils.descendantsOfType(
exposingList,
"operator_identifier",
);
if (exposedOperators.length > 0) {
Expand Down
44 changes: 23 additions & 21 deletions src/providers/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,29 +223,31 @@ export class CodeLensProvider {
}
});

tree.rootNode.descendantsOfType("value_declaration").forEach(node => {
const functionName = TreeUtils.getFunctionNameNodeFromDefinition(node);
TreeUtils.descendantsOfType(tree.rootNode, "value_declaration").forEach(
node => {
const functionName = TreeUtils.getFunctionNameNodeFromDefinition(node);

if (functionName) {
if (
node.previousNamedSibling &&
node.previousNamedSibling.type === "type_annotation"
) {
codeLens.push(
this.createReferenceCodeLens(
node.previousNamedSibling,
functionName,
uri,
tree,
),
);
} else {
codeLens.push(
this.createReferenceCodeLens(node, functionName, uri, tree),
);
if (functionName) {
if (
node.previousNamedSibling &&
node.previousNamedSibling.type === "type_annotation"
) {
codeLens.push(
this.createReferenceCodeLens(
node.previousNamedSibling,
functionName,
uri,
tree,
),
);
} else {
codeLens.push(
this.createReferenceCodeLens(node, functionName, uri, tree),
);
}
}
}
});
},
);

const moduleNameNode = TreeUtils.getModuleNameNode(tree);
if (moduleNameNode && moduleNameNode.lastChild) {
Expand Down
5 changes: 4 additions & 1 deletion src/providers/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ export class CompletionProvider {
completions.push(this.createTypeCompletion(value, name.text));
}
// Add types constructors
const unionVariants = declaration.descendantsOfType("union_variant");
const unionVariants = TreeUtils.descendantsOfType(
declaration,
"union_variant",
);
for (const unionVariant of unionVariants) {
const unionVariantName = TreeUtils.findFirstNamedChildOfType(
"upper_case_identifier",
Expand Down
Loading

0 comments on commit 04ea9d7

Please sign in to comment.