Search in sources :

Example 6 with HeaderValue

use of org.jetbrains.lang.manifest.psi.HeaderValue in project intellij-plugins by JetBrains.

the class OsgiManifestPsiTest method testClauses.

public void testClauses() {
    ManifestFile file = createFile("Import-Package: a.b,c.d;a=value;d:=value");
    Header header = file.getHeader("Import-Package");
    assertNotNull(header);
    List<HeaderValue> clauses = header.getHeaderValues();
    assertEquals(2, clauses.size());
    Clause clause1 = (Clause) clauses.get(0), clause2 = (Clause) clauses.get(1);
    assertEquals(0, clause1.getAttributes().size());
    assertEquals(0, clause1.getDirectives().size());
    assertEquals(1, clause2.getAttributes().size());
    assertEquals(1, clause2.getDirectives().size());
    assertNotNull(clause2.getAttribute("a"));
    assertNull(clause2.getAttribute("b"));
    assertNotNull(clause2.getDirective("d"));
    assertNull(clause2.getDirective("z"));
}
Also used : HeaderValue(org.jetbrains.lang.manifest.psi.HeaderValue) Header(org.jetbrains.lang.manifest.psi.Header) Clause(org.osmorc.manifest.lang.psi.Clause) ManifestFile(org.jetbrains.lang.manifest.psi.ManifestFile)

Example 7 with HeaderValue

use of org.jetbrains.lang.manifest.psi.HeaderValue in project intellij-plugins by JetBrains.

the class OsgiManifestPsiTest method assertAssignment.

private static void assertAssignment(ManifestFile file, boolean attribute, String name, String expected) {
    List<Header> headers = file.getHeaders();
    assertEquals(1, headers.size());
    List<HeaderValue> clauses = headers.get(0).getHeaderValues();
    assertEquals(1, clauses.size());
    assertTrue(clauses.get(0) instanceof Clause);
    Clause clause = (Clause) clauses.get(0);
    AssignmentExpression element = attribute ? clause.getAttribute(name) : clause.getDirective(name);
    if (expected != null) {
        assertNotNull(element);
        assertEquals(expected, element.getValue());
    } else {
        assertNull(element);
    }
}
Also used : HeaderValue(org.jetbrains.lang.manifest.psi.HeaderValue) Header(org.jetbrains.lang.manifest.psi.Header) AssignmentExpression(org.osmorc.manifest.lang.psi.AssignmentExpression) Clause(org.osmorc.manifest.lang.psi.Clause)

Aggregations

HeaderValue (org.jetbrains.lang.manifest.psi.HeaderValue)7 Header (org.jetbrains.lang.manifest.psi.Header)4 HeaderValuePart (org.jetbrains.lang.manifest.psi.HeaderValuePart)3 Clause (org.osmorc.manifest.lang.psi.Clause)3 ManifestFile (org.jetbrains.lang.manifest.psi.ManifestFile)2 Annotation (com.intellij.lang.annotation.Annotation)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiFile (com.intellij.psi.PsiFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 AssignmentExpression (org.osmorc.manifest.lang.psi.AssignmentExpression)1