Adjust variable naming
This commit is contained in:
@@ -30,15 +30,16 @@ export function mapToExpressionPos(token: TemplateToken, position: Position): Ex
|
||||
for (const originalExp of token.originalExpressions) {
|
||||
// Find the original expression that contains the position
|
||||
if (posWithinRange(pos, originalExp.expressionRange!)) {
|
||||
const tr = mapRange(originalExp.expressionRange);
|
||||
const exprRange = mapRange(originalExp.expressionRange);
|
||||
|
||||
return {
|
||||
expression: originalExp.expression,
|
||||
// Adjust the position to point into the expression
|
||||
position: {
|
||||
line: pos.line - tr.start.line - 1,
|
||||
column: pos.column - tr.start.character - 1
|
||||
line: pos.line - exprRange.start.line - 1,
|
||||
column: pos.column - exprRange.start.character - 1
|
||||
},
|
||||
documentRange: tr
|
||||
documentRange: exprRange
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -46,13 +47,14 @@ export function mapToExpressionPos(token: TemplateToken, position: Position): Ex
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const tr = mapRange(token.expressionRange!);
|
||||
const exprRange = mapRange(token.expressionRange!);
|
||||
return {
|
||||
expression: token.expression,
|
||||
// Adjust the position to point into the expression
|
||||
position: {
|
||||
line: pos.line - tr.start.line - 1,
|
||||
column: pos.column - tr.start.character - 1
|
||||
line: pos.line - exprRange.start.line - 1,
|
||||
column: pos.column - exprRange.start.character - 1
|
||||
},
|
||||
documentRange: tr
|
||||
documentRange: exprRange
|
||||
};
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ describe("visitor", () => {
|
||||
|
||||
async function hoverExpression(input: string) {
|
||||
const [td, pos] = getPositionFromCursor(input);
|
||||
const allowedContext = ["github"]; //token.definitionInfo?.allowedContext || [];
|
||||
const allowedContext = ["github"];
|
||||
|
||||
const file: File = {
|
||||
name: td.uri,
|
||||
@@ -114,7 +114,13 @@ async function hoverExpression(input: string) {
|
||||
const workflowContext = getWorkflowContext(td.uri, template, []);
|
||||
const context = await getContext(allowedContext, contextProviderConfig, workflowContext, Mode.Completion);
|
||||
|
||||
const r = new HoverVisitor(
|
||||
const l = new Lexer(td.getText());
|
||||
const lr = l.lex();
|
||||
|
||||
const p = new Parser(lr.tokens, ["github"], []);
|
||||
const expr = p.parse();
|
||||
|
||||
const hv = new HoverVisitor(
|
||||
{
|
||||
line: pos.line,
|
||||
column: pos.character
|
||||
@@ -123,12 +129,5 @@ async function hoverExpression(input: string) {
|
||||
[],
|
||||
validatorFunctions
|
||||
);
|
||||
|
||||
const l = new Lexer(td.getText());
|
||||
const lr = l.lex();
|
||||
|
||||
const p = new Parser(lr.tokens, ["github"], []);
|
||||
const expr = p.parse();
|
||||
|
||||
return r.hover(expr);
|
||||
return hv.hover(expr);
|
||||
}
|
||||
|
||||
@@ -139,25 +139,25 @@ function expressionHover(
|
||||
const p = new Parser(lr.tokens, namedContexts, functions);
|
||||
const expr = p.parse();
|
||||
|
||||
const v = new HoverVisitor(position, context, [], validatorFunctions);
|
||||
const hoverResult = v.hover(expr);
|
||||
const hv = new HoverVisitor(position, context, [], validatorFunctions);
|
||||
const hoverResult = hv.hover(expr);
|
||||
if (!hoverResult) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const mr = hoverResult.range;
|
||||
const exprRange = hoverResult.range;
|
||||
|
||||
return {
|
||||
contents: hoverResult?.description || hoverResult?.label,
|
||||
// Map the expression range back to a document range
|
||||
range: {
|
||||
start: {
|
||||
line: documentRange.start.line + mr.start.line,
|
||||
character: documentRange.start.character + mr.start.column
|
||||
line: documentRange.start.line + exprRange.start.line,
|
||||
character: documentRange.start.character + exprRange.start.column
|
||||
},
|
||||
end: {
|
||||
line: documentRange.start.line + mr.end.line,
|
||||
character: documentRange.start.character + mr.end.column
|
||||
line: documentRange.start.line + exprRange.end.line,
|
||||
character: documentRange.start.character + exprRange.end.column
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user