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


Java SuppressionUtil类代码示例

本文整理汇总了Java中com.intellij.codeInspection.SuppressionUtil的典型用法代码示例。如果您正苦于以下问题:Java SuppressionUtil类的具体用法?Java SuppressionUtil怎么用?Java SuppressionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: visitDocComment

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Override
public void visitDocComment(PsiDocComment comment) {
  super.visitDocComment(comment);
  final PsiDocTag[] tags = comment.getTags();
  for (PsiDocTag tag : tags) {
    if (Comparing.strEqual(tag.getName(), SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) {
      final PsiElement[] dataElements = tag.getDataElements();
      if (dataElements != null && dataElements.length > 0) {
        final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(comment, PsiModifierListOwner.class);
        if (listOwner != null) {
          final RefElementImpl element = (RefElementImpl)myRefManager.getReference(listOwner);
          if (element != null) {
            String suppression = "";
            for (PsiElement dataElement : dataElements) {
              suppression += "," + dataElement.getText();
            }
            element.addSuppression(suppression);
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RefJavaManagerImpl.java

示例2: processIdentifier

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Nullable
private HighlightInfo processIdentifier(@NotNull PsiIdentifier identifier, @NotNull ProgressIndicator progress, @NotNull GlobalUsageHelper helper) {
  if (SuppressionUtil.inspectionResultSuppressed(identifier, myUnusedSymbolInspection)) return null;
  PsiElement parent = identifier.getParent();

  if (parent instanceof PsiLocalVariable && myUnusedSymbolInspection.LOCAL_VARIABLE) {
    return processLocalVariable((PsiLocalVariable)parent, identifier, progress);
  }
  if (parent instanceof PsiField && myUnusedSymbolInspection.FIELD) {
    return processField(myProject, (PsiField)parent, identifier, progress, helper);
  }
  if (parent instanceof PsiParameter && myUnusedSymbolInspection.PARAMETER) {
    if (SuppressionUtil.isSuppressed(identifier, UnusedSymbolLocalInspectionBase.UNUSED_PARAMETERS_SHORT_NAME)) return null;
    return processParameter(myProject, (PsiParameter)parent, identifier, progress);
  }
  if (parent instanceof PsiMethod && myUnusedSymbolInspection.METHOD) {
    return processMethod(myProject, (PsiMethod)parent, identifier, progress, helper);
  }
  if (parent instanceof PsiClass && myUnusedSymbolInspection.CLASS) {
    return processClass(myProject, (PsiClass)parent, identifier, progress, helper);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PostHighlightingVisitor.java

示例3: getTokenizer

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@NotNull
@Override
public Tokenizer getTokenizer(PsiElement element) {
    if (element instanceof PsiWhiteSpace) {
        return EMPTY_TOKENIZER;
    }
    if (element instanceof PsiNameIdentifierOwner) {
        return new PsiIdentifierOwnerTokenizer();
    }
    if (element.getParent() instanceof PsiNameIdentifierOwner) {
        return EMPTY_TOKENIZER;
    }
    if (element.getNode().getElementType() == JSGraphQLEndpointTokenTypes.IDENTIFIER) {
        return IDENTIFIER_TOKENIZER;
    }
    if (element instanceof PsiComment) {
        if (SuppressionUtil.isSuppressionComment(element)) {
            return EMPTY_TOKENIZER;
        }
        return myCommentTokenizer;
    }
    return EMPTY_TOKENIZER;
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:24,代码来源:JSGraphQLEndpointSpellcheckingStrategy.java

示例4: removeFromComment

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
private void removeFromComment(final PsiComment comment, final boolean checkLine) throws IncorrectOperationException {
  if (checkLine) {
    final PsiStatement statement = PsiTreeUtil.getNextSiblingOfType(comment, PsiStatement.class);
    if (statement != null && !Comparing.strEqual(statement.getText(), myProblemLine)) return;
  }
  String newText = removeFromElementText(comment);
  if (newText != null) {
    if (newText.length() == 0) {
      comment.delete();
    }
    else {
      PsiComment newComment = JavaPsiFacade.getInstance(comment.getProject()).getElementFactory()
        .createCommentFromText("// " + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME+" "+newText, comment);
      comment.replace(newComment);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:RemoveSuppressWarningAction.java

示例5: invoke

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull final PsiElement element) throws IncorrectOperationException {
  final PsiDocCommentOwner container = getContainer(element);
  LOG.assertTrue(container != null);
  if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
  if (use15Suppressions(container)) {
    final PsiModifierList modifierList = container.getModifierList();
    if (modifierList != null) {
      final PsiAnnotation annotation = modifierList.findAnnotation(JavaSuppressionUtil.SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
      if (annotation != null) {
        annotation.replace(JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText("@" +
                                                                                                           JavaSuppressionUtil.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" +
                                                                                                           SuppressionUtil.ALL + "\")", container));
        return;
      }
    }
  }
  else {
    PsiDocComment docComment = container.getDocComment();
    if (docComment != null) {
      PsiDocTag noInspectionTag = docComment.findTagByName(SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME);
      if (noInspectionTag != null) {
        String tagText = "@" + SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME + " " + SuppressionUtil.ALL;
        noInspectionTag.replace(JavaPsiFacade.getInstance(project).getElementFactory().createDocTagFromText(tagText));
        // todo suppress
        //DaemonCodeAnalyzer.getInstance(project).restart();
        return;
      }
    }
  }

  super.invoke(project, element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SuppressAllForClassFix.java

示例6: getTokenizer

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@NotNull
public Tokenizer getTokenizer(PsiElement element) {
  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
    return EMPTY_TOKENIZER;
  }
  if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer();
  if (element instanceof PsiComment) {
    if (SuppressionUtil.isSuppressionComment(element)) {
      return EMPTY_TOKENIZER;
    }
    return myCommentTokenizer;
  }
  if (element instanceof XmlAttributeValue) return myXmlAttributeTokenizer;
  if (element instanceof XmlText) return myXmlTextTokenizer;
  if (element instanceof PsiPlainText) {
    PsiFile file = element.getContainingFile();
    FileType fileType = file == null ? null : file.getFileType();
    if (fileType instanceof CustomSyntaxTableFileType) {
      return new CustomFileTypeTokenizer(((CustomSyntaxTableFileType)fileType).getSyntaxTable());
    }
    return TEXT_TOKENIZER;
  }
  if (element instanceof XmlToken) {
    if (((XmlToken)element).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      PsiElement injection = InjectedLanguageManager.getInstance(element.getProject()).findInjectedElementAt(element.getContainingFile(), element.getTextOffset());
      if (injection == null) {
        return TEXT_TOKENIZER;
      }
    }

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

示例7: isSuppressed

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
public boolean isSuppressed(@NotNull String... toolId) {
  if (mySuppressions != null) {
    for (@NonNls String suppression : mySuppressions) {
      for (String id : toolId) {
        if (suppression.equals(id)) return true;
      }
      if (suppression.equalsIgnoreCase(SuppressionUtil.ALL)){
        return true;
      }
    }
  }
  final RefEntity entity = getOwner();
  return entity instanceof RefElementImpl && ((RefElementImpl)entity).isSuppressed(toolId);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:RefElementImpl.java

示例8: invoke

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @Nullable Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
  PsiElement container = getContainer(element);
  if (container == null) return;

  if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;

  final List<? extends PsiElement> comments = getCommentsFor(container);
  if (comments != null) {
    for (PsiElement comment : comments) {
      if (comment instanceof PsiComment && SuppressionUtil.isSuppressionComment(comment)) {
        replaceSuppressionComment(comment);
        return;
      }
    }
  }

  boolean caretWasBeforeStatement = editor != null && editor.getCaretModel().getOffset() == container.getTextRange().getStartOffset();
  try {
    createSuppression(project, element, container);
  }
  catch (IncorrectOperationException e) {
    if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) {
      Messages.showErrorDialog(editor.getComponent(),
                               InspectionsBundle.message("suppress.inspection.annotation.syntax.error", e.getMessage()));
    }
  }

  if (caretWasBeforeStatement) {
    editor.getCaretModel().moveToOffset(container.getTextRange().getStartOffset());
  }
  UndoUtil.markPsiFileForUndo(element.getContainingFile());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:AbstractSuppressByNoInspectionCommentFix.java

示例9: invoke

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull final PsiElement element) throws IncorrectOperationException {
  final PsiDocCommentOwner container = getContainer(element);
  LOG.assertTrue(container != null);
  if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
  if (use15Suppressions(container)) {
    final PsiModifierList modifierList = container.getModifierList();
    if (modifierList != null) {
      final PsiAnnotation annotation = modifierList.findAnnotation(JavaSuppressionUtil.SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
      if (annotation != null) {
        annotation.replace(JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText("@" +
                                                                                                           JavaSuppressionUtil.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" +
                                                                                                           SuppressionUtil.ALL + "\")", container));
        return;
      }
    }
  }
  else {
    PsiDocComment docComment = container.getDocComment();
    if (docComment != null) {
      PsiDocTag noInspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
      if (noInspectionTag != null) {
        String tagText = "@" + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + SuppressionUtil.ALL;
        noInspectionTag.replace(JavaPsiFacade.getInstance(project).getElementFactory().createDocTagFromText(tagText));
        // todo suppress
        //DaemonCodeAnalyzer.getInstance(project).restart();
        return;
      }
    }
  }

  super.invoke(project, element);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:SuppressAllForClassFix.java

示例10: JavadocManagerImpl

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
public JavadocManagerImpl(Project project) {
  myInfos = new ArrayList<JavadocTagInfo>();

  myInfos.add(new SimpleDocTagInfo("author", PsiClass.class, false, LanguageLevel.JDK_1_3));
  myInfos.add(new SimpleDocTagInfo("deprecated", PsiElement.class, false, LanguageLevel.JDK_1_3));
  myInfos.add(new SimpleDocTagInfo("serialData", PsiMethod.class, false, LanguageLevel.JDK_1_3));
  myInfos.add(new SimpleDocTagInfo("serialField", PsiField.class, false, LanguageLevel.JDK_1_3));
  myInfos.add(new SimpleDocTagInfo("since", PsiElement.class, false, LanguageLevel.JDK_1_3));
  myInfos.add(new SimpleDocTagInfo("version", PsiClass.class, false, LanguageLevel.JDK_1_3));

  myInfos.add(new SimpleDocTagInfo("docRoot", PsiElement.class, true, LanguageLevel.JDK_1_3));
  myInfos.add(new SimpleDocTagInfo("inheritDoc", PsiElement.class, true, LanguageLevel.JDK_1_4));
  myInfos.add(new SimpleDocTagInfo("literal", PsiElement.class, true, LanguageLevel.JDK_1_5));
  myInfos.add(new SimpleDocTagInfo("code", PsiElement.class, true, LanguageLevel.JDK_1_5));

  //Not a standard tag, but added by IDEA for inspection suppression
  myInfos.add(new SimpleDocTagInfo(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME, PsiElement.class, false, LanguageLevel.JDK_1_3));

  myInfos.add(new ParamDocTagInfo());
  myInfos.add(new ReturnDocTagInfo());
  myInfos.add(new SerialDocTagInfo());
  myInfos.add(new SeeDocTagInfo("see", false));
  myInfos.add(new SeeDocTagInfo("link", true));
  myInfos.add(new SeeDocTagInfo("linkplain", true));
  myInfos.add(new ExceptionTagInfo("exception"));
  myInfos.add(new ExceptionTagInfo("throws"));
  myInfos.add(new ValueDocTagInfo());
  Collections.addAll(myInfos, Extensions.getExtensions(JavadocTagInfo.EP_NAME, project));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:JavadocManagerImpl.java

示例11: getTokenizer

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@NotNull
public Tokenizer getTokenizer(PsiElement element) {
  if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer();
  if (element instanceof PsiComment) {
    if (SuppressionUtil.isSuppressionComment(element)) {
      return EMPTY_TOKENIZER;
    }
    return myCommentTokenizer;
  }
  if (element instanceof XmlAttributeValue) return myXmlAttributeTokenizer;
  if (element instanceof XmlText) return myXmlTextTokenizer;
  if (element instanceof PsiPlainText) return TEXT_TOKENIZER;
  return EMPTY_TOKENIZER;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:SpellcheckingStrategy.java

示例12: isSuppressed

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
public boolean isSuppressed(final String... toolId) {
  if (mySuppressions != null) {
    for (@NonNls String suppression : mySuppressions) {
      for (String id : toolId) {
        if (suppression.equals(id)) return true;
      }
      if (suppression.equalsIgnoreCase(SuppressionUtil.ALL)){
        return true;
      }
    }
  }
  final RefEntity entity = getOwner();
  return entity instanceof RefElementImpl && ((RefElementImpl)entity).isSuppressed(toolId);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:RefElementImpl.java

示例13: replaceSuppressionComments

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
protected boolean replaceSuppressionComments(PsiElement container) {
  final List<? extends PsiElement> comments = getCommentsFor(container);
  if (comments != null) {
    for (PsiElement comment : comments) {
      if (comment instanceof PsiComment && SuppressionUtil.isSuppressionComment(comment)) {
        replaceSuppressionComment(comment);
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:AbstractBatchSuppressByNoInspectionCommentFix.java

示例14: getChangeHighlightingDirtyScopeFor

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Override
public PsiElement getChangeHighlightingDirtyScopeFor(@NotNull PsiElement changedElement) {
  if (changedElement instanceof PsiWhiteSpace ||
      changedElement instanceof PsiComment
      && !changedElement.getText().contains(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) {
    return changedElement;
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:DefaultChangeLocalityDetector.java

示例15: visitComment

import com.intellij.codeInspection.SuppressionUtil; //导入依赖的package包/类
@Override
public void visitComment(PsiComment comment) {
  super.visitComment(comment);
  final String commentText = comment.getText();
  final IElementType tokenType = comment.getTokenType();
  if (!tokenType.equals(JavaTokenType.END_OF_LINE_COMMENT)
      && !tokenType.equals(JavaTokenType.C_STYLE_COMMENT)) {
    return;
  }
  @NonNls final String strippedComment = commentText.substring(2).trim();
  if (strippedComment.startsWith(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) {
    registerError(comment);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:SuppressionAnnotationInspection.java


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