本文整理汇总了Java中com.intellij.codeInspection.InspectionManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java InspectionManager.getInstance方法的具体用法?Java InspectionManager.getInstance怎么用?Java InspectionManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInspection.InspectionManager
的用法示例。
在下文中一共展示了InspectionManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showOfflineView
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@NotNull
public static InspectionResultsView showOfflineView(@NotNull Project project,
@NotNull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
@NotNull InspectionProfile inspectionProfile,
@NotNull String title) {
final AnalysisScope scope = new AnalysisScope(project);
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
context.setExternalProfile(inspectionProfile);
context.setCurrentScope(scope);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context,
new OfflineInspectionRVContentProvider(resMap, project));
((RefManagerImpl)context.getRefManager()).startOfflineView();
view.update();
TreeUtil.selectFirstNode(view.getTree());
context.addView(view, title);
return view;
}
示例2: showOfflineView
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@NotNull
public static InspectionResultsView showOfflineView(@NotNull Project project,
@NotNull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
final InspectionProfile inspectionProfile,
final String title) {
final AnalysisScope scope = new AnalysisScope(project);
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
context.setExternalProfile(inspectionProfile);
context.setCurrentScope(scope);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context,
new OfflineInspectionRVContentProvider(resMap, project));
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
view.update();
TreeUtil.selectFirstNode(view.getTree());
if (context.getContentManager() != null) { //test
context.addView(view, title);
}
return view;
}
示例3: run
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的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);
}
}
}
示例4: showOfflineView
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Nonnull
public static InspectionResultsView showOfflineView(@Nonnull Project project,
@Nonnull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
@Nonnull InspectionProfile inspectionProfile,
@Nonnull String title) {
final AnalysisScope scope = new AnalysisScope(project);
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
context.setExternalProfile(inspectionProfile);
context.setCurrentScope(scope);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context,
new OfflineInspectionRVContentProvider(resMap, project));
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
view.update();
TreeUtil.selectFirstNode(view.getTree());
context.addView(view, title);
return view;
}
示例5: runTool
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
protected GlobalInspectionContextImpl runTool(final String testDir,
final String jdkName,
boolean runDeadCodeFirst,
@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionToolWrapper... additional) {
final VirtualFile[] sourceDir = new VirtualFile[1];
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
setupRootModel(testDir, sourceDir, jdkName);
}
catch (Exception e) {
LOG.error(e);
}
}
});
AnalysisScope scope = createAnalysisScope(sourceDir[0].getParent());
InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
InspectionToolWrapper[] toolWrappers = runDeadCodeFirst ? new InspectionToolWrapper []{getUnusedDeclarationWrapper(), toolWrapper} : new InspectionToolWrapper []{toolWrapper};
toolWrappers = ArrayUtil.mergeArrays(toolWrappers, additional);
final GlobalInspectionContextForTests globalContext =
CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, toolWrappers);
InspectionTestUtil.runTool(toolWrapper, scope, globalContext);
return globalContext;
}
示例6: performPostRunActivities
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public void performPostRunActivities(@NotNull List<InspectionToolWrapper> needRepeatSearchRequest, @NotNull final GlobalInspectionContext context) {
JobDescriptor progress = context.getStdJobDescriptors().FIND_EXTERNAL_USAGES;
progress.setTotalAmount(getRequestCount());
do {
processSearchRequests(context);
InspectionToolWrapper[] requestors = needRepeatSearchRequest.toArray(new InspectionToolWrapper[needRepeatSearchRequest.size()]);
InspectionManager inspectionManager = InspectionManager.getInstance(context.getProject());
for (InspectionToolWrapper toolWrapper : requestors) {
boolean result = false;
if (toolWrapper instanceof GlobalInspectionToolWrapper) {
InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)context).getPresentation(toolWrapper);
result = ((GlobalInspectionToolWrapper)toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager, context, presentation);
}
if (!result) {
needRepeatSearchRequest.remove(toolWrapper);
}
}
int oldSearchRequestCount = progress.getTotalAmount();
int oldDoneAmount = progress.getDoneAmount();
int totalAmount = oldSearchRequestCount + getRequestCount();
progress.setTotalAmount(totalAmount);
progress.setDoneAmount(oldDoneAmount);
}
while (!needRepeatSearchRequest.isEmpty());
}
示例7: invoke
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
if (!FileModificationService.getInstance().preparePsiElementForWrite(file)) return;
final InspectionManager managerEx = InspectionManager.getInstance(project);
final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)managerEx.createNewGlobalContext(false);
final AnalysisScope scope = getScope(project, file);
if (scope != null) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
globalContext.codeCleanup(project, scope, profile, getText(), null, false);
}
}
示例8: testInspection
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public void testInspection(@NotNull String testDir, @NotNull InspectionToolWrapper toolWrapper) {
VirtualFile sourceDir = copyDirectoryToProject(new File(testDir, "src").getPath(), "src");
AnalysisScope scope = new AnalysisScope(getPsiManager().findDirectory(sourceDir));
scope.invalidate();
InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
GlobalInspectionContextForTests globalContext = createGlobalContextForTool(scope, getProject(), inspectionManager, toolWrapper);
InspectionTestUtil.runTool(toolWrapper, scope, globalContext);
InspectionTestUtil.compareToolResults(globalContext, toolWrapper, false, new File(getTestDataPath(), testDir).getPath());
}
示例9: refreshViews
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
private static void refreshViews(@NotNull Project project, @NotNull Set<PsiElement> selectedElements, @NotNull InspectionToolWrapper toolWrapper) {
InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final Set<GlobalInspectionContextImpl> runningContexts = managerEx.getRunningContexts();
for (GlobalInspectionContextImpl context : runningContexts) {
for (PsiElement element : selectedElements) {
context.ignoreElement(toolWrapper.getTool(), element);
}
context.refreshViews();
}
}
示例10: runInspections
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
protected void runInspections(Project project, AnalysisScope scope) {
final InspectionProfile profile = myExternalProfile != null ? myExternalProfile : InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
final InspectionManager managerEx = InspectionManager.getInstance(project);
final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)managerEx.createNewGlobalContext(false);
globalContext.codeCleanup(project, scope, profile, getTemplatePresentation().getText(), null, false);
}
示例11: analyze
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
protected static void analyze(Project project, PsiFile psiFile) {
FileDocumentManager.getInstance().saveAllDocuments();
final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final AnalysisScope scope = new AnalysisScope(psiFile);
final GlobalInspectionContextImpl inspectionContext = inspectionManagerEx.createNewGlobalContext(false);
inspectionContext.setCurrentScope(scope);
final InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
inspectionContext.setExternalProfile(inspectionProfile);
inspectionContext.doInspections(scope);
}
示例12: doGlobalInspectionTest
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
protected void doGlobalInspectionTest(@NotNull GlobalInspectionToolWrapper wrapper,
@NotNull String globalTestDir,
@NotNull AnalysisScope scope) {
myFixture.enableInspections(wrapper.getTool());
scope.invalidate();
final InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
final GlobalInspectionContextForTests globalContext =
CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper);
InspectionTestUtil.runTool(wrapper, scope, globalContext);
InspectionTestUtil.compareToolResults(globalContext, wrapper, false, getTestDataPath() + globalTestDir);
}
示例13: validateImportTarget
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
private void validateImportTarget(@Nullable StringLiteral target) {
if (target == null) {
return;
}
String targetString = target.getStringContents();
if (targetString == null
|| targetString.startsWith(":")
|| targetString.startsWith("//")
|| targetString.startsWith("@")
|| targetString.length() < 2) {
return;
}
if (targetString.startsWith("/")) {
Annotation annotation =
markWarning(
target, "Deprecated load syntax; loaded Skylark module should by in label format.");
InspectionManager inspectionManager = InspectionManager.getInstance(target.getProject());
ProblemDescriptor descriptor =
inspectionManager.createProblemDescriptor(
target,
annotation.getMessage(),
DeprecatedLoadQuickFix.INSTANCE,
ProblemHighlightType.LIKE_DEPRECATED,
true);
annotation.registerFix(DeprecatedLoadQuickFix.INSTANCE, null, null, descriptor);
return;
}
markError(target, "Invalid load syntax: missing Skylark module.");
}
示例14: runTool
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
protected GlobalInspectionContextImpl runTool(final String testDir,
final String jdkName,
boolean runDeadCodeFirst,
@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionToolWrapper... additional) {
final VirtualFile[] sourceDir = new VirtualFile[1];
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
setupRootModel(testDir, sourceDir, jdkName);
}
catch (Exception e) {
LOG.error(e);
}
}
});
AnalysisScope scope = createAnalysisScope(sourceDir[0].getParent());
InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
InspectionToolWrapper[] toolWrappers = runDeadCodeFirst ? new InspectionToolWrapper []{getUnusedDeclarationWrapper(), toolWrapper} : new InspectionToolWrapper []{toolWrapper};
toolWrappers = ArrayUtil.mergeArrays(toolWrappers, additional);
final GlobalInspectionContextImpl globalContext =
CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, toolWrappers);
InspectionTestUtil.runTool(toolWrapper, scope, globalContext, inspectionManager);
return globalContext;
}
示例15: invoke
import com.intellij.codeInspection.InspectionManager; //导入方法依赖的package包/类
@Override
public void invoke(@Nonnull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
if (!FileModificationService.getInstance().preparePsiElementForWrite(file)) return;
final InspectionManager managerEx = InspectionManager.getInstance(project);
final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)managerEx.createNewGlobalContext(false);
final AnalysisScope scope = getScope(project, file);
if (scope != null) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
globalContext.codeCleanup(project, scope, profile, getText(), null, false);
}
}