-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a522f45
commit ab8cf5c
Showing
23 changed files
with
140 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/language-service/src/languageFeatures/renamePrepare.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type * as vscode from 'vscode-languageserver-protocol'; | ||
import type { TextDocument } from 'vscode-languageserver-textdocument'; | ||
|
||
export function getOverlapRange( | ||
range1Start: number, | ||
range1End: number, | ||
range2Start: number, | ||
range2End: number, | ||
): { start: number, end: number; } | undefined { | ||
|
||
const start = Math.max(range1Start, range2Start); | ||
const end = Math.min(range1End, range2End); | ||
|
||
if (start > end) | ||
return undefined; | ||
|
||
return { | ||
start, | ||
end, | ||
}; | ||
} | ||
|
||
export function isInsideRange(parent: vscode.Range, child: vscode.Range) { | ||
if (child.start.line < parent.start.line) return false; | ||
if (child.end.line > parent.end.line) return false; | ||
if (child.start.line === parent.start.line && child.start.character < parent.start.character) return false; | ||
if (child.end.line === parent.end.line && child.end.character > parent.end.character) return false; | ||
return true; | ||
} | ||
|
||
export function getWordRange(wordPattern: RegExp, position: vscode.Position, document: TextDocument): vscode.Range | undefined { | ||
const lineStart: vscode.Position = { | ||
line: position.line, | ||
character: 0, | ||
}; | ||
const lineEnd: vscode.Position = { | ||
line: position.line + 1, | ||
character: 0, | ||
}; | ||
const offset = document.offsetAt(position); | ||
const lineStartOffset = document.offsetAt(lineStart); | ||
const lineText = document.getText({ start: lineStart, end: lineEnd }); | ||
for (const match of lineText.matchAll(wordPattern)) { | ||
if (match.index === undefined) continue; | ||
const matchStart = match.index + lineStartOffset; | ||
const matchEnd = matchStart + match[0].length; | ||
if (offset >= matchStart && offset <= matchEnd) { | ||
return { | ||
start: document.positionAt(matchStart), | ||
end: document.positionAt(matchEnd), | ||
}; | ||
} | ||
} | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
export * from './common'; | ||
export * from './ts'; | ||
export * from './path'; | ||
export * from './uriMap'; | ||
|
||
// fix build | ||
export * as _1 from 'vscode-languageserver-textdocument'; | ||
export * as _2 from 'vscode-uri'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.