Java Code Examples for com.intellij.codeInsight.daemon.DaemonBundle#message()
The following examples show how to use
com.intellij.codeInsight.daemon.DaemonBundle#message() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DaemonTooltipWithActionRenderer.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override protected String getHtmlForProblemWithLink(@Nonnull String problem) { //remove "more... (keymap)" info Html html = new Html(problem).setKeepFont(true); String extendMessage = DaemonBundle.message("inspection.extended.description"); String textToProcess = UIUtil.getHtmlBody(html); int indexOfMore = textToProcess.indexOf(extendMessage); if (indexOfMore < 0) return textToProcess; int keymapStartIndex = textToProcess.indexOf("(", indexOfMore); if (keymapStartIndex > 0) { int keymapEndIndex = textToProcess.indexOf(")", keymapStartIndex); if (keymapEndIndex > 0) { textToProcess = textToProcess.substring(0, keymapStartIndex) + textToProcess.substring(keymapEndIndex + 1, textToProcess.length()); } } return textToProcess.replace(extendMessage, ""); }
Example 2
Source File: HaxeLineMarkerProvider.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Nullable private static LineMarkerInfo createImplementationMarker(final HaxeClass componentWithDeclarationList, final List<HaxeClass> items) { final HaxeComponentName componentName = componentWithDeclarationList.getComponentName(); if (componentName == null) { return null; } final PsiElement element = componentName.getIdentifier().getFirstChild(); return new LineMarkerInfo<>( element, element.getTextRange(), componentWithDeclarationList instanceof HaxeInterfaceDeclaration ? AllIcons.Gutter.ImplementedMethod : AllIcons.Gutter.OverridenMethod, Pass.UPDATE_ALL, item -> DaemonBundle.message("method.is.implemented.too.many"), new GutterIconNavigationHandler<PsiElement>() { @Override public void navigate(MouseEvent e, PsiElement elt) { PsiElementListNavigator.openTargets( e, HaxeResolveUtil.getComponentNames(items).toArray(new NavigatablePsiElement[items.size()]), DaemonBundle.message("navigation.title.subclass", componentWithDeclarationList.getName(), items.size()), "Subclasses of " + componentWithDeclarationList.getName(), new DefaultPsiElementCellRenderer() ); } }, GutterIconRenderer.Alignment.RIGHT ); }
Example 3
Source File: ThriftLineMarkerProvider.java From intellij-thrift with Apache License 2.0 | 5 votes |
@Nullable private LineMarkerInfo findImplementationsAndCreateMarker(final ThriftDefinitionName definitionName) { final List<NavigatablePsiElement> implementations = ThriftPsiUtil.findImplementations(definitionName); if (implementations.isEmpty()) { return null; } return new LineMarkerInfo<PsiElement>( definitionName, definitionName.getTextRange(), AllIcons.Gutter.ImplementedMethod, Pass.UPDATE_ALL, new Function<PsiElement, String>() { @Override public String fun(PsiElement element) { return DaemonBundle.message("interface.is.implemented.too.many"); } }, new GutterIconNavigationHandler<PsiElement>() { @Override public void navigate(MouseEvent e, PsiElement elt) { PsiElementListNavigator.openTargets( e, implementations.toArray(new NavigatablePsiElement[implementations.size()]), DaemonBundle.message("navigation.title.implementation.method", definitionName.getText(), implementations.size()), "Implementations of " + definitionName.getText(), new DefaultPsiElementCellRenderer() ); } }, GutterIconRenderer.Alignment.RIGHT ); }
Example 4
Source File: LocalInspectionsPass.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private HighlightInfo createHighlightInfo(@Nonnull ProblemDescriptor descriptor, @Nonnull LocalInspectionToolWrapper tool, @Nonnull HighlightInfoType level, @Nonnull Set<Pair<TextRange, String>> emptyActionRegistered, @Nonnull 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; }
Example 5
Source File: ShowAutoImportPass.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String getMessage(final boolean multiple, @Nonnull String name) { final String messageKey = multiple ? "import.popup.multiple" : "import.popup.text"; String hintText = DaemonBundle.message(messageKey, name); hintText += " " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS)); return hintText; }
Example 6
Source File: HeavyProcessLatch.java From consulo with Apache License 2.0 | 4 votes |
@Override public String toString() { return DaemonBundle.message(bundleKey); }
Example 7
Source File: WolfHighlightingPass.java From consulo with Apache License 2.0 | 4 votes |
WolfHighlightingPass(@Nonnull Project project, @Nonnull Document document, @Nonnull PsiFile file) { super(project, document, DaemonBundle.message("pass.wolf"), file, null, TextRange.EMPTY_RANGE, false, HighlightInfoProcessor.getEmpty()); }
Example 8
Source File: WholeFileLocalInspectionsPassFactory.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nullable public TextEditorHighlightingPass createHighlightingPass(@Nonnull final PsiFile file, @Nonnull final Editor editor) { final long psiModificationCount = PsiManager.getInstance(myProject).getModificationTracker().getModificationCount(); if (psiModificationCount == myPsiModificationCount) { return null; //optimization } if (myFileToolsCache.containsKey(file) && !myFileToolsCache.get(file)) { return null; } ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor); return new LocalInspectionsPass(file, editor.getDocument(), 0, file.getTextLength(), visibleRange, true, new DefaultHighlightInfoProcessor()) { @Nonnull @Override List<LocalInspectionToolWrapper> getInspectionTools(@Nonnull InspectionProfileWrapper profile) { List<LocalInspectionToolWrapper> tools = super.getInspectionTools(profile); List<LocalInspectionToolWrapper> result = tools.stream().filter(LocalInspectionToolWrapper::runForWholeFile).collect(Collectors.toList()); myFileToolsCache.put(file, !result.isEmpty()); return result; } @Override protected String getPresentableName() { return DaemonBundle.message("pass.whole.inspections"); } @Override void inspectInjectedPsi(@Nonnull List<PsiElement> elements, boolean onTheFly, @Nonnull ProgressIndicator indicator, @Nonnull InspectionManager iManager, boolean inVisibleRange, @Nonnull List<LocalInspectionToolWrapper> wrappers) { // already inspected in LIP } @Override protected void applyInformationWithProgress() { super.applyInformationWithProgress(); myPsiModificationCount = PsiManager.getInstance(myProject).getModificationTracker().getModificationCount(); } }; }
Example 9
Source File: ConfigureInspectionsAction.java From consulo with Apache License 2.0 | 4 votes |
public ConfigureInspectionsAction() { super(DaemonBundle.message("popup.action.configure.inspections")); }
Example 10
Source File: TrafficLightRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@Nonnull SeverityRegistrar severityRegistrar) { DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus(); PsiFile psiFile = getPsiFile(); if (psiFile == null) { status.reasonWhyDisabled = DaemonBundle.message("process.title.no.file"); status.errorAnalyzingFinished = true; return status; } if (myProject.isDisposed()) { status.reasonWhyDisabled = DaemonBundle.message("process.title.project.is.disposed"); status.errorAnalyzingFinished = true; return status; } if (!myDaemonCodeAnalyzer.isHighlightingAvailable(psiFile)) { if (!psiFile.isPhysical()) { status.reasonWhyDisabled = DaemonBundle.message("process.title.file.is.generated"); status.errorAnalyzingFinished = true; return status; } if (psiFile instanceof PsiCompiledElement) { status.reasonWhyDisabled = DaemonBundle.message("process.title.file.is.decompiled"); status.errorAnalyzingFinished = true; return status; } final FileType fileType = psiFile.getFileType(); if (fileType.isBinary()) { status.reasonWhyDisabled = DaemonBundle.message("process.title.file.is.binary"); status.errorAnalyzingFinished = true; return status; } status.reasonWhyDisabled = DaemonBundle.message("process.title.highlighting.is.disabled.for.this.file"); status.errorAnalyzingFinished = true; return status; } FileViewProvider provider = psiFile.getViewProvider(); Set<Language> languages = provider.getLanguages(); HighlightingSettingsPerFile levelSettings = HighlightingSettingsPerFile.getInstance(myProject); boolean shouldHighlight = languages.isEmpty(); for (Language language : languages) { PsiFile root = provider.getPsi(language); FileHighlightingSetting level = levelSettings.getHighlightingSettingForRoot(root); shouldHighlight |= level != FileHighlightingSetting.SKIP_HIGHLIGHTING; } if (!shouldHighlight) { status.reasonWhyDisabled = DaemonBundle.message("process.title.highlighting.level.is.none"); status.errorAnalyzingFinished = true; return status; } if (HeavyProcessLatch.INSTANCE.isRunning()) { Map.Entry<String, HeavyProcessLatch.Type> processEntry = HeavyProcessLatch.INSTANCE.getRunningOperation(); if (processEntry != null) { status.reasonWhySuspended = processEntry.getKey(); status.heavyProcessType = processEntry.getValue(); } else { status.reasonWhySuspended = DaemonBundle.message("process.title.heavy.operation.is.running"); status.heavyProcessType = HeavyProcessLatch.Type.Processing; } status.errorAnalyzingFinished = true; return status; } status.errorCount = errorCount.clone(); List<ProgressableTextEditorHighlightingPass> passesToShowProgressFor = myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument); status.passes = ContainerUtil.filter(passesToShowProgressFor, p -> !StringUtil.isEmpty(p.getPresentableName()) && p.getProgress() >= 0); status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(psiFile); status.reasonWhySuspended = myDaemonCodeAnalyzer.isUpdateByTimerEnabled() ? null : DaemonBundle.message("process.title.highlighting.is.paused.temporarily"); fillDaemonCodeAnalyzerErrorsStatus(status, severityRegistrar); return status; }
Example 11
Source File: TrafficLightRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public AnalyzerStatus getStatus(@Nonnull Editor editor) { if (PowerSaveMode.isEnabled()) { return new AnalyzerStatus(AllIcons.General.InspectionsPowerSaveMode, "Code analysis is disabled in power save mode", "", () -> createUIController(editor)); } else { DaemonCodeAnalyzerStatus status = getDaemonCodeAnalyzerStatus(mySeverityRegistrar); List<StatusItem> statusItems = new ArrayList<>(); Icon mainIcon = null; String title = ""; String details = ""; boolean isDumb = DumbService.isDumb(myProject); if (status.errorAnalyzingFinished) { if (isDumb) { title = DaemonBundle.message("shallow.analysis.completed"); details = DaemonBundle.message("shallow.analysis.completed.details"); } } else { title = DaemonBundle.message("performing.code.analysis"); } int[] errorCount = status.errorCount; for (int i = errorCount.length - 1; i >= 0; i--) { int count = errorCount[i]; if (count > 0) { HighlightSeverity severity = mySeverityRegistrar.getSeverityByIndex(i); String name = StringUtil.toLowerCase(severity.getName()); if (count > 1) { name = StringUtil.pluralize(name); } Icon icon = mySeverityRegistrar.getRendererIconByIndex(i); statusItems.add(new StatusItem(Integer.toString(count), icon, name)); if (mainIcon == null) { mainIcon = icon; } } } if (!statusItems.isEmpty()) { if (mainIcon == null) { mainIcon = AllIcons.General.InspectionsOK; } AnalyzerStatus result = new AnalyzerStatus(mainIcon, title, "", () -> createUIController(editor)). withNavigation(). withExpandedStatus(statusItems); //noinspection ConstantConditions return status.errorAnalyzingFinished ? result : result.withAnalyzingType(AnalyzingType.PARTIAL). withPasses(ContainerUtil.map(status.passes, p -> new PassWrapper(p.getPresentableName(), p.getProgress(), p.isFinished()))); } if (StringUtil.isNotEmpty(status.reasonWhyDisabled)) { return new AnalyzerStatus(AllIcons.General.InspectionsTrafficOff, DaemonBundle.message("no.analysis.performed"), status.reasonWhyDisabled, () -> createUIController(editor)) .withTextStatus(DaemonBundle.message("iw.status.off")); } if (StringUtil.isNotEmpty(status.reasonWhySuspended)) { return new AnalyzerStatus(AllIcons.General.InspectionsPause, DaemonBundle.message("analysis.suspended"), status.reasonWhySuspended, () -> createUIController(editor)). withTextStatus(status.heavyProcessType != null ? status.heavyProcessType.toString() : DaemonBundle.message("iw.status.paused")); } if (status.errorAnalyzingFinished) { return isDumb ? new AnalyzerStatus(AllIcons.General.InspectionsPause, title, details, () -> createUIController(editor)). withTextStatus(DaemonBundle.message("heavyProcess.type.indexing")) : new AnalyzerStatus(AllIcons.General.InspectionsOK, DaemonBundle.message("no.errors.or.warnings.found"), details, () -> createUIController(editor)); } //noinspection ConstantConditions return new AnalyzerStatus(AllIcons.General.InspectionsEye, title, details, () -> createUIController(editor)). withTextStatus(DaemonBundle.message("iw.status.analyzing")). withAnalyzingType(AnalyzingType.EMPTY). withPasses(ContainerUtil.map(status.passes, p -> new PassWrapper(p.getPresentableName(), p.getProgress(), p.isFinished()))); } }
Example 12
Source File: ConfigureHighlightingLevel.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static JBPopup getConfigureHighlightingLevelPopup(DataContext context) { PsiFile psi = context.getData(CommonDataKeys.PSI_FILE); if (psi == null) { return null; } if (!psi.isValid() || psi.getProject().isDisposed()) return null; FileViewProvider provider = psi.getViewProvider(); Set<Language> languages = provider.getLanguages(); if (languages.isEmpty()) return null; VirtualFile file = psi.getVirtualFile(); if (file == null) { return null; } ProjectFileIndex index = ProjectFileIndex.getInstance(psi.getProject()); boolean isAllInspectionsEnabled = index.isInContent(file) || !index.isInLibrary(file); boolean isSeparatorNeeded = languages.size() > 1; DefaultActionGroup group = new DefaultActionGroup(); languages.stream().sorted((o1, o2) -> o1.getDisplayName().compareTo(o2.getDisplayName())).forEach(it -> { if (isSeparatorNeeded) { group.add(AnSeparator.create(it.getDisplayName())); } group.add(new LevelAction(InspectionsLevel.NONE, provider, it)); group.add(new LevelAction(InspectionsLevel.ERRORS, provider, it)); if (isAllInspectionsEnabled) { group.add(new LevelAction(InspectionsLevel.ALL, provider, it)); } }); group.add(AnSeparator.create()); group.add(new ConfigureInspectionsAction()); String title = DaemonBundle.message("popup.title.configure.highlighting.level", psi.getVirtualFile().getPresentableName()); return JBPopupFactory.getInstance().createActionGroupPopup(title, group, context, true, null, 100); }