|
8 | 8 | import { URI } from "vscode-uri"; |
9 | 9 | import Parser, { Point, SyntaxNode, Tree } from "web-tree-sitter"; |
10 | 10 | import { ElmWorkspace } from "../elmWorkspace"; |
11 | | -import { Position } from "../position"; |
12 | 11 | import { IDocumentEvents } from "../util/documentEvents"; |
13 | 12 | import { ElmWorkspaceMatcher } from "../util/elmWorkspaceMatcher"; |
14 | 13 |
|
@@ -50,59 +49,11 @@ export class ASTProvider { |
50 | 49 | } |
51 | 50 |
|
52 | 51 | for (const changeEvent of params.contentChanges) { |
53 | | - // TODO why doesn't this work anymore? |
54 | | - // if (changeEvent.range && changeEvent.rangeLength) { |
55 | | - // // range is range of the change. end is exclusive |
56 | | - // // rangeLength is length of text removed |
57 | | - // // text is new text |
58 | | - // const { range, rangeLength, text } = changeEvent; |
59 | | - // const startIndex: number = range.start.line * range.start.character; |
60 | | - // const oldEndIndex: number = startIndex + rangeLength - 1; |
61 | | - // if (tree) { |
62 | | - // tree.edit({ |
63 | | - // // end index for new version of text |
64 | | - // newEndIndex: range.end.line * range.end.character - 1, |
65 | | - // // position in new doc change ended |
66 | | - // newEndPosition: Position.FROM_VS_POSITION(range.end).toTSPosition(), |
67 | | - |
68 | | - // // end index for old version of text |
69 | | - // oldEndIndex, |
70 | | - // // position in old doc change ended. |
71 | | - // oldEndPosition: this.computeEndPosition( |
72 | | - // startIndex, |
73 | | - // oldEndIndex, |
74 | | - // tree, |
75 | | - // ), |
76 | | - |
77 | | - // // index in old doc the change started |
78 | | - // startIndex, |
79 | | - // // position in old doc change started |
80 | | - // startPosition: Position.FROM_VS_POSITION( |
81 | | - // range.start, |
82 | | - // ).toTSPosition(), |
83 | | - // }); |
84 | | - // tree = this.parser.parse(text, tree); |
85 | | - // } |
86 | | - // } else { |
87 | 52 | tree = this.parser.parse(changeEvent.text); |
88 | | - // } |
89 | 53 | } |
90 | 54 | if (tree) { |
91 | 55 | forest.setTree(document.uri, true, true, tree); |
92 | 56 | imports.updateImports(document.uri, tree, forest); |
93 | 57 | } |
94 | 58 | }; |
95 | | - |
96 | | - private computeEndPosition = ( |
97 | | - startIndex: number, |
98 | | - endIndex: number, |
99 | | - tree: Tree, |
100 | | - ): Point => { |
101 | | - const node: SyntaxNode = tree.rootNode.descendantForIndex( |
102 | | - startIndex, |
103 | | - endIndex, |
104 | | - ); |
105 | | - |
106 | | - return node.endPosition; |
107 | | - }; |
108 | 59 | } |
0 commit comments