本文整理汇总了Java中com.intellij.profile.codeInspection.InspectionProjectProfileManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java InspectionProjectProfileManager.getInstance方法的具体用法?Java InspectionProjectProfileManager.getInstance怎么用?Java InspectionProjectProfileManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.profile.codeInspection.InspectionProjectProfileManager
的用法示例。
在下文中一共展示了InspectionProjectProfileManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
private static void doTest(final String dirName) throws Exception {
InspectionProfileImpl.INIT_INSPECTIONS = true;
try {
final String relativePath = "/inspection/converter/";
final File projectFile = new File(JavaTestUtil.getJavaTestDataPath() + relativePath + dirName + "/options.ipr");
for (Element element : JDOMUtil.loadDocument(projectFile).getRootElement().getChildren("component")) {
if (Comparing.strEqual(element.getAttributeValue("name"), "InspectionProjectProfileManager")) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(getProject());
profileManager.loadState(element);
Element configElement = profileManager.getState();
final File file = new File(JavaTestUtil.getJavaTestDataPath() + relativePath + dirName + "/options.after.xml");
PlatformTestUtil.assertElementsEqual(JDOMUtil.loadDocument(file).getRootElement(), configElement);
break;
}
}
}
finally {
InspectionProfileImpl.INIT_INSPECTIONS = false;
}
}
示例2: testPreserveCompatibility
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testPreserveCompatibility() throws Exception {
InspectionProfileImpl foo = new InspectionProfileImpl("foo", InspectionToolRegistrar.getInstance(), InspectionProjectProfileManager.getInstance(getProject()));
String test = "<profile version=\"1.0\" is_locked=\"false\">\n" +
" <option name=\"myName\" value=\"idea.default\" />\n" +
" <option name=\"myLocal\" value=\"false\" />\n" +
" <inspection_tool class=\"AbstractMethodCallInConstructor\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" />\n" +
" <inspection_tool class=\"AssignmentToForLoopParameter\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\">\n" +
" <option name=\"m_checkForeachParameters\" value=\"false\" />\n" +
" </inspection_tool>\n" +
"</profile>";
foo.readExternal(JDOMUtil.loadDocument(test).getRootElement());
foo.initInspectionTools(getProject());
Element serialized = new Element("profile");
foo.writeExternal(serialized);
assertEquals(test, JDOMUtil.writeElement(serialized));
}
示例3: testSettingsModification
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testSettingsModification() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model, profile);
panel.setVisible(true);
panel.reset();
JavaDocLocalInspection tool = getInspection(model);
assertEquals("", tool.myAdditionalJavadocTags);
tool.myAdditionalJavadocTags = "foo";
model.setModified(true);
panel.apply();
assertEquals(1, InspectionProfileTest.countInitializedTools(model));
assertEquals("foo", getInspection(profile).myAdditionalJavadocTags);
panel.disposeUI();
}
示例4: testModifyInstantiatedTool
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testModifyInstantiatedTool() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
JavaDocLocalInspection originalTool = getInspection(profile);
originalTool.myAdditionalJavadocTags = "foo";
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model, profile);
panel.setVisible(true);
panel.reset();
assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 1, InspectionProfileTest.countInitializedTools(model));
JavaDocLocalInspection copyTool = getInspection(model);
copyTool.myAdditionalJavadocTags = "bar";
model.setModified(true);
panel.apply();
assertEquals(1, InspectionProfileTest.countInitializedTools(model));
assertEquals("bar", getInspection(profile).myAdditionalJavadocTags);
panel.disposeUI();
}
示例5: testDoNotChangeSettingsOnCancel
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testDoNotChangeSettingsOnCancel() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
JavaDocLocalInspection originalTool = getInspection(profile);
assertEquals("", originalTool.myAdditionalJavadocTags);
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
JavaDocLocalInspection copyTool = getInspection(model);
copyTool.myAdditionalJavadocTags = "foo";
// this change IS NOT COMMITTED
assertEquals("", getInspection(profile).myAdditionalJavadocTags);
}
示例6: getCurrentProfile
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public InspectionProfile getCurrentProfile() {
if (myExternalProfile != null) return myExternalProfile;
InspectionManagerBase managerEx = (InspectionManagerBase)InspectionManager.getInstance(myProject);
String currentProfile = managerEx.getCurrentProfile();
final InspectionProjectProfileManager inspectionProfileManager = InspectionProjectProfileManager.getInstance(myProject);
Profile profile = inspectionProfileManager.getProfile(currentProfile, false);
if (profile == null) {
profile = InspectionProfileManager.getInstance().getProfile(currentProfile);
if (profile != null) return (InspectionProfile)profile;
final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames();
if (availableProfileNames.length == 0) {
//can't be
return null;
}
profile = inspectionProfileManager.getProfile(availableProfileNames[0]);
}
return (InspectionProfile)profile;
}
示例7: actionPerformed
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(myProject);
final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper();
InspectionProfile inspectionProfile = myInspectionProfile;
final boolean profileIsDefined = isProfileDefined();
if (!profileIsDefined) {
inspectionProfile = guessProfileToSelect(profileManager);
}
if (toolWrapper != null) {
final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); //do not search for dead code entry point tool
if (key != null){
if (new EditInspectionToolsSettingsAction(key).editToolSettings(myProject, (InspectionProfileImpl)inspectionProfile, profileIsDefined)
&& profileIsDefined){
updateCurrentProfile();
}
return;
}
}
if (EditInspectionToolsSettingsAction.editToolSettings(myProject, inspectionProfile, profileIsDefined, null) && profileIsDefined) {
updateCurrentProfile();
}
}
示例8: invoke
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
final ProjectInspectionToolsConfigurable configurable =
new ProjectInspectionToolsConfigurable(InspectionProfileManager.getInstance(), profileManager) {
@Override
protected boolean acceptTool(InspectionToolWrapper entry) {
return super.acceptTool(entry) && entry.isCleanupTool();
}
@Override
public String getDisplayName() {
return CodeCleanupAction.CODE_CLEANUP_INSPECTIONS_DISPLAY_NAME;
}
};
ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
}
示例9: addRemoveTestsScope
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
private void addRemoveTestsScope(Project project, boolean add) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getInspectionProfile();
final String shortName = myInspection.getShortName();
final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
if (tool == null) {
return;
}
final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
if (add) {
profile.addScope(tool, namedScope, level, false, project);
}
else {
profile.removeScope(shortName, 0, project);
}
profile.scopesChanged();
}
示例10: doTest
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
private static void doTest(final String dirName) throws Exception {
try {
final String relativePath = "/inspection/converter/";
final File projectFile = new File(JavaTestUtil.getJavaTestDataPath() + relativePath + dirName + "/options.ipr");
final List children = JDOMUtil.loadDocument(projectFile).getRootElement().getChildren("component");
for (Object child : children) {
final Element element = (Element)child;
if (Comparing.strEqual(element.getAttributeValue("name"), "InspectionProjectProfileManager")) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(getProject());
InspectionProfileImpl.INIT_INSPECTIONS = true;
profileManager.readExternal(element);
final Element configElement = new Element("config");
profileManager.writeExternal(configElement);
final File file = new File(JavaTestUtil.getJavaTestDataPath() + relativePath + dirName + "/options.after.xml");
PlatformTestUtil.assertElementsEqual(configElement, JDOMUtil.loadDocument(file).getRootElement());
break;
}
}
}
finally {
InspectionProfileImpl.INIT_INSPECTIONS = false;
}
}
示例11: testSettingsModification
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testSettingsModification() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
assertEquals(0, InspectionProfileTest.countInitializedTools(profile));
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
assertEquals(0, InspectionProfileTest.countInitializedTools(model));
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model);
panel.setVisible(true);
panel.reset();
assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 0, InspectionProfileTest.countInitializedTools(model));
JavaDocLocalInspection tool = getInspection(model);
assertEquals("", tool.myAdditionalJavadocTags);
tool.myAdditionalJavadocTags = "foo";
model.setModified(true);
panel.apply();
assertEquals(1, InspectionProfileTest.countInitializedTools(model));
assertEquals("foo", getInspection(profile).myAdditionalJavadocTags);
}
示例12: testModifyInstantiatedTool
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testModifyInstantiatedTool() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
assertEquals(0, InspectionProfileTest.countInitializedTools(profile));
JavaDocLocalInspection originalTool = getInspection(profile);
originalTool.myAdditionalJavadocTags = "foo";
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model);
panel.setVisible(true);
panel.reset();
assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 1, InspectionProfileTest.countInitializedTools(model));
JavaDocLocalInspection copyTool = getInspection(model);
copyTool.myAdditionalJavadocTags = "bar";
model.setModified(true);
panel.apply();
assertEquals(1, InspectionProfileTest.countInitializedTools(model));
assertEquals("bar", getInspection(profile).myAdditionalJavadocTags);
}
示例13: testDoNotChangeSettingsOnCancel
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
public void testDoNotChangeSettingsOnCancel() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
assertEquals(0, InspectionProfileTest.countInitializedTools(profile));
JavaDocLocalInspection originalTool = getInspection(profile);
assertEquals("", originalTool.myAdditionalJavadocTags);
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
JavaDocLocalInspection copyTool = getInspection(model);
copyTool.myAdditionalJavadocTags = "foo";
// this change IS NOT COMMITTED
assertEquals("", getInspection(profile).myAdditionalJavadocTags);
}
示例14: apply
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, StylintAnnotationResult annotationResult, @NotNull AnnotationHolder holder) {
if (annotationResult == null) {
return;
}
InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return;
}
if (annotationResult.fileLevel != null) {
Annotation annotation = holder.createWarningAnnotation(file, annotationResult.fileLevel);
annotation.registerFix(new EditSettingsAction(new StylintSettingsPage(file.getProject())));
annotation.setFileLevelAnnotation(true);
return;
}
// TODO consider adding a fix to edit configuration file
if (annotationResult.result == null || annotationResult.result.lint == null || annotationResult.result.lint.isEmpty()) {
return;
}
List<Lint.Issue> issues = annotationResult.result.lint;
if (issues == null) {
return;
}
StylintProjectComponent component = annotationResult.input.project.getComponent(StylintProjectComponent.class);
int tabSize = 4;
for (Lint.Issue issue : issues) {
HighlightSeverity severity = getHighlightSeverity(issue, component.treatAsWarnings);
TextAttributes forcedTextAttributes = AnnotatorUtils.getTextAttributes(colorsScheme, severityRegistrar, severity);
createAnnotation(holder, file, document, issue, "Stylint: ", tabSize, severity, forcedTextAttributes, inspectionKey, component);
}
}
示例15: apply
import com.intellij.profile.codeInspection.InspectionProjectProfileManager; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, ExternalLintAnnotationResult<LintResult> annotationResult, @NotNull AnnotationHolder holder) {
if (annotationResult == null) {
return;
}
InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
// HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
// HighlightSeverity severity = InspectionUtil.getSeverity(inspectionProjectProfileManager, inspectionKey, file);
EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return;
}
SassLintProjectComponent component = annotationResult.input.project.getComponent(SassLintProjectComponent.class);
for (SassLint.Issue warn : annotationResult.result.sassLint.file.errors) {
HighlightSeverity severity = getHighlightSeverity(warn, component.treatAsWarnings);
TextAttributes forcedTextAttributes = InspectionUtil.getTextAttributes(colorsScheme, severityRegistrar, severity);
Annotation annotation = createAnnotation(holder, file, document, warn, severity, forcedTextAttributes, false);
// if (annotation != null) {
// int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column);
// PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
// BaseActionFix actionFix = Fixes.getFixForRule(warn.rule, lit);
// if (actionFix != null) {
// annotation.registerFix(actionFix, null, inspectionKey);
// }
// annotation.registerFix(new SuppressActionFix(warn.rule, lit), null, inspectionKey);
// }
}
}