Skip to content

Commit c2c7b90

Browse files
committed
consolidate the use of normalizeSlashes in lookup helpers
1 parent 1d8fab8 commit c2c7b90

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

src/services/services.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,7 @@ module ts {
19771977
}
19781978

19791979
function getValidSourceFile(fileName: string): SourceFile {
1980+
fileName = normalizeSlashes(fileName);
19801981
var sourceFile = program.getSourceFile(getCanonicalFileName(fileName));
19811982
if (!sourceFile) {
19821983
throw new Error("Could not find file: '" + fileName + "'.");
@@ -2126,8 +2127,6 @@ module ts {
21262127
function getSyntacticDiagnostics(fileName: string) {
21272128
synchronizeHostData();
21282129

2129-
fileName = normalizeSlashes(fileName);
2130-
21312130
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
21322131
}
21332132

@@ -2138,7 +2137,6 @@ module ts {
21382137
function getSemanticDiagnostics(fileName: string) {
21392138
synchronizeHostData();
21402139

2141-
fileName = normalizeSlashes(fileName)
21422140
var targetSourceFile = getValidSourceFile(fileName);
21432141

21442142
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
@@ -2215,8 +2213,6 @@ module ts {
22152213
function getCompletionsAtPosition(fileName: string, position: number) {
22162214
synchronizeHostData();
22172215

2218-
fileName = normalizeSlashes(fileName);
2219-
22202216
var syntacticStart = new Date().getTime();
22212217
var sourceFile = getValidSourceFile(fileName);
22222218

@@ -2635,8 +2631,6 @@ module ts {
26352631
function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
26362632
// Note: No need to call synchronizeHostData, as we have captured all the data we need
26372633
// in the getCompletionsAtPosition earlier
2638-
fileName = normalizeSlashes(fileName);
2639-
26402634
var sourceFile = getValidSourceFile(fileName);
26412635

26422636
var session = activeCompletionSession;
@@ -3155,7 +3149,6 @@ module ts {
31553149
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
31563150
synchronizeHostData();
31573151

3158-
fileName = normalizeSlashes(fileName);
31593152
var sourceFile = getValidSourceFile(fileName);
31603153
var node = getTouchingPropertyName(sourceFile, position);
31613154
if (!node) {
@@ -3201,7 +3194,6 @@ module ts {
32013194
function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
32023195
synchronizeHostData();
32033196

3204-
fileName = normalizeSlashes(fileName);
32053197
var sourceFile = getValidSourceFile(fileName);
32063198

32073199
var node = getTouchingPropertyName(sourceFile, position);
@@ -3337,7 +3329,6 @@ module ts {
33373329
function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
33383330
synchronizeHostData();
33393331

3340-
fileName = normalizeSlashes(fileName);
33413332
var sourceFile = getValidSourceFile(fileName);
33423333

33433334
var node = getTouchingWord(sourceFile, position);
@@ -3882,7 +3873,6 @@ module ts {
38823873
function findReferences(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
38833874
synchronizeHostData();
38843875

3885-
fileName = normalizeSlashes(fileName);
38863876
var sourceFile = getValidSourceFile(fileName);
38873877

38883878
var node = getTouchingPropertyName(sourceFile, position);
@@ -4705,7 +4695,6 @@ module ts {
47054695
function getEmitOutput(fileName: string): EmitOutput {
47064696
synchronizeHostData();
47074697

4708-
fileName = normalizeSlashes(fileName);
47094698
var sourceFile = getValidSourceFile(fileName);
47104699

47114700
var outputFiles: OutputFile[] = [];
@@ -4849,21 +4838,17 @@ module ts {
48494838
function getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
48504839
synchronizeHostData();
48514840

4852-
fileName = normalizeSlashes(fileName);
48534841
var sourceFile = getValidSourceFile(fileName);
48544842

48554843
return SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
48564844
}
48574845

48584846
/// Syntactic features
48594847
function getCurrentSourceFile(fileName: string): SourceFile {
4860-
fileName = normalizeSlashes(fileName);
4861-
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
4862-
return currentSourceFile;
4848+
return syntaxTreeCache.getCurrentSourceFile(fileName);
48634849
}
48644850

48654851
function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
4866-
fileName = ts.normalizeSlashes(fileName);
48674852
// Get node at the location
48684853
var node = getTouchingPropertyName(getCurrentSourceFile(fileName), startPos);
48694854

@@ -4919,19 +4904,15 @@ module ts {
49194904

49204905
function getBreakpointStatementAtPosition(fileName: string, position: number) {
49214906
// doesn't use compiler - no need to synchronize with host
4922-
fileName = ts.normalizeSlashes(fileName);
49234907
return BreakpointResolver.spanInSourceFileAtLocation(getCurrentSourceFile(fileName), position);
49244908
}
49254909

49264910
function getNavigationBarItems(fileName: string): NavigationBarItem[] {
4927-
fileName = normalizeSlashes(fileName);
4928-
49294911
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(fileName));
49304912
}
49314913

49324914
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
49334915
synchronizeHostData();
4934-
fileName = normalizeSlashes(fileName);
49354916

49364917
var sourceFile = getValidSourceFile(fileName);
49374918

@@ -5005,7 +4986,6 @@ module ts {
50054986

50064987
function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
50074988
// doesn't use compiler - no need to synchronize with host
5008-
fileName = normalizeSlashes(fileName);
50094989
var sourceFile = getCurrentSourceFile(fileName);
50104990

50114991
// Make a scanner we can get trivia from.
@@ -5224,7 +5204,6 @@ module ts {
52245204

52255205
function getOutliningSpans(fileName: string): OutliningSpan[] {
52265206
// doesn't use compiler - no need to synchronize with host
5227-
fileName = normalizeSlashes(fileName);
52285207
var sourceFile = getCurrentSourceFile(fileName);
52295208
return OutliningElementsCollector.collectElements(sourceFile);
52305209
}
@@ -5283,8 +5262,6 @@ module ts {
52835262
}
52845263

52855264
function getIndentationAtPosition(fileName: string, position: number, editorOptions: EditorOptions) {
5286-
fileName = normalizeSlashes(fileName);
5287-
52885265
var start = new Date().getTime();
52895266
var sourceFile = getCurrentSourceFile(fileName);
52905267
log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start));
@@ -5298,21 +5275,16 @@ module ts {
52985275
}
52995276

53005277
function getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[] {
5301-
fileName = normalizeSlashes(fileName);
53025278
var sourceFile = getCurrentSourceFile(fileName);
53035279
return formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options);
53045280
}
53055281

53065282
function getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[] {
5307-
fileName = normalizeSlashes(fileName);
5308-
53095283
var sourceFile = getCurrentSourceFile(fileName);
53105284
return formatting.formatDocument(sourceFile, getRuleProvider(options), options);
53115285
}
53125286

53135287
function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[] {
5314-
fileName = normalizeSlashes(fileName);
5315-
53165288
var sourceFile = getCurrentSourceFile(fileName);
53175289

53185290
if (key === "}") {
@@ -5337,8 +5309,6 @@ module ts {
53375309
// anything away.
53385310
synchronizeHostData();
53395311

5340-
fileName = normalizeSlashes(fileName);
5341-
53425312
var sourceFile = getValidSourceFile(fileName);
53435313

53445314
cancellationToken.throwIfCancellationRequested();
@@ -5484,7 +5454,6 @@ module ts {
54845454
function getRenameInfo(fileName: string, position: number): RenameInfo {
54855455
synchronizeHostData();
54865456

5487-
fileName = normalizeSlashes(fileName);
54885457
var sourceFile = getValidSourceFile(fileName);
54895458

54905459
var node = getTouchingWord(sourceFile, position);

0 commit comments

Comments
 (0)