Search in sources :

Example 1 with QuteIndexer

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

the class QuteIndexerTest method referencesOfIncludedTag.

@Test
public void referencesOfIncludedTag() {
    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, "body", null);
    assertNotNull(indexes);
    assertEquals(2, indexes.size());
    assertEquals(// 
    "[QuteIndex [\n" + // 
    "  tag = \"body\"\n" + // 
    "  parameter = null\n" + // 
    "  position = Position [\n" + // 
    "    line = 2\n" + // 
    "    character = 2\n" + // 
    "  ]\n" + // 
    "  kind = CUSTOM\n" + // 
    "  templateId = \"BookPage/books.qute.html\"\n" + // 
    "], QuteIndex [\n" + // 
    "  tag = \"body\"\n" + // 
    "  parameter = null\n" + // 
    "  position = Position [\n" + // 
    "    line = 2\n" + // 
    "    character = 2\n" + // 
    "  ]\n" + // 
    "  kind = CUSTOM\n" + // 
    "  templateId = \"BookPage/book.qute.html\"\n" + "]]", indexes.toString());
}
Also used : QuteIndex(com.redhat.qute.project.indexing.QuteIndex) QuteIndexer(com.redhat.qute.project.indexing.QuteIndexer) Test(org.junit.jupiter.api.Test)

Example 2 with QuteIndexer

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

the class QuteIndexerTest method completion.

@Test
public void completion() {
    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!{/}
    // BookPage/book.qute.html -->
    // {#include base.qute.html}
    // {#|
    List<QuteIndex> indexes = indexer.find("base.qute.html", "insert", null);
    assertNotNull(indexes);
    assertEquals(2, indexes.size());
    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" + // 
    "], QuteIndex [\n" + // 
    "  tag = \"insert\"\n" + // 
    "  parameter = \"body\"\n" + // 
    "  position = Position [\n" + // 
    "    line = 8\n" + // 
    "    character = 9\n" + // 
    "  ]\n" + // 
    "  kind = INSERT\n" + // 
    "  templateId = \"base.qute.html\"\n" + "]]", indexes.toString());
}
Also used : QuteIndex(com.redhat.qute.project.indexing.QuteIndex) QuteIndexer(com.redhat.qute.project.indexing.QuteIndexer) Test(org.junit.jupiter.api.Test)

Example 3 with QuteIndexer

use of com.redhat.qute.project.indexing.QuteIndexer 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());
}
Also used : QuteIndex(com.redhat.qute.project.indexing.QuteIndex) QuteIndexer(com.redhat.qute.project.indexing.QuteIndexer) Test(org.junit.jupiter.api.Test)

Example 4 with QuteIndexer

use of com.redhat.qute.project.indexing.QuteIndexer 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());
}
Also used : QuteIndex(com.redhat.qute.project.indexing.QuteIndex) QuteIndexer(com.redhat.qute.project.indexing.QuteIndexer) Test(org.junit.jupiter.api.Test)

Aggregations

QuteIndex (com.redhat.qute.project.indexing.QuteIndex)4 QuteIndexer (com.redhat.qute.project.indexing.QuteIndexer)4 Test (org.junit.jupiter.api.Test)4