release: WRNexusJS 0.2.29
This commit is contained in:
@@ -2,14 +2,10 @@
|
||||
|
||||
const vscode = require("vscode");
|
||||
|
||||
const COMPONENT_DECLARATION =
|
||||
/^\s*(component|layout)\s+([A-Za-z_$][\w$]*)\s*\{/gm;
|
||||
const COMPONENT_DECLARATION = /^\s*(component|layout)\s+([A-Za-z_$][\w$]*)\s*\{/gm;
|
||||
|
||||
function getTagAtPosition(document, position) {
|
||||
const range = document.getWordRangeAtPosition(
|
||||
position,
|
||||
/[A-Za-z_$][\w$]*/,
|
||||
);
|
||||
const range = document.getWordRangeAtPosition(position, /[A-Za-z_$][\w$]*/);
|
||||
|
||||
if (!range) {
|
||||
return null;
|
||||
@@ -23,17 +19,13 @@ function getTagAtPosition(document, position) {
|
||||
|
||||
const line = document.lineAt(position.line).text;
|
||||
const offset = document.offsetAt(position);
|
||||
const lineStart = document.offsetAt(
|
||||
new vscode.Position(position.line, 0),
|
||||
);
|
||||
const lineStart = document.offsetAt(new vscode.Position(position.line, 0));
|
||||
|
||||
const characterOffset = offset - lineStart;
|
||||
const before = line.slice(0, characterOffset);
|
||||
const after = line.slice(characterOffset);
|
||||
|
||||
const insideTag =
|
||||
before.lastIndexOf("<") > before.lastIndexOf(">") &&
|
||||
after.includes(">");
|
||||
const insideTag = before.lastIndexOf("<") > before.lastIndexOf(">") && after.includes(">");
|
||||
|
||||
if (!insideTag) {
|
||||
return null;
|
||||
@@ -75,21 +67,12 @@ async function findDeclaration(name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const nameOffset =
|
||||
match.index +
|
||||
match[0].indexOf(declarationName);
|
||||
const nameOffset = match.index + match[0].indexOf(declarationName);
|
||||
|
||||
const start = document.positionAt(nameOffset);
|
||||
const end = document.positionAt(
|
||||
nameOffset + declarationName.length,
|
||||
);
|
||||
const end = document.positionAt(nameOffset + declarationName.length);
|
||||
|
||||
matches.push(
|
||||
new vscode.Location(
|
||||
uri,
|
||||
new vscode.Range(start, end),
|
||||
),
|
||||
);
|
||||
matches.push(new vscode.Location(uri, new vscode.Range(start, end)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,4 +114,4 @@ module.exports = {
|
||||
getTagAtPosition,
|
||||
provideDefinition,
|
||||
registerDefinitionProvider,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user