Package org.intellij.grammar

Examples of org.intellij.grammar.KnownAttribute$ListValue


      annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.KEYWORD);
    }
    else if (parent instanceof BnfListEntry && ((BnfListEntry)parent).getId() == psiElement) {
      boolean hasValue = ((BnfListEntry)parent).getLiteralExpression() != null;
      BnfAttr attr = PsiTreeUtil.getParentOfType(parent, BnfAttr.class);
      KnownAttribute attribute = attr != null ? KnownAttribute.getCompatibleAttribute(attr.getName()) : null;
      if (attribute == KnownAttribute.METHODS && !hasValue) {
        PsiReference reference = parent.findReferenceAt(psiElement.getStartOffsetInParent());
        PsiElement resolve = reference == null ? null : reference.resolve();
        if (resolve == null) {
          annotationHolder.createWarningAnnotation(psiElement, "Unresolved method reference");
        }
        else {
          annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.EXTERNAL);
        }
      }
    }
    else if (psiElement instanceof BnfRefOrTokenImpl) {
      if (parent instanceof BnfAttr) {
        String text = psiElement.getText();
        if (text.equals("true") || text.equals("false")) {
          annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.KEYWORD);
          return;
        }
      }
      PsiReference reference = psiElement.getReference();
      Object resolve = reference == null ? null : reference.resolve();
      if (resolve instanceof BnfRule) {
        addRuleHighlighting((BnfRule)resolve, psiElement, annotationHolder);
      }
      else if (resolve instanceof BnfAttr) {
        annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.ATTRIBUTE);
      }
      else if (resolve == null && parent instanceof BnfAttr) {
        annotationHolder.createWarningAnnotation(psiElement, "Unresolved rule reference");
      }
      else if (GrammarUtil.isExternalReference(psiElement)) {
        if (resolve == null && parent instanceof BnfExternalExpression && ((BnfExternalExpression)parent).getExpressionList().size() == 1 &&
            ParserGeneratorUtil.Rule.isMeta(ParserGeneratorUtil.Rule.of((BnfRefOrTokenImpl)psiElement))) {
          annotationHolder.createInfoAnnotation(parent, null).setTextAttributes(BnfSyntaxHighlighter.META_PARAM);
        }
        else {
          annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.EXTERNAL);
        }
      }
      else if (resolve == null) {
        annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.TOKEN);
      }
    }
    else if (psiElement instanceof BnfStringLiteralExpression) {
      if (parent instanceof BnfAttrPattern || parent instanceof BnfAttr || parent instanceof BnfListEntry) {
        annotationHolder.createInfoAnnotation(psiElement, null).setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
        annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(BnfSyntaxHighlighter.PATTERN);
      }
      if (parent instanceof BnfAttrPattern) {
        PsiReference reference = psiElement.getReference();
        if (reference instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)reference).multiResolve(false).length == 0) {
          annotationHolder.createWarningAnnotation(psiElement, "Pattern doesn't match any rule");
        }
      }
      else if (parent instanceof BnfAttr || parent instanceof BnfListEntry) {
        final String attrName = ObjectUtils.assertNotNull(PsiTreeUtil.getParentOfType(psiElement, BnfAttr.class)).getName();
        KnownAttribute attribute = KnownAttribute.getCompatibleAttribute(attrName);
        if (attribute != null) {
          String value = (String)ParserGeneratorUtil.getAttributeValue((BnfExpression)psiElement);
          Object resolve;
          String refType = "";
          JavaHelper javaHelper = JavaHelper.getJavaHelper(psiElement.getProject());
          if (attribute.getName().endsWith("Class") || attribute == KnownAttribute.MIXIN) {
            resolve = checkJavaResolve(value, javaHelper);
            refType = "class ";
          }
          else if (attribute.getName().endsWith("Package")) {
            resolve = javaHelper.findPackage(value);
            refType = "package ";
          }
          else if (attribute.getName().endsWith("Factory")) {
            resolve = Boolean.TRUE; // todo
          }
          else if (attribute == KnownAttribute.EXTENDS || attribute == KnownAttribute.IMPLEMENTS) {
            resolve = value.contains(".") ? checkJavaResolve(value, javaHelper) :
                      ((BnfFile)psiElement.getContainingFile()).getRule(value);
View Full Code Here

TOP

Related Classes of org.intellij.grammar.KnownAttribute$ListValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.