Skip to content

Commit

Permalink
Refactor hoverService to use getNodeRange from nodeManager
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 20, 2024
1 parent f75858d commit f4841ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
6 changes: 1 addition & 5 deletions server/gx-workflow-ls-format2/src/services/hoverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ export class GxFormat2HoverService {
}
}

const hoverRange = Range.create(
textDocument.positionAt(hoverRangeNode.offset),
textDocument.positionAt(hoverRangeNode.offset + hoverRangeNode.length)
);

const hoverRange = nodeManager.getNodeRange(hoverRangeNode);
const location = nodeManager.getPathFromNode(hoverRangeNode);
const schemaNode = this.schemaNodeResolver.resolveSchemaContext(location);
const contents = this.getHoverMarkdownContentsForNode(schemaNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export class WorkflowTestsHoverServiceImpl implements WorkflowTestsHoverService
return Promise.resolve(null);
}

const hoverRange = Range.create(
documentContext.textDocument.positionAt(hoverRangeNode.offset),
documentContext.textDocument.positionAt(hoverRangeNode.offset + hoverRangeNode.length)
);

const hoverRange = documentContext.nodeManager.getNodeRange(hoverRangeNode);
if (this.parentPropertyMatchesKey(node, "job")) {
const inputHover = await this.getHoverForWorkflowInput(documentContext, node, hoverRange);
if (inputHover) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Diagnostic, DiagnosticSeverity, DocumentContext, Range } from "@gxwf/server-common/src/languageTypes";
import { Diagnostic, DiagnosticSeverity, DocumentContext } from "@gxwf/server-common/src/languageTypes";
import { inject, injectable } from "inversify";
import { ResolvedSchema } from "../schema/jsonSchema";
import { WorkflowTestsSchemaProvider } from "../schema/provider";
Expand Down Expand Up @@ -37,16 +37,10 @@ export class WorkflowTestsValidationServiceImpl implements WorkflowTestsValidati
const property = astRoot.type === "object" ? astRoot.properties[0] : undefined;
if (property && property.keyNode.value === "$schema") {
const node = property.valueNode || property;
const range = Range.create(
documentContext.textDocument.positionAt(node.offset),
documentContext.textDocument.positionAt(node.offset + node.length)
);
const range = documentContext.nodeManager.getNodeRange(node);
addProblem(Diagnostic.create(range, errorMessage, severity));
} else {
const range = Range.create(
documentContext.textDocument.positionAt(astRoot.offset),
documentContext.textDocument.positionAt(astRoot.offset + 1)
);
const range = documentContext.nodeManager.getDefaultRange();
addProblem(Diagnostic.create(range, errorMessage, severity));
}
}
Expand Down

0 comments on commit f4841ba

Please sign in to comment.