Search in sources :

Example 1 with QuteTemplateIndex

use of com.redhat.qute.project.indexing.QuteTemplateIndex in project quarkus-ls by redhat-developer.

the class QuteProject method collectInsert.

private void collectInsert(String insertParamater, Node parent, Template template, List<QuteIndex> indexes) {
    if (parent.getKind() == NodeKind.Section) {
        Section section = (Section) parent;
        if (section.getSectionKind() == SectionKind.INSERT) {
            Parameter parameter = section.getParameterAtIndex(0);
            if (parameter != null) {
                try {
                    if (insertParamater == null || insertParamater.equals(parameter.getValue())) {
                        Position position = template.positionAt(parameter.getStart());
                        Path path = createPath(template.getUri());
                        QuteTemplateIndex templateIndex = new QuteTemplateIndex(path, template.getTemplateId());
                        QuteIndex index = new QuteIndex("insert", parameter.getValue(), position, SectionKind.INSERT, templateIndex);
                        indexes.add(index);
                    }
                } catch (BadLocationException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    List<Node> children = parent.getChildren();
    for (Node node : children) {
        collectInsert(insertParamater, node, template, indexes);
    }
}
Also used : Path(java.nio.file.Path) FileUtils.createPath(com.redhat.qute.utils.FileUtils.createPath) QuteTemplateIndex(com.redhat.qute.project.indexing.QuteTemplateIndex) Position(org.eclipse.lsp4j.Position) Node(com.redhat.qute.parser.template.Node) QuteIndex(com.redhat.qute.project.indexing.QuteIndex) Parameter(com.redhat.qute.parser.template.Parameter) DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) Section(com.redhat.qute.parser.template.Section) BadLocationException(com.redhat.qute.ls.commons.BadLocationException)

Aggregations

DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)1 BadLocationException (com.redhat.qute.ls.commons.BadLocationException)1 Node (com.redhat.qute.parser.template.Node)1 Parameter (com.redhat.qute.parser.template.Parameter)1 Section (com.redhat.qute.parser.template.Section)1 QuteIndex (com.redhat.qute.project.indexing.QuteIndex)1 QuteTemplateIndex (com.redhat.qute.project.indexing.QuteTemplateIndex)1 FileUtils.createPath (com.redhat.qute.utils.FileUtils.createPath)1 Path (java.nio.file.Path)1 Position (org.eclipse.lsp4j.Position)1