use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class ModuleHighlightUtil method checkPackageStatement.
static HighlightInfo checkPackageStatement(@NotNull PsiPackageStatement statement, @NotNull PsiFile file, @Nullable PsiJavaModule module) {
if (PsiUtil.isModuleFile(file)) {
String message = JavaErrorMessages.message("module.no.package");
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create();
QuickFixAction.registerQuickFixAction(info, factory().createDeleteFix(statement));
return info;
}
if (module != null) {
String packageName = statement.getPackageName();
if (packageName != null) {
PsiJavaModule origin = JavaModuleGraphUtil.findOrigin(module, packageName);
if (origin != null) {
String message = JavaErrorMessages.message("module.conflicting.packages", packageName, origin.getName());
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create();
}
}
}
return null;
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class ModuleHighlightUtil method checkFileDuplicates.
@Nullable
static HighlightInfo checkFileDuplicates(@NotNull PsiJavaModule element, @NotNull PsiFile file) {
Module module = findModule(file);
if (module != null) {
Project project = file.getProject();
Collection<VirtualFile> others = FilenameIndex.getVirtualFilesByName(project, MODULE_INFO_FILE, module.getModuleScope(false));
if (others.size() > 1) {
String message = JavaErrorMessages.message("module.file.duplicate");
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).descriptionAndTooltip(message).create();
others.stream().map(f -> PsiManager.getInstance(project).findFile(f)).filter(f -> f != file).findFirst().ifPresent(duplicate -> QuickFixAction.registerQuickFixAction(info, new GoToSymbolFix(duplicate, JavaErrorMessages.message("module.open.duplicate.text"))));
return info;
}
}
return null;
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class DaemonAnalyzerTestCase method findAndInvokeIntentionAction.
protected static void findAndInvokeIntentionAction(@NotNull Collection<HighlightInfo> infos, @NotNull String intentionActionName, @NotNull Editor editor, @NotNull PsiFile file) {
List<IntentionAction> actions = getIntentionActions(infos, editor, file);
IntentionAction intentionAction = LightQuickFixTestCase.findActionWithText(actions, intentionActionName);
if (intentionAction == null) {
fail(String.format("Could not find action by name %s.\n" + "Actions: [%s]\n" + "HighlightInfos: [%s]", intentionActionName, StringUtil.join(ContainerUtil.map(actions, c -> c.getText()), ", "), StringUtil.join(infos, ", ")));
}
CodeInsightTestFixtureImpl.invokeIntention(intentionAction, file, editor, intentionActionName);
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class EditorFixture method requireHighlights.
@NotNull
public EditorFixture requireHighlights(HighlightSeverity severity, String... highlights) {
List<String> infos = new ArrayList<>();
for (HighlightInfo info : getCurrentFileFixture().getHighlightInfos(severity)) {
infos.add(info.getDescription());
}
assertThat(infos).containsOnly(highlights);
return this;
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.
the class FileFixture method waitForCodeAnalysisHighlightCount.
@NotNull
public FileFixture waitForCodeAnalysisHighlightCount(@NotNull final HighlightSeverity severity, final int expected) {
final Document document = getNotNullDocument();
pause(new Condition("Waiting for code analysis " + severity + " count to reach " + expected) {
@Override
public boolean test() {
Collection<HighlightInfo> highlightInfos = execute(new GuiQuery<Collection<HighlightInfo>>() {
@Override
protected Collection<HighlightInfo> executeInEDT() throws Throwable {
CommonProcessors.CollectProcessor<HighlightInfo> processor = new CommonProcessors.CollectProcessor<HighlightInfo>();
DaemonCodeAnalyzerEx.processHighlights(document, myProject, severity, 0, document.getTextLength(), processor);
return processor.getResults();
}
});
assertNotNull(highlightInfos);
return highlightInfos.size() == expected;
}
}, SHORT_TIMEOUT);
return this;
}
Aggregations