本文整理汇总了Java中com.intellij.codeInsight.daemon.HighlightDisplayKey类的典型用法代码示例。如果您正苦于以下问题:Java HighlightDisplayKey类的具体用法?Java HighlightDisplayKey怎么用?Java HighlightDisplayKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HighlightDisplayKey类属于com.intellij.codeInsight.daemon包,在下文中一共展示了HighlightDisplayKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addError
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
public void addError(@NotNull final String inspectionId, final IComponent component, @Nullable IProperty prop,
@NotNull String errorMessage,
EditorQuickFixProvider... editorQuickFixProviders) {
if (myResults == null) {
myResults = new ArrayList<ErrorInfo>();
}
List<QuickFix> quickFixes = new ArrayList<QuickFix>();
for (EditorQuickFixProvider provider : editorQuickFixProviders) {
if (provider != null) {
quickFixes.add(provider.createQuickFix(myEditor, myComponent));
}
}
final ErrorInfo errorInfo = new ErrorInfo(myComponent, prop == null ? null : prop.getName(), errorMessage,
myProfile.getErrorLevel(HighlightDisplayKey.find(inspectionId), myFormPsiFile),
quickFixes.toArray(new QuickFix[quickFixes.size()]));
errorInfo.setInspectionId(inspectionId);
myResults.add(errorInfo);
}
示例2: testDoNotInstantiateOnSave
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
public void testDoNotInstantiateOnSave() throws Exception {
InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile());
assertEquals(0, countInitializedTools(profile));
InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
assertTrue(toolWrappers.length > 0);
InspectionToolWrapper toolWrapper = profile.getInspectionTool(new DataFlowInspection().getShortName(), getProject());
assertNotNull(toolWrapper);
String id = toolWrapper.getShortName();
System.out.println(id);
if (profile.isToolEnabled(HighlightDisplayKey.findById(id))) {
profile.disableTool(id, getProject());
}
else {
profile.enableTool(id, getProject());
}
assertEquals(0, countInitializedTools(profile));
profile.writeExternal(new Element("profile"));
List<InspectionToolWrapper> initializedTools = getInitializedTools(profile);
if (initializedTools.size() > 0) {
for (InspectionToolWrapper initializedTool : initializedTools) {
System.out.println(initializedTool.getShortName());
}
fail();
}
}
示例3: registerFix
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
public void registerFix(@Nullable IntentionAction action,
@Nullable List<IntentionAction> options,
@Nullable String displayName,
@Nullable TextRange fixRange,
@Nullable HighlightDisplayKey key) {
if (action == null) return;
if (fixRange == null) fixRange = new TextRange(startOffset, endOffset);
if (quickFixActionRanges == null) {
quickFixActionRanges = ContainerUtil.createLockFreeCopyOnWriteList();
}
IntentionActionDescriptor desc = new IntentionActionDescriptor(action, options, displayName, null, key, getProblemGroup(), getSeverity());
quickFixActionRanges.add(Pair.create(desc, fixRange));
fixStartOffset = Math.min (fixStartOffset, fixRange.getStartOffset());
fixEndOffset = Math.max (fixEndOffset, fixRange.getEndOffset());
if (action instanceof HintAction) {
setHint(true);
}
}
示例4: enableInspectionTool
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
public static void enableInspectionTool(@NotNull final Project project, @NotNull final InspectionToolWrapper toolWrapper) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
final String shortName = toolWrapper.getShortName();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
HighlightDisplayKey.register(shortName, toolWrapper.getDisplayName(), toolWrapper.getID());
}
InspectionProfileImpl.initAndDo(new Computable() {
@Override
public Object compute() {
InspectionProfileImpl impl = (InspectionProfileImpl)profile;
InspectionToolWrapper existingWrapper = impl.getInspectionTool(shortName, project);
if (existingWrapper == null || existingWrapper.isInitialized() != toolWrapper.isInitialized() || toolWrapper.isInitialized() && toolWrapper.getTool() != existingWrapper.getTool()) {
impl.addTool(project, toolWrapper, new THashMap<String, List<String>>());
}
impl.enableTool(shortName, project);
return null;
}
});
}
示例5: getSeverity
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
protected HighlightSeverity getSeverity(@NotNull RefElement element) {
final PsiElement psiElement = element.getPointer().getContainingFile();
if (psiElement != null) {
final GlobalInspectionContextImpl context = getContext();
final String shortName = getSeverityDelegateName();
final Tools tools = context.getTools().get(shortName);
if (tools != null) {
for (ScopeToolState state : tools.getTools()) {
InspectionToolWrapper toolWrapper = state.getTool();
if (toolWrapper == getToolWrapper()) {
return context.getCurrentProfile().getErrorLevel(HighlightDisplayKey.find(shortName), psiElement).getSeverity();
}
}
}
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
final HighlightDisplayLevel level = profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement);
return level.getSeverity();
}
return null;
}
示例6: buildTree
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
private boolean buildTree() {
InspectionProfile profile = myInspectionProfile;
boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY;
myGroups.clear();
final Map<String, Tools> tools = myGlobalInspectionContext.getTools();
boolean resultsFound = false;
for (Tools currentTools : tools.values()) {
InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool();
final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName());
for (ScopeToolState state : myProvider.getTools(currentTools)) {
InspectionToolWrapper toolWrapper = state.getTool();
if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) {
addTool(toolWrapper, ((InspectionProfileImpl)profile).getErrorLevel(key, state.getScope(myProject), myProject), isGroupedBySeverity);
resultsFound = true;
}
}
}
return resultsFound;
}
示例7: actionPerformed
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的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: process
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
@Override
public boolean process(Trinity<ProblemDescriptor, LocalInspectionToolWrapper,ProgressIndicator> trinity) {
ProgressIndicator indicator = trinity.getThird();
if (indicator.isCanceled()) {
return false;
}
ProblemDescriptor descriptor = trinity.first;
LocalInspectionToolWrapper tool = trinity.second;
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement == null) return true;
PsiFile file = psiElement.getContainingFile();
Document thisDocument = documentManager.getDocument(file);
HighlightSeverity severity = inspectionProfile.getErrorLevel(HighlightDisplayKey.find(tool.getShortName()), file).getSeverity();
infos.clear();
createHighlightsForDescriptor(infos, emptyActionRegistered, ilManager, file, thisDocument, tool, severity, descriptor, psiElement);
for (HighlightInfo info : infos) {
final EditorColorsScheme colorsScheme = getColorsScheme();
UpdateHighlightersUtil.addHighlighterToEditorIncrementally(myProject, myDocument, getFile(), myRestrictRange.getStartOffset(), myRestrictRange.getEndOffset(),
info, colorsScheme, getId(), ranges2markersCache);
}
return true;
}
示例9: getValueAt
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
@Nullable
@Override
public Object getValueAt(final Object node, final int column) {
if (column == TREE_COLUMN) {
return null;
}
final InspectionConfigTreeNode treeNode = (InspectionConfigTreeNode)node;
final List<HighlightDisplayKey> inspectionsKeys = InspectionsAggregationUtil.getInspectionsKeys(treeNode);
if (column == SEVERITIES_COLUMN) {
final MultiColoredHighlightSeverityIconSink sink = new MultiColoredHighlightSeverityIconSink();
for (final HighlightDisplayKey selectedInspectionsNode : inspectionsKeys) {
final String toolId = selectedInspectionsNode.toString();
if (mySettings.getInspectionProfile().getTools(toolId, mySettings.getProject()).isEnabled()) {
sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()),
mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject()));
}
}
return sink.constructIcon(mySettings.getInspectionProfile());
} else if (column == IS_ENABLED_COLUMN) {
return isEnabled(inspectionsKeys);
}
throw new IllegalArgumentException();
}
示例10: addDynamicAnnotation
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
private static void addDynamicAnnotation(HighlightInfo info, GrReferenceExpression referenceExpression, HighlightDisplayKey key) {
final PsiFile containingFile = referenceExpression.getContainingFile();
if (containingFile != null) {
VirtualFile file = containingFile.getVirtualFile();
if (file == null) return;
}
else {
return;
}
if (PsiUtil.isCall(referenceExpression)) {
PsiType[] argumentTypes = PsiUtil.getArgumentTypes(referenceExpression, false);
if (argumentTypes != null) {
QuickFixAction.registerQuickFixAction(info, referenceExpression.getTextRange(),
GroovyQuickFixFactory.getInstance().createDynamicMethodFix(referenceExpression,
argumentTypes), key);
}
}
else {
QuickFixAction.registerQuickFixAction(info, referenceExpression.getTextRange(), GroovyQuickFixFactory.getInstance().createDynamicPropertyFix(referenceExpression), key);
}
}
示例11: collectInspectionFromNodes
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
private static void collectInspectionFromNodes(final InspectionConfigTreeNode node,
final Set<HighlightDisplayKey> tools,
final List<InspectionConfigTreeNode> nodes) {
if (node == null) {
return;
}
nodes.add(node);
final ToolDescriptors descriptors = node.getDescriptors();
if (descriptors == null) {
for (int i = 0; i < node.getChildCount(); i++) {
collectInspectionFromNodes((InspectionConfigTreeNode)node.getChildAt(i), tools, nodes);
}
} else {
final HighlightDisplayKey key = descriptors.getDefaultDescriptor().getKey();
tools.add(key);
}
}
示例12: addRemoveTestsScope
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的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();
}
示例13: testHighlightStatus_OtherInspections2
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的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));
}
示例14: getHighlighLevelAndInspection
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
@Nullable
public static Pair<AndroidLintInspectionBase, HighlightDisplayLevel> getHighlighLevelAndInspection(@NotNull Project project,
@NotNull Issue issue,
@NotNull PsiElement context) {
final String inspectionShortName = AndroidLintInspectionBase.getInspectionShortNameByIssue(project, issue);
if (inspectionShortName == null) {
return null;
}
final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionShortName);
if (key == null) {
return null;
}
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
if (!profile.isToolEnabled(key, context)) {
return null;
}
final AndroidLintInspectionBase inspection = (AndroidLintInspectionBase)profile.getUnwrappedTool(inspectionShortName, context);
if (inspection == null) return null;
final HighlightDisplayLevel errorLevel = profile.getErrorLevel(key, context);
return Pair.create(inspection,
errorLevel != null ? errorLevel : HighlightDisplayLevel.WARNING);
}
示例15: getIssuesFromInspections
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入依赖的package包/类
@NotNull
static List<Issue> getIssuesFromInspections(@NotNull Project project, @Nullable PsiElement context) {
final List<Issue> result = new ArrayList<Issue>();
final IssueRegistry fullRegistry = new IntellijLintIssueRegistry();
for (Issue issue : fullRegistry.getIssues()) {
final String inspectionShortName = AndroidLintInspectionBase.getInspectionShortNameByIssue(project, issue);
if (inspectionShortName == null) {
continue;
}
final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionShortName);
if (key == null) {
continue;
}
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
final boolean enabled = context != null ? profile.isToolEnabled(key, context) : profile.isToolEnabled(key);
if (!enabled) {
continue;
}
result.add(issue);
}
return result;
}