Skip to content

Commit 02b8b4a

Browse files
committed
Don't need basename
1 parent 6fa4631 commit 02b8b4a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/features/json/jsonContributions.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
'use strict';
66

77
import {Location, getLocation, createScanner, SyntaxKind} from 'jsonc-parser';
8-
import {basename} from 'path';
98
import {ProjectJSONContribution} from './projectJSONContribution';
109
import {XHRRequest, configure as configureXHR, xhr} from 'request-light';
1110

@@ -57,12 +56,11 @@ export class JSONHoverProvider implements HoverProvider {
5756
}
5857

5958
public provideHover(document: TextDocument, position: Position, token: CancellationToken): Thenable<Hover> {
60-
let fileName = basename(document.fileName);
6159
let offset = document.offsetAt(position);
6260
let location = getLocation(document.getText(), offset);
6361
let node = location.previousNode;
6462
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);
6664
if (promise) {
6765
return promise.then(htmlContent => {
6866
let range = new Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
@@ -94,9 +92,6 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
9492
}
9593

9694
public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Thenable<CompletionList> {
97-
98-
let fileName = basename(document.fileName);
99-
10095
let currentWord = this.getCurrentWord(document, position);
10196
let overwriteRange = null;
10297
let items: CompletionItem[] = [];
@@ -137,12 +132,12 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
137132
scanner.setPosition(offset);
138133
scanner.scan();
139134
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);
141136
} else {
142137
if (location.path.length === 0) {
143-
collectPromise = this.jsonContribution.collectDefaultSuggestions(fileName, collector);
138+
collectPromise = this.jsonContribution.collectDefaultSuggestions(document.fileName, collector);
144139
} else {
145-
collectPromise = this.jsonContribution.collectValueSuggestions(fileName, location, collector);
140+
collectPromise = this.jsonContribution.collectValueSuggestions(document.fileName, location, collector);
146141
}
147142
}
148143
if (collectPromise) {

0 commit comments

Comments
 (0)