本文整理汇总了Java中com.intellij.codeInspection.ex.LocalInspectionToolWrapper类的典型用法代码示例。如果您正苦于以下问题:Java LocalInspectionToolWrapper类的具体用法?Java LocalInspectionToolWrapper怎么用?Java LocalInspectionToolWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalInspectionToolWrapper类属于com.intellij.codeInspection.ex包,在下文中一共展示了LocalInspectionToolWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureLocalInspectionTools
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
if ("RandomEditingForUnused".equals(getTestName(false))) {
return new LocalInspectionTool[]{new UnusedImportLocalInspection(),};
}
List<InspectionToolWrapper> all = InspectionToolRegistrar.getInstance().createTools();
List<LocalInspectionTool> locals = new ArrayList<>();
for (InspectionToolWrapper tool : all) {
if (tool instanceof LocalInspectionToolWrapper) {
LocalInspectionTool e = ((LocalInspectionToolWrapper)tool).getTool();
locals.add(e);
}
}
return locals.toArray(new LocalInspectionTool[locals.size()]);
}
示例2: init
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private static boolean init() {
// It's assumed that default spell checking inspection settings are just fine for processing all types of data.
// Please perform corresponding settings tuning if that assumption is broken at future.
Class<LocalInspectionTool>[] inspectionClasses = (Class<LocalInspectionTool>[])new Class<?>[] {SpellCheckingInspection.class};
for (Class<LocalInspectionTool> inspectionClass : inspectionClasses) {
try {
LocalInspectionTool tool = inspectionClass.newInstance();
SPELL_CHECK_TOOLS.put(tool.getShortName(), new LocalInspectionToolWrapper(tool));
}
catch (Throwable e) {
return false;
}
}
return true;
}
示例3: inspectEx
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@NotNull
public static Map<String, List<ProblemDescriptor>> inspectEx(@NotNull final List<LocalInspectionToolWrapper> toolWrappers,
@NotNull final PsiFile file,
@NotNull final InspectionManager iManager,
final boolean isOnTheFly,
boolean failFastOnAcquireReadAction,
@NotNull final ProgressIndicator indicator) {
if (toolWrappers.isEmpty()) return Collections.emptyMap();
final List<PsiElement> elements = new ArrayList<PsiElement>();
TextRange range = file.getTextRange();
Divider.divideInsideAndOutside(file, range.getStartOffset(), range.getEndOffset(), range, elements, new ArrayList<ProperTextRange>(),
Collections.<PsiElement>emptyList(), Collections.<ProperTextRange>emptyList(), true, Conditions.<PsiFile>alwaysTrue());
return inspectElements(toolWrappers, file, iManager, isOnTheFly, failFastOnAcquireReadAction, indicator, elements,
calcElementDialectIds(elements));
}
示例4: getDialectIdsSpecifiedForTool
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@Nullable("null means not specified")
private static Set<String> getDialectIdsSpecifiedForTool(@NotNull LocalInspectionToolWrapper wrapper) {
String langId = wrapper.getLanguage();
if (langId == null) {
return null;
}
Language language = Language.findLanguageByID(langId);
Set<String> result;
if (language != null) {
List<Language> dialects = language.getDialects();
boolean applyToDialects = wrapper.applyToDialects();
result = applyToDialects && !dialects.isEmpty() ? new THashSet<String>(1 + dialects.size()) : new SmartHashSet<String>();
result.add(langId);
if (applyToDialects) {
for (Language dialect : dialects) {
result.add(dialect.getID());
}
}
}
else {
// unknown language in plugin.xml, ignore
result = Collections.singleton(langId);
}
return result;
}
示例5: setUp
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
SSBasedInspection inspection = new SSBasedInspection();
List<Configuration> configurations = new ArrayList<Configuration>();
SearchConfiguration configuration = new SearchConfiguration();
MatchOptions options = new MatchOptions();
options.setFileType(StdFileTypes.JAVA);
options.setSearchPattern("int i;");
configuration.setMatchOptions(options);
configurations.add(configuration);
configuration = new SearchConfiguration();
options = new MatchOptions();
options.setFileType(StdFileTypes.JAVA);
options.setSearchPattern("f();");
configuration.setMatchOptions(options);
configurations.add(configuration);
inspection.setConfigurations(configurations, myProject);
myWrapper = new LocalInspectionToolWrapper(inspection);
}
示例6: testHighlightStatus_OtherInspections
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
public void testHighlightStatus_OtherInspections() throws Throwable {
myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager,
final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return new ProblemDescriptor[0];
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
HighlightDisplayKey.register(inspection.getShortName());
myInspectionProfile.setInspectionTools(new LocalInspectionToolWrapper(inspection));
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.ANNOTATORS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
myAnnotationsManager.appendProblems(myElement, createHolder(), inspection.getClass());
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
示例7: testHighlightStatus_OtherInspections2
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
public void testHighlightStatus_OtherInspections2() throws Throwable {
myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager,
final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return new ProblemDescriptor[0];
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
HighlightDisplayKey.register(inspection.getShortName());
LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspection);
myInspectionProfile.setInspectionTools(toolWrapper);
myInspectionProfile.setEnabled(toolWrapper, false);
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
示例8: testHighlightStatus_OtherInspections
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
public void testHighlightStatus_OtherInspections() throws Throwable {
myElement.setFileDescription(new DomFileDescription(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager,
final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return new ProblemDescriptor[0];
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
HighlightDisplayKey.register(inspection.getShortName());
myInspectionProfile.setInspectionTools(new LocalInspectionToolWrapper(inspection));
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.ANNOTATORS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
myAnnotationsManager.appendProblems(myElement, createHolder(), inspection.getClass());
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
示例9: testHighlightStatus_OtherInspections2
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
public void testHighlightStatus_OtherInspections2() throws Throwable {
myElement.setFileDescription(new DomFileDescription(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager,
final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return new ProblemDescriptor[0];
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
HighlightDisplayKey.register(inspection.getShortName());
LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspection);
myInspectionProfile.setInspectionTools(toolWrapper);
myInspectionProfile.setEnabled(toolWrapper, false);
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
示例10: run
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@Override
protected void run() {
InspectionManager inspectionManager = InspectionManager.getInstance(project);
GlobalInspectionContext context = inspectionManager.createNewGlobalContext(false);
InspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspectionTool);
List<ProblemDescriptor> problemDescriptors;
try {
problemDescriptors = InspectionEngine.runInspectionOnFile(psiFile, toolWrapper, context);
} catch (IndexNotReadyException exception) {
return;
}
for (ProblemDescriptor problemDescriptor : problemDescriptors) {
QuickFix[] fixes = problemDescriptor.getFixes();
if (fixes != null) {
writeQuickFixes(problemDescriptor, fixes);
}
}
}
示例11: inspectEx
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@Nonnull
public static Map<String, List<ProblemDescriptor>> inspectEx(@Nonnull final List<LocalInspectionToolWrapper> toolWrappers,
@Nonnull final PsiFile file,
@Nonnull final InspectionManager iManager,
final boolean isOnTheFly,
boolean failFastOnAcquireReadAction,
@Nonnull final ProgressIndicator indicator) {
if (toolWrappers.isEmpty()) return Collections.emptyMap();
TextRange range = file.getTextRange();
List<Divider.DividedElements> allDivided = new ArrayList<>();
Divider.divideInsideAndOutsideAllRoots(file, range, range, Conditions.alwaysTrue(), new CommonProcessors.CollectProcessor<>(allDivided));
List<PsiElement> elements = ContainerUtil.concat(
(List<List<PsiElement>>)ContainerUtil.map(allDivided, d -> ContainerUtil.concat(d.inside, d.outside, d.parents)));
return inspectElements(toolWrappers, file, iManager, isOnTheFly, failFastOnAcquireReadAction, indicator, elements,
calcElementDialectIds(elements));
}
示例12: getDialectIdsSpecifiedForTool
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@Nullable
public static Set<String> getDialectIdsSpecifiedForTool(@Nonnull LocalInspectionToolWrapper wrapper) {
String langId = wrapper.getLanguage();
if (langId == null) {
return null;
}
Language language = Language.findLanguageByID(langId);
Set<String> result;
if (language != null) {
result = new SmartHashSet<String>();
result.add(langId);
}
else {
// unknown language in plugin.xml, ignore
result = Collections.singleton(langId);
}
return result;
}
示例13: testSimpleInspection
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
public void testSimpleInspection() {
// force Camel enabled so the inspection test can run
CamelInspection inspection = new CamelInspection(true);
// must be called fooroute as inspectionsimplejava fails for some odd reason
doTest("testData/fooroute/", new LocalInspectionToolWrapper(inspection), "java 1.8");
}
示例14: testIgnore
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
public void testIgnore() throws Exception {
final RedundantCastInspection castInspection = new RedundantCastInspection();
castInspection.IGNORE_ANNOTATED_METHODS = true;
castInspection.IGNORE_SUSPICIOUS_METHOD_CALLS = true;
final LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(castInspection);
doTest("redundantCast/generics/" + getTestName(false), tool, "java 1.5");
}
示例15: inspect
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; //导入依赖的package包/类
@NotNull
public static List<ProblemDescriptor> inspect(@NotNull final List<LocalInspectionToolWrapper> toolWrappers,
@NotNull final PsiFile file,
@NotNull final InspectionManager iManager,
final boolean isOnTheFly,
boolean failFastOnAcquireReadAction,
@NotNull final ProgressIndicator indicator) {
final Map<String, List<ProblemDescriptor>> problemDescriptors = inspectEx(toolWrappers, file, iManager, isOnTheFly, failFastOnAcquireReadAction, indicator);
final List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>();
for (List<ProblemDescriptor> group : problemDescriptors.values()) {
result.addAll(group);
}
return result;
}