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


Java InspectionManager.createProblemDescriptor方法代码示例

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


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

示例1: createProblemDescriptorWithQuickFixes

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
private void createProblemDescriptorWithQuickFixes(PsiModifierListOwner owner,
                                                   InspectionManager manager,
                                                   Collection<ProblemDescriptor> problemDescriptors,
                                                   PsiElement element) {
    if (element.isPhysical()) {
        LocalQuickFix[] localQuickFixes = createQuickFixes(owner, isRemoveRedundantAnnotations());
        ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
                element,
                MISSING_NULLABLE_NONNULL_ANNOTATION,
                localQuickFixes,
                GENERIC_ERROR_OR_WARNING,
                true,
                false);
        problemDescriptors.add(problemDescriptor);
    }
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:17,代码来源:NullabilityAnnotationsInspection.java

示例2: checkFile

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  List<ProblemDescriptor> problems = Lists.newArrayList();
  if (file.getFileType().equals(BuildoutCfgFileType.INSTANCE)) {
    Visitor visitor = new Visitor();
    file.accept(visitor);

    for (BuildoutPartReference ref : visitor.getUnresolvedParts()) {
      ProblemDescriptor d = manager
        .createProblemDescriptor(ref.getElement(), ref.getRangeInElement(), PyBundle.message("buildout.unresolved.part.inspection.msg"),
                                 ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
      problems.add(d);
    }
  }
  return problems.toArray(new ProblemDescriptor[problems.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BuildoutUnresolvedPartInspection.java

示例3: checkNewExpression

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Nullable
private static ProblemDescriptor checkNewExpression(PsiNewExpression expression, InspectionManager manager, boolean isOnTheFly) {
  final Project project = manager.getProject();
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
  final PsiClass jbColorClass = facade.findClass(JBColor.class.getName(), GlobalSearchScope.allScope(project));
  final PsiType type = expression.getType();
  if (type != null && jbColorClass != null) {
    if (!facade.getResolveHelper().isAccessible(jbColorClass, expression, jbColorClass)) return null;
    final PsiExpressionList arguments = expression.getArgumentList();
    if (arguments != null) {
      if ("java.awt.Color".equals(type.getCanonicalText())) {
        final PsiElement parent = expression.getParent();
        if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiNewExpression) {
          final PsiType parentType = ((PsiNewExpression)parent.getParent()).getType();
          if (parentType == null || JBColor.class.getName().equals(parentType.getCanonicalText())) return null;
        }
          return manager.createProblemDescriptor(expression, "Replace with JBColor", new ConvertToJBColorQuickFix(),
                                                 ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:UseJBColorInspection.java

示例4: checkClass

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
  final Project project = psiClass.getProject();
  final PsiIdentifier nameIdentifier = psiClass.getNameIdentifier();
  final Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);

  if (nameIdentifier == null || module == null || !PsiUtil.isInstantiable(psiClass)) return null;

  final PsiClass base = JavaPsiFacade.getInstance(project).findClass(INSPECTION_PROFILE_ENTRY, GlobalSearchScope.allScope(project));
  if (base == null || !psiClass.isInheritor(base, true) || isPathMethodsAreOverridden(psiClass)) return null;

  final InspectionDescriptionInfo info = InspectionDescriptionInfo.create(module, psiClass);
  if (!info.isValid() || info.hasDescriptionFile()) return null;

  final PsiElement problemElement = getProblemElement(psiClass, info.getShortNameMethod());
  final ProblemDescriptor problemDescriptor = manager
    .createProblemDescriptor(problemElement == null ? nameIdentifier : problemElement,
                             "Inspection does not have a description", isOnTheFly,
                             new LocalQuickFix[]{new CreateHtmlDescriptionFix(info.getFilename(), module, DescriptionType.INSPECTION)},
                             ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
  return new ProblemDescriptor[]{problemDescriptor};
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:InspectionDescriptionNotFoundInspection.java

示例5: checkClass

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass,
                                       @NotNull InspectionManager manager,
                                       boolean isOnTheFly )
{
    PsiAnnotation mixinsAnnotation = getMixinsAnnotation( psiClass );
    if( mixinsAnnotation == null )
    {
        return null;
    }

    if( psiClass.isInterface() )
    {
        return null;
    }

    String message = message( "mixins.annotation.declared.on.mixin.type.error.declared.on.class" );
    RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix( mixinsAnnotation );
    ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( mixinsAnnotation, message, fix,
                                                                           GENERIC_ERROR_OR_WARNING );
    return new ProblemDescriptor[]{ problemDescriptor };

}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:MixinsAnnotationDeclaredOnMixinType.java

示例6: verifyAnnotationDeclaredCorrectly

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Nullable
protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable,
                                                                       @NotNull PsiAnnotation structureAnnotation,
                                                                       @NotNull InspectionManager manager )
{
    StructureAnnotationDeclarationValidationResult annotationCheck =
        validateStructureAnnotationDeclaration( psiVariable );
    switch( annotationCheck )
    {
    case invalidInjectionType:
        String message = message(
            "injections.structure.annotation.declared.correctly.error.invalid.injection.type",
            psiVariable.getType().getCanonicalText()
        );
        AbstractFix removeStructureAnnotationFix = createRemoveAnnotationFix( structureAnnotation );
        ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
            structureAnnotation, message, removeStructureAnnotationFix, GENERIC_ERROR_OR_WARNING
        );
        return new ProblemDescriptor[]{ problemDescriptor };
    }

    return null;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:StructureAnnotationDeclaredCorrectlyInspection.java

示例7: checkFile

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  if (PantsUtil.isBUILDFileName(file.getName()) && !PantsUtil.isPythonAvailable() && PantsUtil.isPantsProject(file.getProject())) {
    LocalQuickFix[] fixes = new LocalQuickFix[]{new AddPythonPluginQuickFix()};
    ProblemDescriptor descriptor = manager.createProblemDescriptor(
      file.getNavigationElement(),
      PantsBundle.message("pants.info.python.plugin.missing"),
      isOnTheFly,
      fixes,
      ProblemHighlightType.GENERIC_ERROR_OR_WARNING
    );
    return new ProblemDescriptor[]{descriptor};
  }
  return null;
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:17,代码来源:PythonPluginInspection.java

示例8: checkFile

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  if (PantsUtil.isBUILDFileName(file.getName()) && PantsUtil.isPythonAvailable() && PantsUtil.isPantsProject(file.getProject())) {
    if (file.getFileType() != PythonFileType.INSTANCE) {
      LocalQuickFix[] fixes = new LocalQuickFix[]{new TypeAssociationFix()};
      ProblemDescriptor descriptor = manager.createProblemDescriptor(
        file.getNavigationElement(),
        PantsBundle.message("pants.info.mistreated.build.file"),
        isOnTheFly,
        fixes,
        ProblemHighlightType.GENERIC_ERROR_OR_WARNING
      );
      return new ProblemDescriptor[]{descriptor};
    }
  }
  return null;
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:19,代码来源:BuildFileTypeInspection.java

示例9: checkFile

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
    if (!(file instanceof XQueryFile)) {
        return null;
    }

    XQueryVersionDecl versionDecl = PsiTreeUtil.findChildOfType(file, XQueryVersionDecl.class);
    XQueryVersion version = versionDecl != null ? versionDecl.getVersion() : null;
    if (version != null) {
        String versionString = version.getVersionString();
        XQueryLanguageVersion languageVersion = XQueryLanguageVersion.valueFor(versionString);
        if (languageVersion == null) {
            ProblemDescriptor problem = manager.createProblemDescriptor(versionDecl.getVersion(), getDescription(versionString), (LocalQuickFix) null,
                    WEAK_WARNING, true);
            return new ProblemDescriptor[]{problem};
        }
    }

    return null;
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:21,代码来源:InvalidVersionInspection.java

示例10: checkFile

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public ProblemDescriptor[] checkFile(PsiFile file, InspectionManager manager, boolean isOnTheFly) {
    if (!(file instanceof XQueryFile)) {
        return null;
    }

    final XQueryModuleDecl moduleDeclaration = ((XQueryFile) file).getModuleDeclaration();

    if (moduleDeclaration != null && moduleDeclaration.getNamespacePrefix() != null
            && moduleDeclaration.getURILiteral() != null
            && !namespacePrefixIsDerivedFromFileName(moduleDeclaration)) {
        ProblemDescriptor[] problemDescriptors = new ProblemDescriptor[1];
        problemDescriptors[0] = manager.createProblemDescriptor(moduleDeclaration.getNamespacePrefix(), "Namespace prefix should be derived from file name part in URI", (LocalQuickFix) null,
                GENERIC_ERROR_OR_WARNING, true);

        return problemDescriptors;
    } else {
        return null;
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:21,代码来源:NamespacePrefixFromFileName.java

示例11: checkFileHeader

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
static ProblemDescriptor checkFileHeader(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean onTheFly)
{
	TIntObjectHashMap<String> offsetToProperty = new TIntObjectHashMap<>();
	FileTemplate defaultTemplate = FileTemplateManager.getInstance(file.getProject()).getDefaultTemplate(JavaTemplateUtil.FILE_HEADER_TEMPLATE_NAME);
	Pattern pattern = FileTemplateUtil.getTemplatePattern(defaultTemplate, file.getProject(), offsetToProperty);
	Matcher matcher = pattern.matcher(file.getViewProvider().getContents());
	if(!matcher.matches())
	{
		return null;
	}

	PsiComment element = PsiTreeUtil.findElementOfClassAtRange(file, matcher.start(1), matcher.end(1), PsiComment.class);
	if(element == null)
	{
		return null;
	}

	LocalQuickFix[] fixes = createQuickFix(matcher, offsetToProperty, file.getProject(), onTheFly);
	String description = InspectionsBundle.message("default.file.template.description");
	return manager.createProblemDescriptor(element, description, onTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:FileHeaderChecker.java

示例12: checkElement

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefModule)) {
    return null;
  }
  final List<RefEntity> children = refEntity.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
  }
  if (numClasses <= limit) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "module.with.too.many.classes.problem.descriptor",
    refEntity.getName(), Integer.valueOf(numClasses),
    Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ModuleWithTooManyClassesInspection.java

示例13: checkElement

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, @NotNull InspectionManager inspectionManager,
                                              @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefModule)) {
    return null;
  }
  final RefModule refModule = (RefModule)refEntity;
  final List<RefEntity> children = refModule.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
  }
  if (numClasses >= limit || numClasses == 0) {
    return null;
  }
  final Project project = globalInspectionContext.getProject();
  final Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length == 1) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message("module.with.too.few.classes.problem.descriptor",
                                                             refModule.getName(), Integer.valueOf(numClasses), Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ModuleWithTooFewClassesInspection.java

示例14: checkElement

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Nullable
@Override
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity,
                                              @NotNull AnalysisScope scope,
                                              @NotNull InspectionManager manager,
                                              @NotNull GlobalInspectionContext globalContext) {
  if (!(refEntity instanceof RefPackage)) {
    return null;
  }
  final RefPackage refPackage = (RefPackage)refEntity;
  final String packageName = refPackage.getQualifiedName();
  final Project project = globalContext.getProject();
  final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
  if (hasPackageInfoFile(aPackage)) {
    return null;
  }
  final List<RefEntity> children = refPackage.getChildren();
  boolean hasClasses = false;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      hasClasses = true;
      break;
    }
  }
  if (!hasClasses) {
    return null;
  }
  if (PsiUtil.isLanguageLevel5OrHigher(aPackage)) {
    return new CommonProblemDescriptor[] {
      manager.createProblemDescriptor(InspectionGadgetsBundle.message("missing.package.info.problem.descriptor", packageName))};
  }
  else {
    return new CommonProblemDescriptor[] {
      manager.createProblemDescriptor(InspectionGadgetsBundle.message("missing.package.html.problem.descriptor", packageName))};
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:MissingPackageInfoInspectionBase.java

示例15: checkElement

import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefPackage)) {
    return null;
  }
  final List<RefEntity> children = refEntity.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
  }
  if (numClasses <= limit) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "package.with.too.many.classes.problem.descriptor",
    refEntity.getQualifiedName(), Integer.valueOf(numClasses),
    Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PackageWithTooManyClassesInspection.java


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