allow non-navigatable messages in problems view (IDEA-95581 Show project structure errors in the problems window)

add language-level validation for module cycles
This commit is contained in:
Eugene Zhuravlev
2012-11-25 19:23:58 +01:00
parent 0161ef3c12
commit bd9a1483cf
4 changed files with 34 additions and 11 deletions
@@ -56,16 +56,13 @@ public abstract class ProblemsView {
public abstract void clearOldMessages(CompileScope scope, UUID currentSessionId);
public abstract void addMessage(int type, @NotNull String[] text, @Nullable String groupName, @NotNull Navigatable navigatable, @Nullable String exportTextPrefix, @Nullable String rendererTextPrefix, @NotNull UUID sessionId);
public abstract void addMessage(int type, @NotNull String[] text, @Nullable String groupName, @Nullable Navigatable navigatable, @Nullable String exportTextPrefix, @Nullable String rendererTextPrefix, @NotNull UUID sessionId);
public final void addMessage(CompilerMessage message, @NotNull UUID sessionId) {
final VirtualFile file = message.getVirtualFile();
Navigatable navigatable = message.getNavigatable();
if (navigatable == null) {
if (file == null) {
return; // both navigatable and file must not be null
}
navigatable = new OpenFileDescriptor(myProject, file, -1, -1);
if (navigatable == null && file != null) {
navigatable = new OpenFileDescriptor(myProject, file, -1, -1);
}
final CompilerMessageCategory category = message.getCategory();
final int type = CompilerTask.translateCategory(category);
@@ -123,7 +123,7 @@ public class ProblemsViewImpl extends ProblemsView{
public void addMessage(final int type,
@NotNull final String[] text,
@Nullable final String groupName,
@NotNull final Navigatable navigatable,
@Nullable final Navigatable navigatable,
@Nullable final String exportTextPrefix, @Nullable final String rendererTextPrefix, @Nullable final UUID sessionId) {
myViewUpdater.execute(new Runnable() {
@@ -134,7 +134,12 @@ public class ProblemsViewImpl extends ProblemsView{
if (group != null && !sessionId.equals(group.getData())) {
structure.removeElement(group);
}
myPanel.addMessage(type, text, groupName, navigatable, exportTextPrefix, rendererTextPrefix, sessionId);
if (navigatable != null) {
myPanel.addMessage(type, text, groupName, navigatable, exportTextPrefix, rendererTextPrefix, sessionId);
}
else {
myPanel.addMessage(type, text, null, -1, -1, sessionId);
}
}
});
}
@@ -110,7 +110,9 @@ class AutoMakeMessageHandler extends DefaultMessageHandler {
@Override
public void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure) {
CompilerManager.NOTIFICATION_GROUP.createNotification("Auto make failure: " + failure.getDescription(), MessageType.INFO);
final String msg = "Auto make failure: " + failure.getDescription();
CompilerManager.NOTIFICATION_GROUP.createNotification(msg, MessageType.INFO);
ProblemsView.SERVICE.getInstance(myProject).addMessage(new CompilerMessageImpl(myProject, CompilerMessageCategory.ERROR, msg), sessionId);
}
@Override
@@ -2,7 +2,9 @@ package org.jetbrains.jps.incremental.java;
import com.intellij.execution.process.BaseOSProcessHandler;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -273,12 +275,29 @@ public class JavaBuilder extends ModuleLevelBuilder {
profile = context.getAnnotationProcessingProfile(modules.iterator().next());
}
else {
// perform cycle-related validations
final JpsJavaExtensionService javaExt = JpsJavaExtensionService.getInstance();
Pair<String, LanguageLevel> pair = null;
for (JpsModule module : modules) {
final LanguageLevel moduleLevel = javaExt.getLanguageLevel(module);
if (pair == null) {
pair = Pair.create(module.getName(), moduleLevel); // first value
}
else {
if (!Comparing.equal(pair.getSecond(), moduleLevel)) {
final String message = "Modules " + pair.getFirst()+ " and " +module.getName() + " must have the same language level because of cyclic dependencies between them";
diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, message));
return true;
}
}
}
// check that all chunk modules are excluded from annotation processing
for (JpsModule module : modules) {
final ProcessorConfigProfile prof = context.getAnnotationProcessingProfile(module);
if (prof.isEnabled()) {
String message = "Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [" + chunk.getName() + "] are excluded from annotation processing";
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, message));
final String message = "Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [" + chunk.getName() + "] are excluded from annotation processing";
diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, message));
return true;
}
}