Search in sources :

Example 1 with HeaderParser

use of org.jetbrains.lang.manifest.header.HeaderParser in project intellij-community by JetBrains.

the class HeaderAnnotator method annotate.

@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
    if (psiElement instanceof Header) {
        Header header = (Header) psiElement;
        String name = header.getName();
        if (!isValidName(name)) {
            holder.createAnnotation(HighlightSeverity.ERROR, header.getNameElement().getTextRange(), ManifestBundle.message("header.name.invalid"));
        } else {
            HeaderParser headerParser = myRepository.getHeaderParser(name);
            if (headerParser != null) {
                headerParser.annotate(header, holder);
            }
        }
    }
}
Also used : HeaderParser(org.jetbrains.lang.manifest.header.HeaderParser) Header(org.jetbrains.lang.manifest.psi.Header)

Example 2 with HeaderParser

use of org.jetbrains.lang.manifest.header.HeaderParser in project intellij-community by JetBrains.

the class ManifestParser method parseHeader.

private void parseHeader(PsiBuilder builder) {
    PsiBuilder.Marker header = builder.mark();
    String headerName = builder.getTokenText();
    assert headerName != null : "[" + builder.getOriginalText() + "]@" + builder.getCurrentOffset();
    builder.advanceLexer();
    if (builder.getTokenType() == ManifestTokenType.COLON) {
        builder.advanceLexer();
        if (!expect(builder, ManifestTokenType.SIGNIFICANT_SPACE)) {
            builder.error(ManifestBundle.message("manifest.whitespace.expected"));
        }
        HeaderParser headerParser = notNull(myRepository.getHeaderParser(headerName), StandardHeaderParser.INSTANCE);
        headerParser.parse(builder);
    } else {
        PsiBuilder.Marker marker = builder.mark();
        consumeHeaderValue(builder);
        marker.error(ManifestBundle.message("manifest.colon.expected"));
    }
    header.done(ManifestElementType.HEADER);
}
Also used : StandardHeaderParser(org.jetbrains.lang.manifest.header.impl.StandardHeaderParser) HeaderParser(org.jetbrains.lang.manifest.header.HeaderParser) PsiBuilder(com.intellij.lang.PsiBuilder)

Aggregations

HeaderParser (org.jetbrains.lang.manifest.header.HeaderParser)2 PsiBuilder (com.intellij.lang.PsiBuilder)1 StandardHeaderParser (org.jetbrains.lang.manifest.header.impl.StandardHeaderParser)1 Header (org.jetbrains.lang.manifest.psi.Header)1