|
5 | 5 | 'use strict'; |
6 | 6 |
|
7 | 7 | import {Location, getLocation, createScanner, SyntaxKind} from 'jsonc-parser'; |
8 | | -import {basename} from 'path'; |
9 | 8 | import {ProjectJSONContribution} from './projectJSONContribution'; |
10 | 9 | import {XHRRequest, configure as configureXHR, xhr} from 'request-light'; |
11 | 10 |
|
@@ -57,12 +56,11 @@ export class JSONHoverProvider implements HoverProvider { |
57 | 56 | } |
58 | 57 |
|
59 | 58 | public provideHover(document: TextDocument, position: Position, token: CancellationToken): Thenable<Hover> { |
60 | | - let fileName = basename(document.fileName); |
61 | 59 | let offset = document.offsetAt(position); |
62 | 60 | let location = getLocation(document.getText(), offset); |
63 | 61 | let node = location.previousNode; |
64 | 62 | if (node && node.offset <= offset && offset <= node.offset + node.length) { |
65 | | - let promise = this.jsonContribution.getInfoContribution(fileName, location); |
| 63 | + let promise = this.jsonContribution.getInfoContribution(document.fileName, location); |
66 | 64 | if (promise) { |
67 | 65 | return promise.then(htmlContent => { |
68 | 66 | let range = new Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length)); |
@@ -94,9 +92,6 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { |
94 | 92 | } |
95 | 93 |
|
96 | 94 | public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Thenable<CompletionList> { |
97 | | - |
98 | | - let fileName = basename(document.fileName); |
99 | | - |
100 | 95 | let currentWord = this.getCurrentWord(document, position); |
101 | 96 | let overwriteRange = null; |
102 | 97 | let items: CompletionItem[] = []; |
@@ -137,12 +132,12 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { |
137 | 132 | scanner.setPosition(offset); |
138 | 133 | scanner.scan(); |
139 | 134 | let isLast = scanner.getToken() === SyntaxKind.CloseBraceToken || scanner.getToken() === SyntaxKind.EOF; |
140 | | - collectPromise = this.jsonContribution.collectPropertySuggestions(fileName, location, currentWord, addValue, isLast, collector); |
| 135 | + collectPromise = this.jsonContribution.collectPropertySuggestions(document.fileName, location, currentWord, addValue, isLast, collector); |
141 | 136 | } else { |
142 | 137 | if (location.path.length === 0) { |
143 | | - collectPromise = this.jsonContribution.collectDefaultSuggestions(fileName, collector); |
| 138 | + collectPromise = this.jsonContribution.collectDefaultSuggestions(document.fileName, collector); |
144 | 139 | } else { |
145 | | - collectPromise = this.jsonContribution.collectValueSuggestions(fileName, location, collector); |
| 140 | + collectPromise = this.jsonContribution.collectValueSuggestions(document.fileName, location, collector); |
146 | 141 | } |
147 | 142 | } |
148 | 143 | if (collectPromise) { |
|
0 commit comments