当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationHolder.createErrorAnnotation方法代码示例

本文整理汇总了Java中com.intellij.lang.annotation.AnnotationHolder.createErrorAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationHolder.createErrorAnnotation方法的具体用法?Java AnnotationHolder.createErrorAnnotation怎么用?Java AnnotationHolder.createErrorAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.annotation.AnnotationHolder的用法示例。


在下文中一共展示了AnnotationHolder.createErrorAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, Collection<BsbErrorAnnotation> annotationResult, @NotNull AnnotationHolder holder) {
    LineNumbering lineNumbering = new LineNumbering(file.getText());
    for (BsbErrorAnnotation annotation : annotationResult) {
        PsiElement elementAtOffset = null;
        /*
        if (annotation.m_element != null) {
            elementAtOffset = annotation.m_element;
        } else {
            int startOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_startOffset);
            elementAtOffset = findElementAtOffset(file, startOffset);
        }
        */

        if (elementAtOffset != null) {
            holder.createErrorAnnotation(elementAtOffset, annotation.m_message);
            BucklescriptProjectComponent.getInstance(file.getProject()).associatePsiElement(file.getVirtualFile(), elementAtOffset);
        } else {
            int startOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_startOffset);
            int endOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_endOffset);
            holder.createErrorAnnotation(new TextRangeInterval(startOffset, endOffset), annotation.m_message);
        }
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:25,代码来源:BsErrorAnnotator.java

示例2: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof ChoiceStatementElement) {
    boolean foundDefault = false;
    for (PsiElement child : psiElement.getChildren()) {
      if (!(child instanceof SoyChoiceClause)) {
        continue;
      }

      SoyChoiceClause clause = (SoyChoiceClause) child;

      if (foundDefault) {
        if (!clause.isDefault()) {
          annotationHolder.createErrorAnnotation(
              child, "{case} clauses are not allowed after {default}.");
        } else if (clause.isDefault()) {
          annotationHolder.createErrorAnnotation(
              child, "There can only be one {default} clause.");
        }
      } else if (clause.isDefault()) {
        foundDefault = true;
      }
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:26,代码来源:CaseAndDefaultAnnotator.java

示例3: verifyExtensionInterfaces

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private void verifyExtensionInterfaces( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiJavaCodeReferenceElementImpl &&
      ((PsiJavaCodeReferenceElementImpl)element).getTreeParent() instanceof ReferenceListElement &&
      ((PsiJavaCodeReferenceElementImpl)element).getTreeParent().getText().startsWith( PsiKeyword.IMPLEMENTS ) )
  {
    final PsiElement resolve = element.getReference().resolve();
    if( resolve instanceof PsiExtensibleClass )
    {
      PsiExtensibleClass iface = (PsiExtensibleClass)resolve;
      if( !isStructuralInterface( iface ) )
      {
        TextRange range = new TextRange( element.getTextRange().getStartOffset(),
                                         element.getTextRange().getEndOffset() );
        holder.createErrorAnnotation( range, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.getName() ) );
      }
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:20,代码来源:ExtensionClassAnnotator.java

示例4: errrantThisOrExtension

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private void errrantThisOrExtension( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiModifierList )
  {
    PsiModifierList mods = (PsiModifierList)element;
    PsiAnnotation annotation;
    if( (annotation = mods.findAnnotation( Extension.class.getName() )) != null ||
        (annotation = mods.findAnnotation( This.class.getName() )) != null)
    {
      TextRange range = new TextRange( annotation.getTextRange().getStartOffset(),
                                       annotation.getTextRange().getEndOffset() );
      //noinspection ConstantConditions
      holder.createErrorAnnotation( range, ExtIssueMsg.MSG_NOT_IN_EXTENSION_CLASS.get( ClassUtil.extractClassName( annotation.getQualifiedName() ) ) );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:ExtensionClassAnnotator.java

示例5: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {

    if (element instanceof SmcStartMapNameElement) {
        SmcStartMapNameElement mapNameElement = (SmcStartMapNameElement) element;
        if (mapNameElement.getName() != null && SmcPsiUtil.findMap(element.getContainingFile(), mapNameElement.getName()).isEmpty()) {
            holder.createErrorAnnotation(element, getNoElementDeclarationFoundMessage(SmcTypes.MAP, mapNameElement.getName()));
        }
    }

    if (element instanceof SmcStartStateNameElement) {
        SmcStartStateNameElement stateNameElement = (SmcStartStateNameElement) element;
        SmcStartState start = (SmcStartState) element.getParent();
        String name = stateNameElement.getName();
        String mapName = start.getMapName();
        if (name != null &&
                SmcPsiUtil.getElementsByTypeAndNameWithinNamedType(element,
                        SmcMap.class,
                        mapName,
                        SmcState.class,
                        name).isEmpty()) {
            holder.createErrorAnnotation(element, getNoElementFoundInsideOtherElementMessage(SmcTypes.STATE,
                    name, SmcTypes.MAP, mapName));
        }
    }
}
 
开发者ID:menshele,项目名称:smcplugin,代码行数:27,代码来源:SmcStartStateAnnotator.java

示例6: checkKindTestArguments

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private static void checkKindTestArguments(AnnotationHolder holder,
                                           XPathNodeTypeTest test,
                                           boolean wildcardAllowed,
                                           int min,
                                           int max) {
  final XPathExpression[] arguments = test.getArgumentList();
  if (arguments.length >= min) {
    for (XPathExpression arg : arguments) {
      final PrefixedName argument = findQName(arg);
      if (argument == null) {
        holder.createErrorAnnotation(arg, "QName expected");
      } else {
        if (!wildcardAllowed && ("*".equals(argument.getPrefix()) || "*".equals(argument.getLocalName()))) {
          holder.createErrorAnnotation(arg, "QName expected");
        }
      }
    }
  } else {
    holder.createErrorAnnotation(test, "Missing argument for node kind test");
  }

  markExceedingArguments(holder, arguments, max);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:XPathAnnotator.java

示例7: addMessagesForTreeChild

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private static void addMessagesForTreeChild(final XmlToken childByRole,
                                            final Validator.ValidationHost.ErrorType type,
                                            final String message,
                                            AnnotationHolder myHolder, IntentionAction... actions) {
  if (childByRole != null) {
    Annotation annotation;
    if (type == Validator.ValidationHost.ErrorType.ERROR) {
      annotation = myHolder.createErrorAnnotation(childByRole, message);
    }
    else {
      annotation = myHolder.createWarningAnnotation(childByRole, message);
    }

    appendFixes(annotation, actions);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XMLExternalAnnotator.java

示例8: createErrorAnnotations

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private void createErrorAnnotations(PsiElement element, PsiFile file, AnnotationHolder holder, List<RuntimeException> annotationResult) {
    Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    if (document == null) {
        return;
    }
    PsiElement psiElementWithError = element;
    for (RuntimeException exception : annotationResult) {
        if (exception instanceof LocatedRuntimeException) {
            LocatedRuntimeException locatedException = (LocatedRuntimeException) exception;
            PsiElement childAtLine = file.findElementAt(document.getLineStartOffset(locatedException.getLineNumber() - 1));
            if (childAtLine != null) {
                psiElementWithError = childAtLine;
            }
        }
        holder.createErrorAnnotation(psiElementWithError, exception.getMessage());
    }
}
 
开发者ID:CloudSlang,项目名称:cs-intellij-plugin,代码行数:18,代码来源:ExecutableAnnotator.java

示例9: checkApplicability

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
  final String qname = annotation.getQualifiedName();
  if (!GroovyCommonClassNames.GROOVY_TRANSFORM_FIELD.equals(qname)) return false;

  checkScriptField(holder, annotation);

  PsiElement annoParent = annotation.getParent();
  PsiElement ownerToUse = annoParent instanceof PsiModifierList ? annoParent.getParent() : annoParent;
  if (!(ownerToUse instanceof GrVariableDeclaration) ||
      !PsiUtil.isLocalVariable(((GrVariableDeclaration)ownerToUse).getVariables()[0])) {
    return false;
  }

  if (!GrAnnotationImpl.isAnnotationApplicableTo(annotation, PsiAnnotation.TargetType.LOCAL_VARIABLE)) {
    GrCodeReferenceElement ref = annotation.getClassReference();
    String target = JavaErrorMessages.message("annotation.target.LOCAL_VARIABLE");
    String description = JavaErrorMessages.message("annotation.not.applicable", ref.getText(), target);
    holder.createErrorAnnotation(ref, description);
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FieldAnnotationChecker.java

示例10: annotateTranslation

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private void annotateTranslation(PsiElement psiElement, AnnotationHolder annotationHolder, String value) {
    if (TranslationUtil.keyExists(psiElement.getProject(), value)) {
        annotationHolder.createInfoAnnotation(psiElement, null);
    } else {
        annotationHolder.createErrorAnnotation(psiElement, "Unresolved translation - this may occur if you defined the translation key only in TypoScript");
    }
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:8,代码来源:TranslationAnnotator.java

示例11: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof SoyAnyStringLiteral
      && psiElement.getParent() instanceof SoyExpr
      && psiElement.getText().startsWith("\"")) {
    annotationHolder.createErrorAnnotation(
        psiElement, "Strings in expressions must use single quotes.");
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:10,代码来源:DoubleQuotedStringAnnotator.java

示例12: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(PsiElement element, AnnotationHolder holder) {
  if (element instanceof SoyXidStatement) {
    if (((SoyXidStatement) element).getCssXidIdentifier().getText().startsWith("%")) {
      holder.createErrorAnnotation(element, "Xid identifiers cannot start with '%'.");
    }
  }
  if (element instanceof SoyCssStatement) {
    if (((SoyCssStatement) element).getCssXidIdentifier().getText().contains(".")) {
      holder.createErrorAnnotation(element, "CSS identifiers cannot contain '.'.");
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:14,代码来源:IdentifierSanityAnnotator.java

示例13: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof TagBlockElement) {
    TagBlockElement block = (TagBlockElement) psiElement;
    if (block.isIncomplete() && !(block instanceof ChoiceClauseElement)) {
      annotationHolder.createErrorAnnotation(block.getOpeningTag(),
          "{" + block.getTagName() + "} is not closed.");
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:11,代码来源:IncompleteBlockAnnotator.java

示例14: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof CallStatementElement) {
    CallStatementElement statement = (CallStatementElement) psiElement;

    Collection<String> givenParameters = ParamUtils.getGivenParameters(statement);

    // TODO(thso): Detect data="" in more robust way.
    if (statement.getText().contains("data=")) return;

    PsiElement identifier =
        PsiTreeUtil.findChildOfType(statement, SoyTemplateReferenceIdentifier.class);

    if (identifier == null) return;

    List<String> requiredParameters =
        ParamUtils.getParametersForInvocation(statement, identifier.getText())
            .stream()
            .filter((var) -> !var.isOptional)
            .map((var) -> var.name)
            .collect(Collectors.toList());

    if (!givenParameters.containsAll(requiredParameters)) {
      requiredParameters.removeAll(givenParameters);
      annotationHolder.createErrorAnnotation(
          identifier, "Missing required parameters: " + String.join(",", requiredParameters));
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:30,代码来源:MissingParametersAnnotator.java

示例15: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof SoyVariableReferenceIdentifier && psiElement.getText().equals("$")) {
    annotationHolder.createErrorAnnotation(psiElement, "Variable name expected.");
  } else if (psiElement instanceof SoyFieldExpr && psiElement.getText().endsWith(".")) {
    annotationHolder.createErrorAnnotation(psiElement, "Field name expected.");
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:9,代码来源:UnfinishedIdentifiersAnnotator.java


注:本文中的com.intellij.lang.annotation.AnnotationHolder.createErrorAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。