use of com.redhat.qute.project.indexing.QuteIndex 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);
}
}
use of com.redhat.qute.project.indexing.QuteIndex in project quarkus-ls by redhat-developer.
the class QuteIndexerTest method definition.
@Test
public void definition() {
long start = System.currentTimeMillis();
QuteIndexer indexer = new QuteIndexer(createProject());
indexer.scan();
long end = System.currentTimeMillis();
System.err.println((end - start) + "ms");
// base.qute.html -->
// <title>{#insert title}Default Title{/}</title>
// BookPage/book.qute.html -->
// {#include base.qute.html}
// {#ti|tle}A Book{/title}
// get definition of title parameter of insert, declared in'base.qute.html'
List<QuteIndex> indexes = indexer.find("base.qute.html", "insert", "title");
assertNotNull(indexes);
assertEquals(1, indexes.size());
QuteIndex index = indexes.get(0);
assertEquals(//
"QuteIndex [\n" + //
" tag = \"insert\"\n" + //
" parameter = \"title\"\n" + //
" position = Position [\n" + //
" line = 3\n" + //
" character = 18\n" + //
" ]\n" + //
" kind = INSERT\n" + //
" templateId = \"base.qute.html\"\n" + "]", index.toString());
}
use of com.redhat.qute.project.indexing.QuteIndex in project quarkus-ls by redhat-developer.
the class QuteIndexerTest method referencesOfIncludedFile.
@Test
public void referencesOfIncludedFile() {
long start = System.currentTimeMillis();
QuteIndexer indexer = new QuteIndexer(createProject());
indexer.scan();
long end = System.currentTimeMillis();
System.err.println((end - start) + "ms");
// base.qute.html -->
// <title>{#insert title}Default Title{/}</title>
// ...
// {#insert body}No body!{/}
// 1. reference
// BookPage/book.qute.html -->
// {#include base}
// {#title}A Book{/title}
// 2. reference
// BookPage/books.qute.html -->
// {#include base}
// {#title}Books{/title}
List<QuteIndex> indexes = indexer.find(null, "include", "base");
assertNotNull(indexes);
assertEquals(2, indexes.size());
assertEquals(//
"[QuteIndex [\n" + //
" tag = \"include\"\n" + //
" parameter = \"base\"\n" + //
" position = Position [\n" + //
" line = 0\n" + //
" character = 10\n" + //
" ]\n" + //
" kind = INCLUDE\n" + //
" templateId = \"BookPage/books.qute.html\"\n" + //
"], QuteIndex [\n" + //
" tag = \"include\"\n" + //
" parameter = \"base\"\n" + //
" position = Position [\n" + //
" line = 0\n" + //
" character = 10\n" + //
" ]\n" + //
" kind = INCLUDE\n" + //
" templateId = \"BookPage/book.qute.html\"\n" + "]]", indexes.toString());
}
Aggregations