本文整理汇总了Java中com.intellij.codeInsight.daemon.HighlightDisplayKey.find方法的典型用法代码示例。如果您正苦于以下问题:Java HighlightDisplayKey.find方法的具体用法?Java HighlightDisplayKey.find怎么用?Java HighlightDisplayKey.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.daemon.HighlightDisplayKey
的用法示例。
在下文中一共展示了HighlightDisplayKey.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerFixesForUnusedParameter
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
@Override
public void registerFixesForUnusedParameter(@NotNull PsiParameter parameter, @NotNull Object highlightInfo) {
Project myProject = parameter.getProject();
InspectionProfile profile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
UnusedParametersInspection unusedParametersInspection =
(UnusedParametersInspection)profile.getUnwrappedTool(UnusedSymbolLocalInspectionBase.UNUSED_PARAMETERS_SHORT_NAME, parameter);
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || unusedParametersInspection != null);
List<IntentionAction> options = new ArrayList<IntentionAction>();
HighlightDisplayKey myUnusedSymbolKey = HighlightDisplayKey.find(UnusedSymbolLocalInspectionBase.SHORT_NAME);
options.addAll(IntentionManager.getInstance().getStandardIntentionOptions(myUnusedSymbolKey, parameter));
if (unusedParametersInspection != null) {
SuppressQuickFix[] batchSuppressActions = unusedParametersInspection.getBatchSuppressActions(parameter);
Collections.addAll(options, SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions));
}
//need suppress from Unused Parameters but settings from Unused Symbol
QuickFixAction.registerQuickFixAction((HighlightInfo)highlightInfo, new SafeDeleteFix(parameter),
options, HighlightDisplayKey.getDisplayNameByKey(myUnusedSymbolKey));
}
示例2: 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();
}
示例3: 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;
}
});
}
示例4: 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;
}
示例5: 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();
}
}
示例6: 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);
}
示例7: 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;
}
示例8: PostHighlightingVisitor
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
PostHighlightingVisitor(@NotNull PsiFile file,
@NotNull Document document,
@NotNull RefCountHolder refCountHolder) throws ProcessCanceledException {
myProject = file.getProject();
myFile = file;
myDocument = document;
myCurrentEntryIndex = -1;
myLanguageLevel = PsiUtil.getLanguageLevel(file);
final FileViewProvider viewProvider = myFile.getViewProvider();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
VirtualFile virtualFile = viewProvider.getVirtualFile();
myInLibrary = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
myRefCountHolder = refCountHolder;
ApplicationManager.getApplication().assertReadAccessAllowed();
InspectionProfile profile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
myDeadCodeKey = HighlightDisplayKey.find(UnusedDeclarationInspectionBase.SHORT_NAME);
myDeadCodeInspection = (UnusedDeclarationInspectionBase)profile.getUnwrappedTool(UnusedDeclarationInspectionBase.SHORT_NAME, myFile);
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || myDeadCodeInspection != null);
myUnusedSymbolInspection = myDeadCodeInspection != null ? myDeadCodeInspection.getSharedLocalInspectionTool() : null;
myDeadCodeInfoType = myDeadCodeKey == null
? HighlightInfoType.UNUSED_SYMBOL
: new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(myDeadCodeKey, myFile).getSeverity(),
HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
}
示例9: getSuppressActions
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
@NotNull
@Override
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
String shortName = getShortName();
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
throw new AssertionError("HighlightDisplayKey.find(" + shortName + ") is null. Inspection: "+getClass());
}
return SuppressManager.getInstance().createSuppressActions(key);
}
示例10: appendFixes
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
private static void appendFixes(@Nullable TextRange fixedRange, @NotNull HighlightInfo info, @Nullable List<Annotation.QuickFixInfo> fixes) {
if (fixes != null) {
for (final Annotation.QuickFixInfo quickFixInfo : fixes) {
TextRange range = fixedRange != null ? fixedRange : quickFixInfo.textRange;
HighlightDisplayKey key = quickFixInfo.key != null
? quickFixInfo.key
: HighlightDisplayKey.find(ANNOTATOR_INSPECTION_SHORT_NAME);
info.registerFix(quickFixInfo.quickFix, null, HighlightDisplayKey.getDisplayNameByKey(key), range, key);
}
}
}
示例11: runTool
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
public static void runTool(@NotNull InspectionToolWrapper toolWrapper,
@NotNull final AnalysisScope scope,
@NotNull final GlobalInspectionContextForTests globalContext) {
final String shortName = toolWrapper.getShortName();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null){
HighlightDisplayKey.register(shortName);
}
globalContext.doInspections(scope);
do {
UIUtil.dispatchAllInvocationEvents();
}
while (!globalContext.isFinished());
}
示例12: Descriptor
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
public Descriptor(@NotNull ScopeToolState state, @NotNull InspectionProfileImpl inspectionProfile, @NotNull Project project) {
myState = state;
myInspectionProfile = inspectionProfile;
InspectionToolWrapper tool = state.getTool();
myText = tool.getDisplayName();
final String[] groupPath = tool.getGroupPath();
myGroup = groupPath.length == 0 ? new String[]{InspectionProfileEntry.GENERAL_GROUP_NAME} : groupPath;
myKey = HighlightDisplayKey.find(tool.getShortName());
myScopeName = state.getScopeName();
myScope = state.getScope(project);
myLevel = inspectionProfile.getErrorLevel(myKey, myScope, project);
myEnabled = inspectionProfile.isToolEnabled(myKey, myScope, project);
myToolWrapper = tool;
}
示例13: createHighlightInfo
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
@Nullable
private HighlightInfo createHighlightInfo(@NotNull ProblemDescriptor descriptor,
@NotNull LocalInspectionToolWrapper tool,
@NotNull HighlightInfoType level,
@NotNull Set<Pair<TextRange, String>> emptyActionRegistered,
@NotNull PsiElement element) {
@NonNls String message = ProblemDescriptorUtil.renderDescriptionMessage(descriptor, element);
final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
final InspectionProfile inspectionProfile = myProfileWrapper.getInspectionProfile();
if (!inspectionProfile.isToolEnabled(key, getFile())) return null;
HighlightInfoType type = new HighlightInfoType.HighlightInfoTypeImpl(level.getSeverity(element), level.getAttributesKey());
final String plainMessage = message.startsWith("<html>") ? StringUtil.unescapeXml(XmlStringUtil.stripHtml(message).replaceAll("<[^>]*>", "")) : message;
@NonNls final String link = " <a "
+"href=\"#inspection/" + tool.getShortName() + "\""
+ (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "")
+">" + DaemonBundle.message("inspection.extended.description")
+"</a> " + myShortcutText;
@NonNls String tooltip = null;
if (descriptor.showTooltip()) {
tooltip = XmlStringUtil.wrapInHtml((message.startsWith("<html>") ? XmlStringUtil.stripHtml(message): XmlStringUtil.escapeString(message)) + link);
}
HighlightInfo highlightInfo = highlightInfoFromDescriptor(descriptor, type, plainMessage, tooltip,element);
if (highlightInfo != null) {
registerQuickFixes(tool, descriptor, highlightInfo, emptyActionRegistered);
}
return highlightInfo;
}
示例14: registerQuickFixes
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
private static void registerQuickFixes(@NotNull LocalInspectionToolWrapper tool,
@NotNull ProblemDescriptor descriptor,
@NotNull HighlightInfo highlightInfo,
@NotNull Set<Pair<TextRange,String>> emptyActionRegistered) {
final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
boolean needEmptyAction = true;
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null && fixes.length > 0) {
for (int k = 0; k < fixes.length; k++) {
if (fixes[k] != null) { // prevent null fixes from var args
QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixWrapper.wrap(descriptor, k), key);
needEmptyAction = false;
}
}
}
HintAction hintAction = descriptor instanceof ProblemDescriptorImpl ? ((ProblemDescriptorImpl)descriptor).getHintAction() : null;
if (hintAction != null) {
QuickFixAction.registerQuickFixAction(highlightInfo, hintAction, key);
needEmptyAction = false;
}
if (((ProblemDescriptorBase)descriptor).getEnforcedTextAttributes() != null) {
needEmptyAction = false;
}
if (needEmptyAction && emptyActionRegistered.add(Pair.<TextRange, String>create(highlightInfo.getFixTextRange(), tool.getShortName()))) {
IntentionAction emptyIntentionAction = new EmptyIntentionAction(tool.getDisplayName());
QuickFixAction.registerQuickFixAction(highlightInfo, emptyIntentionAction, key);
}
}
示例15: isInspectionEnabled
import com.intellij.codeInsight.daemon.HighlightDisplayKey; //导入方法依赖的package包/类
public static boolean isInspectionEnabled(@NonNls String shortName, PsiElement context) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(context.getProject());
final InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getInspectionProfile();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
return profile.isToolEnabled(key, context);
}