use of com.redhat.qute.parser.template.Node in project quarkus-ls by redhat-developer.
the class QuteHighlighting method findDocumentHighlights.
public List<DocumentHighlight> findDocumentHighlights(Template template, Position position, CancelChecker cancelChecker) {
try {
List<DocumentHighlight> highlights = new ArrayList<>();
int offset = template.offsetAt(position);
Node node = template.findNodeAt(offset);
if (node == null) {
return Collections.emptyList();
}
node = QutePositionUtility.findBestNode(offset, node);
switch(node.getKind()) {
case ParameterDeclaration:
case Parameter:
highlightReferenceObjectPart(node, offset, highlights, cancelChecker);
break;
case ExpressionPart:
Part part = (Part) node;
if (part.getPartKind() == PartKind.Object) {
highlightDeclaredObject((ObjectPart) part, highlights, cancelChecker);
}
break;
case Section:
higlightSection((Section) node, offset, position, highlights, cancelChecker);
break;
default:
}
return highlights;
} catch (BadLocationException e) {
LOGGER.log(Level.SEVERE, "In QuteHighlighting the client provided Position is at a BadLocation", e);
return Collections.emptyList();
}
}
use of com.redhat.qute.parser.template.Node in project quarkus-ls by redhat-developer.
the class QuteHover method doHover.
public CompletableFuture<Hover> doHover(Template template, Position position, SharedSettings settings, CancelChecker cancelChecker) {
cancelChecker.checkCanceled();
HoverRequest hoverRequest = null;
try {
hoverRequest = new HoverRequest(template, position, settings);
} catch (BadLocationException e) {
LOGGER.log(Level.SEVERE, "Failed creating HoverRequest", e);
return NO_HOVER;
}
Node node = hoverRequest.getNode();
if (node == null) {
return NO_HOVER;
}
switch(node.getKind()) {
case Section:
// - Start end tag definition
Section section = (Section) node;
return doHoverForSection(section, template, hoverRequest, cancelChecker);
case ParameterDeclaration:
ParameterDeclaration parameterDeclaration = (ParameterDeclaration) node;
return doHoverForParameterDeclaration(parameterDeclaration, template, hoverRequest, cancelChecker);
case ExpressionPart:
Part part = (Part) node;
return doHoverForExpressionPart(part, template, hoverRequest, cancelChecker);
case Parameter:
Parameter parameter = (Parameter) node;
return doHoverForParameter(parameter, template, hoverRequest);
default:
return NO_HOVER;
}
}
use of com.redhat.qute.parser.template.Node in project quarkus-ls by redhat-developer.
the class QuteSearchUtils method searchReferencedObjects.
private static void searchReferencedObjects(String partName, PartNameMatcher matcher, Node owerNode, BiConsumer<Node, Range> collector, CancelChecker cancelChecker) {
Template template = owerNode.getOwnerTemplate();
Node parent = owerNode.getKind() == NodeKind.ParameterDeclaration ? template : owerNode;
searchReferencedObjects(partName, matcher, parent, owerNode, collector, cancelChecker);
}
use of com.redhat.qute.parser.template.Node in project quarkus-ls by redhat-developer.
the class UserTagUtils method collectUserTagParameters.
private static void collectUserTagParameters(Node parent, Template template, Set<String> extistingObjectParts, Consumer<ObjectPart> collector, CancelChecker cancelChecker) {
cancelChecker.checkCanceled();
if (parent.getKind() == NodeKind.Expression) {
Expression expression = (Expression) parent;
collectUserTagParameters(expression, extistingObjectParts, collector, cancelChecker);
return;
} else if (parent.getKind() == NodeKind.Section) {
Section section = (Section) parent;
List<Parameter> parameters = section.getParameters();
for (Parameter parameter : parameters) {
if (parameter.isCanHaveExpression()) {
Expression expression = parameter.getJavaTypeExpression();
collectUserTagParameters(expression, extistingObjectParts, collector, cancelChecker);
}
}
}
List<Node> children = parent.getChildren();
for (Node node : children) {
collectUserTagParameters(node, template, extistingObjectParts, collector, cancelChecker);
}
}
use of com.redhat.qute.parser.template.Node in project quarkus-ls by redhat-developer.
the class QuteLinkedEditing method findLinkedEditingRanges.
public LinkedEditingRanges findLinkedEditingRanges(Template template, Position position, CancelChecker cancelChecker) {
try {
int offset = template.offsetAt(position);
Node node = template.findNodeAt(offset);
if (node == null) {
return null;
}
node = QutePositionUtility.findBestNode(offset, node);
List<Range> ranges = new ArrayList<>();
//
QuteSearchUtils.searchReferencedObjects(//
node, //
offset, (n, range) -> ranges.add(range), true, cancelChecker);
if (ranges.size() <= 1) {
return null;
}
return new LinkedEditingRanges(ranges);
} catch (BadLocationException e) {
LOGGER.log(Level.SEVERE, "In QuteLinkedEditing the client provided Position is at a BadLocation", e);
return null;
}
}
Aggregations