]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Showing compilation warnings in SCL issue view and editors 88/288/1
authorHannu Niemistö <hannu.niemisto@iki.fi>
Sun, 22 Jan 2017 21:45:57 +0000 (23:45 +0200)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 23 Jan 2017 13:15:05 +0000 (15:15 +0200)
refs #6987

Change-Id: I127a72d134789982cb842ae351df5ef8604bae40

24 files changed:
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/SCLCompiler.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/TypeChecking.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/TranslationContext.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/annotations/AnnotationUtils.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/DeprecatedProperty.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/SCLValue.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Environments.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/CompilationError.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorLog.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/LazyModule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/Module.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/source/TextualModuleSource.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/top/ExpressionEvaluator.java
bundles/org.simantics.scl.runtime/scl/Prelude.scl
bundles/org.simantics.scl.ui/icons/warning.png [new file with mode: 0644]
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/Activator.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesContentProvider.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesTableEntry.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java

index 6c2befb5cdb15c2e72d171cfbc88c0c3663b6972..7c6d53ac8f698171b3275f533925afb68bee1698 100644 (file)
@@ -34,14 +34,10 @@ import org.simantics.scl.compiler.internal.parsing.translation.ProcessedDInstanc
 import org.simantics.scl.compiler.internal.parsing.translation.RelationRepository;
 import org.simantics.scl.compiler.internal.parsing.translation.ValueRepository;
 import org.simantics.scl.compiler.module.ImportDeclaration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 
 public class DeclarationClassification {
-    private static final Logger LOGGER = LoggerFactory.getLogger(DeclarationClassification.class);
-    
     ArrayList<ImportDeclaration> importsAst = new ArrayList<ImportDeclaration>();
     ArrayList<DDataAst> dataTypesAst = new ArrayList<DDataAst>();
     ArrayList<DTypeAst> typeAliasesAst = new ArrayList<DTypeAst>();
@@ -241,7 +237,7 @@ public class DeclarationClassification {
             currentAnnotations = new ArrayList<DAnnotationAst>(2);
         }
         if(declaration.name.name.equals("Eq") || declaration.name.name.equals("Hashable")) {
-            LOGGER.warn("Skipped instance definition for " + declaration.name + " for " + declaration.types[0]);
+               errorLog.logWarning(declaration.location, "Skipped instance definition for " + declaration.name + " for " + declaration.types[0]);
             return;
         }
         instancesAst.add(new ProcessedDInstanceAst(
@@ -255,7 +251,7 @@ public class DeclarationClassification {
             currentAnnotations = new ArrayList<DAnnotationAst>(2);
         }
         if(declaration.name.name.equals("Eq") || declaration.name.name.equals("Hashable")) {
-            LOGGER.warn("Skipped instance definition for " + declaration.name + " for " + declaration.types[0]);
+               errorLog.logWarning(declaration.location, "Skipped instance definition for " + declaration.name + " for " + declaration.types[0]);
             return;
         }
         derivingInstancesAst.add(declaration);
index f5834aef1ac949b92a74a5c83c3cd2265a0f0fd5..0971641e8b4470b2938f2cc8ac9660dc58a7d316 100644 (file)
@@ -31,9 +31,11 @@ import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
 import org.simantics.scl.compiler.elaboration.expressions.EVar;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
+import org.simantics.scl.compiler.elaboration.expressions.annotations.AnnotationUtils;
 import org.simantics.scl.compiler.elaboration.fundeps.Fundep;
 import org.simantics.scl.compiler.elaboration.java.JavaMethodDeclaration;
 import org.simantics.scl.compiler.elaboration.macros.StandardMacroRule;
+import org.simantics.scl.compiler.elaboration.modules.DeprecatedProperty;
 import org.simantics.scl.compiler.elaboration.modules.InlineProperty;
 import org.simantics.scl.compiler.elaboration.modules.MethodImplementation;
 import org.simantics.scl.compiler.elaboration.modules.PrivateProperty;
@@ -310,7 +312,7 @@ public class Elaboration {
             }
         }.findComponents();
         
-        if(errorLog.isEmpty()) {
+        if(errorLog.hasNoErrors()) {
             for(DTypeAst typeAlias : orderedTypeAliases) {
                 TypeAlias alias = (TypeAlias)module.getTypeDescriptor(typeAlias.name);
                 TypeTranslationContext context = createTypeTranslationContext();
@@ -1212,7 +1214,19 @@ public class Elaboration {
             value.addProperty(PrivateProperty.INSTANCE);
         }
         else if(annotation.id.text.equals("@deprecated")) {
-            // TODO
+            String description = "";
+            if(annotation.parameters.length > 0) {
+                if(annotation.parameters.length > 1)
+                    errorLog.log(annotation.location, "Invalid number of parameters, expected one string.");
+                else {
+                    String temp = AnnotationUtils.extractString(annotation.parameters[0]);
+                    if(temp == null)
+                        errorLog.log(annotation.location, "Invalid parameter, expected one string.");
+                    else
+                        description = temp;
+                }
+            }
+            value.addProperty(new DeprecatedProperty(description));
         }
         else
             errorLog.log(annotation.location, "Unknown annotation.");
index 27583ea53b30e25df56ff6e3b73caf7cf1901b65..29136b60935662d0e57bf91534959dfa4b9e7bf7 100644 (file)
@@ -56,7 +56,7 @@ public class SCLCompiler {
     }
     
     private boolean hasErrors() {
-        return !compilationContext.errorLog.isEmpty();
+        return !compilationContext.errorLog.hasNoErrors();
     }
     
     public void compile(
@@ -161,6 +161,8 @@ public class SCLCompiler {
             module.setClasses(classes);
             module.setModuleInitializer(moduleInitializer);
             module.setBranchPoints(elaboration.branchPoints);
+            if(compilationContext.errorLog.hasErrorsOrWarnings())
+                module.setWarnings(compilationContext.errorLog.getErrors());
             
             if(SCLCompilerConfiguration.ENABLE_TIMING) {
                 phaseFinished("Code generation");
index 3118142df09740dce51ead4cf262f058f0b11b0b..b8d959e197b65dd56b9fc23dd9a9a521a0be0857 100644 (file)
@@ -237,7 +237,7 @@ public class TypeChecking {
                                         compilationContext.errorLog.log(c.getDemandLocation(), 
                                                 "Constraint <"+c.constraint+"> is not given and cannot be derived.");
                                     }
-                                    if(compilationContext.errorLog.isEmpty()) { // To prevent exceptions
+                                    if(compilationContext.errorLog.hasNoErrors()) { // To prevent exceptions
                                         expression = ExpressionAugmentation.augmentSolved(
                                                 red.solvedConstraints,
                                                 expression);
@@ -247,7 +247,7 @@ public class TypeChecking {
                                     }
                                 }
                                 else {
-                                    if(compilationContext.errorLog.isEmpty()) // To prevent exceptions
+                                    if(compilationContext.errorLog.hasNoErrors()) // To prevent exceptions
                                         expression = expression.decomposeMatching();
                                 }
                                 expression = expression.closure(vars.toArray(new TVar[vars.size()]));
index 41f807592b7ad1de8c0b28d20183a3d4c80a3948..e5b5720ef07a005b61f3269b3ed07fc30e2737bd 100644 (file)
@@ -205,6 +205,9 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
         }
         if(value == null)
             return new EError(location);
+        String deprecatedDescription = value.isDeprecated();
+        if(deprecatedDescription != null)
+            errorLog.logWarning(location, "Deprecated value " + value.getName().name + "." + (deprecatedDescription.isEmpty() ? "" : " " + deprecatedDescription));
         return new EConstant(location, value);
     }
     
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/annotations/AnnotationUtils.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/annotations/AnnotationUtils.java
new file mode 100644 (file)
index 0000000..fb7334c
--- /dev/null
@@ -0,0 +1,27 @@
+package org.simantics.scl.compiler.elaboration.expressions.annotations;
+
+import org.simantics.scl.compiler.constants.StringConstant;
+import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
+import org.simantics.scl.compiler.elaboration.expressions.EStringLiteral;
+import org.simantics.scl.compiler.elaboration.expressions.EVar;
+import org.simantics.scl.compiler.elaboration.expressions.Expression;
+
+public class AnnotationUtils {
+    public static String extractString(Expression expression) {
+        if(expression instanceof EVar)
+            return ((EVar)expression).name;
+        else if(expression instanceof EStringLiteral) {
+            EStringLiteral literal = (EStringLiteral)expression;
+            if(literal.strings.length == 1)
+                return literal.strings[0];
+        }
+        else if(expression instanceof ELiteral) {
+            ELiteral literal = (ELiteral)expression;
+            if(literal.getValue() instanceof StringConstant) {
+                StringConstant constant = (StringConstant)literal.getValue();
+                return constant.getValue();
+            }
+        }
+        return null;
+    }
+}
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/DeprecatedProperty.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/DeprecatedProperty.java
new file mode 100644 (file)
index 0000000..8298bfc
--- /dev/null
@@ -0,0 +1,9 @@
+package org.simantics.scl.compiler.elaboration.modules;
+
+public class DeprecatedProperty implements SCLValueProperty {
+    public final String description;
+
+    public DeprecatedProperty(String description) {
+        this.description = description;
+    }
+}
index 2d9ed6fe1d5db38ad94ad92d6dc4e91e47b01112..408eb01e561cf96fc5bf020b04e574cadf0e030d 100644 (file)
@@ -144,6 +144,13 @@ public final class SCLValue implements Typed {
                                return true;
                return false;
        }
+       
+       public String isDeprecated() {
+           for(SCLValueProperty property : properties)
+            if(property instanceof DeprecatedProperty)
+                return ((DeprecatedProperty)property).description;
+        return null;
+       }
 
        public void setDocumentation(String documentation) {
                this.documentation = documentation;
index 4328d15e0b02535dfe695e06602702c19ea41218..df86c1130e7930b0866a4d8f046d5e14edf3473a 100644 (file)
@@ -186,7 +186,7 @@ public class Environments {
             TypeAst typeAst = (TypeAst)parser.parseType();
             TypeTranslationContext context = new TypeTranslationContext(compilationContext);
             Type type = context.toType(typeAst);
-            if(compilationContext.errorLog.isEmpty())
+            if(compilationContext.errorLog.hasNoErrors())
                 return type;
         } catch(SCLSyntaxErrorException e) {
             compilationContext.errorLog.log(e.location, e.getMessage());
index bf355285c13d343e4904559e5075c164ef0eb52e..a26823fe88a6ba31d3ebf89c603d6cf85524fc12 100644 (file)
@@ -9,14 +9,20 @@ public class CompilationError implements Comparable<CompilationError> {
     
     public final long location;
     public final String description;
+    public final ErrorSeverity severity;
     
-    public CompilationError(long location, String description) {
+    public CompilationError(long location, String description, ErrorSeverity severity) {
         if(description == null)
             throw new NullPointerException();
         this.location = location;
         this.description = description;
+        this.severity = severity;
     }
     
+    public CompilationError(long location, String description) {
+       this(location, description, ErrorSeverity.ERROR);
+    }          
+    
     public CompilationError(long location, Exception exception) {
         this(location, exceptionToString(exception));
     }
index f2e648b0089ea022021c815f98cf5e52d5d4228c..62d5d8c3de021defc1648d90c15f8ad55998440d 100644 (file)
@@ -6,20 +6,27 @@ import java.util.Collections;
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
 
 public class ErrorLog {
-    ArrayList<CompilationError> errors = new ArrayList<CompilationError>(); 
+    ArrayList<CompilationError> errors = new ArrayList<CompilationError>();
+    int errorCount;
     long exceptionPosition = Locations.NO_LOCATION;
     
     public void log(String message) {
-        errors.add(new CompilationError(message));
+        log(new CompilationError(message));
     }
     
     public void log(CompilationError error) {
         errors.add(error);
+        if(error.severity == ErrorSeverity.ERROR)
+               ++errorCount;
     }
     
     public void log(long locatable, String description) {
         log(new CompilationError(locatable, description));
     }
+    
+    public void logWarning(long locatable, String description) {
+        log(new CompilationError(locatable, description, ErrorSeverity.WARNING));
+    }
 
     public void log(Exception e) {
         long location = Locations.NO_LOCATION;
@@ -34,8 +41,16 @@ public class ErrorLog {
         log(new CompilationError(location, e));
     }
     
-    public boolean isEmpty() {
-        return errors.isEmpty();
+    public boolean hasNoErrors() {
+        return errorCount == 0;
+    }
+    
+    public boolean hasErrors() {
+        return errorCount > 0;
+    }
+    
+    public boolean hasErrorsOrWarnings() {
+        return !errors.isEmpty();
     }
 
     public CompilationError[] getErrors() {
@@ -49,6 +64,7 @@ public class ErrorLog {
     }
 
     public String getErrorsAsString() {
+        Collections.sort(errors);
         StringBuilder b = new StringBuilder();
         for(CompilationError error : errors)
             b.append(error.description).append('\n');
@@ -61,6 +77,6 @@ public class ErrorLog {
     }
 
     public int getErrorCount() {
-        return errors.size();
+        return errorCount;
     }
 }
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java
new file mode 100644 (file)
index 0000000..9f65cb3
--- /dev/null
@@ -0,0 +1,6 @@
+package org.simantics.scl.compiler.errors;
+
+public enum ErrorSeverity {
+       ERROR,
+       WARNING
+}
index 2f6d52bdba63298ad51c6de3e4f2c8fe3c5b6b89..a8b51a8be96cad3a0aa1933758e89cc4201707bf 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
 import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
+import org.simantics.scl.compiler.errors.CompilationError;
 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
 import org.simantics.scl.compiler.top.ModuleInitializer;
 import org.simantics.scl.compiler.types.TCon;
@@ -41,7 +42,8 @@ public class ConcreteModule implements Module {
     THashMap<String, MappingRelation> mappingRelations = new THashMap<String, MappingRelation>();
     ArrayList<ImportDeclaration> dependencies = new ArrayList<ImportDeclaration>();
     THashMap<String, BranchPoint[]> branchPoints;
-
+    CompilationError[] warnings = CompilationError.EMPTY_ARRAY;
+    
     Map<String, byte[]> classes = Collections.emptyMap();
     ModuleInitializer moduleInitializer;
 
@@ -267,6 +269,13 @@ public class ConcreteModule implements Module {
 
     @Override
     public void dispose() {
-        
+    }
+    
+    public void setWarnings(CompilationError[] warnings) {
+        this.warnings = warnings;
+    }
+    
+    public CompilationError[] getWarnings() {
+        return warnings;
     }
 }
index 00871dcdf377aebd7b1d77051d70182033906841..fe57054cc133b7fe28f6ec636ef28f4c962b4212 100644 (file)
@@ -5,7 +5,6 @@ import java.util.Collections;
 
 import org.simantics.scl.compiler.elaboration.modules.Documentation;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
 import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance;
 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
@@ -13,6 +12,7 @@ import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
+import org.simantics.scl.compiler.errors.CompilationError;
 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
 import org.simantics.scl.compiler.top.ModuleInitializer;
 import org.simantics.scl.compiler.types.TCon;
@@ -134,4 +134,9 @@ public abstract class LazyModule implements Module {
     public THashMap<String, BranchPoint[]> getBranchPoints() {
         return null;
     }
+    
+    @Override
+    public CompilationError[] getWarnings() {
+        return CompilationError.EMPTY_ARRAY;
+    }
 }
index e8a1113367be7a9acde195e7e0b9e33629da9f57..180509521312ca6e7bb014ec0d99e8ba7ab015b2 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
 import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
+import org.simantics.scl.compiler.errors.CompilationError;
 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
 import org.simantics.scl.compiler.top.ModuleInitializer;
 import org.simantics.scl.compiler.types.TCon;
@@ -51,5 +52,7 @@ public interface Module {
 
     THashMap<String, BranchPoint[]> getBranchPoints();
     void dispose();
+
+    CompilationError[] getWarnings();
     
 }
index f4e9c7de048cc6347c1c685a60a4777a1aaaf107..4f22022e5f46cd6ba5cb60767fbbb05f425f86bf 100644 (file)
@@ -90,7 +90,7 @@ public abstract class TextualModuleSource implements ModuleSource {
                             listener),
                     moduleName,
                     getJavaReferenceValidator());
-            if(compiler.getErrorLog().isEmpty())
+            if(compiler.getErrorLog().hasNoErrors())
                 return new Success<Module>(compiler.getModule());
             else {
                 LOGGER.error("While compiling " + getModuleName() + ":");
index d87beec65a7380361a2c45961fa41c2c886b8c18..c1881fbca53acb2ffc20a21a01a4f4291ed77cb4 100644 (file)
@@ -253,7 +253,7 @@ public class ExpressionEvaluator {
         {
             TranslationContext context = new TranslationContext(compilationContext, localEnvironment);
             expression = expression.resolve(context);
-            if(!errorLog.isEmpty())
+            if(!errorLog.hasNoErrors())
                 throw new SCLExpressionCompilationException(errorLog.getErrors());
         }
         
@@ -278,7 +278,7 @@ public class ExpressionEvaluator {
             
             expectedType.addPolarity(Polarity.POSITIVE);
             context.solveSubsumptions(expression.location);
-            if(!errorLog.isEmpty())
+            if(!errorLog.hasNoErrors())
                 throw new SCLExpressionCompilationException(errorLog.getErrors());
             if(decorateExpression && Types.canonical(expectedEffect) != Types.NO_EFFECTS) {
                 ExpressionDecorator decorator =
@@ -288,7 +288,7 @@ public class ExpressionEvaluator {
             expression = context.solveConstraints(environment, expression);
             expressionType = expression.getType();
             
-            if(!errorLog.isEmpty())
+            if(!errorLog.hasNoErrors())
                 throw new SCLExpressionCompilationException(errorLog.getErrors());
 
             if(localEnvironment != null)
@@ -319,7 +319,7 @@ public class ExpressionEvaluator {
                 new SimplificationContext(compilationContext, DummyJavaReferenceValidator.INSTANCE);
         expression = expression.simplify(context);
         
-        if(!errorLog.isEmpty())
+        if(!errorLog.hasNoErrors())
             throw new SCLExpressionCompilationException(errorLog.getErrors());
         
         if(SCLCompilerConfiguration.SHOW_EXPRESSION_BEFORE_EVALUATION)
index c2307014a51ceec23d4c4e7d059667d0a414a015..2c5966dc40f99a2b38a594b675dd8dc9588bf1bb 100644 (file)
@@ -1396,6 +1396,7 @@ instance Show String where
 instance Read String where
     read str = str
     
+@deprecated
 "`splitString text pattern` splits the string into a list of string where the parts are sepratated in the original list by the given pattern."
 splitString :: String -> String -> [String]
 splitString source pattern = arrayToList $ splitString_ source pattern
diff --git a/bundles/org.simantics.scl.ui/icons/warning.png b/bundles/org.simantics.scl.ui/icons/warning.png
new file mode 100644 (file)
index 0000000..628cf2d
Binary files /dev/null and b/bundles/org.simantics.scl.ui/icons/warning.png differ
index ca35872ec3505a9dc874ce40c4dc86f64a2e6783..a408e7f30ae3b745fd72ad7f3bd476933cb4ba67 100644 (file)
@@ -33,6 +33,7 @@ public class Activator extends AbstractUIPlugin {
         reg.put("find", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/find.png") );
         reg.put("disk", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/disk.png") );
         reg.put("error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/error.png") );
+        reg.put("warning", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/warning.png") );
     }
     
     @Override
index e432a179aa2a9258b440271210ae34f29417197e..b8010ef828a23868ba0b24b7820c53be38ef2dfa 100644 (file)
@@ -9,9 +9,12 @@ import org.eclipse.jface.text.Position;
 import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.jface.text.source.AnnotationModel;
 import org.simantics.scl.compiler.errors.CompilationError;
+import org.simantics.scl.compiler.errors.DoesNotExist;
+import org.simantics.scl.compiler.errors.ErrorSeverity;
 import org.simantics.scl.compiler.errors.Failable;
 import org.simantics.scl.compiler.errors.Failure;
 import org.simantics.scl.compiler.errors.Locations;
+import org.simantics.scl.compiler.errors.Success;
 import org.simantics.scl.compiler.module.Module;
 import org.simantics.scl.compiler.module.repository.ModuleRepository;
 import org.simantics.scl.compiler.module.repository.UpdateListener;
@@ -41,17 +44,21 @@ public class SCLAnnotationModel extends AnnotationModel {
             Failure failure = (Failure)result;
             setAnnotations(Arrays.asList(failure.errors));
         }
-        else {
+        else if(result == DoesNotExist.INSTANCE)
             setAnnotations(Collections.<CompilationError>emptyList());
-        }
+        else
+            setAnnotations(Arrays.asList(result.getResult().getWarnings()));
     }
     
     protected void setAnnotations(List<CompilationError> errors) {
         synchronized(getLockObject()) {
             removeAllAnnotations();
             for(CompilationError error : errors) {
-                Annotation annotation = new Annotation("org.eclipse.ui.workbench.texteditor.error", true,
-                        error.description);
+                Annotation annotation = new Annotation(
+                        error.severity == ErrorSeverity.ERROR ?
+                                "org.eclipse.ui.workbench.texteditor.error" :
+                                    "org.eclipse.ui.workbench.texteditor.warning",
+                                    true, error.description);
                 int begin = Locations.beginOf(error.location);
                 int end = Locations.endOf(error.location);
                 Position position = new Position(begin, end - begin);
index 7a5daffdbee0716670932e1358a3f227cf2f8dc4..4772ad5ba7996b89baa875c4cf24db9e70e940e4 100644 (file)
@@ -9,6 +9,7 @@ import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Control;
 import org.simantics.scl.compiler.errors.CompilationError;
+import org.simantics.scl.compiler.errors.DoesNotExist;
 import org.simantics.scl.compiler.errors.Failable;
 import org.simantics.scl.compiler.errors.Failure;
 import org.simantics.scl.compiler.module.Module;
@@ -28,7 +29,7 @@ public class SCLIssuesContentProvider implements IStructuredContentProvider {
     boolean disposed = false;
     AtomicBoolean refreshInProgress = new AtomicBoolean(false);
     
-    THashMap<String, Failure> currentFailures = new THashMap<String, Failure>();
+    THashMap<String, CompilationError[]> currentFailures = new THashMap<String, CompilationError[]>();
     THashMap<String, UpdateListener> updateListeners = new THashMap<String, UpdateListener>(); 
     
     @Override
@@ -64,11 +65,22 @@ public class SCLIssuesContentProvider implements IStructuredContentProvider {
         synchronized(currentFailures) {
             if(result instanceof Failure) {
                 Failure failure = (Failure)result;
-                currentFailures.put(moduleName, failure);
+                currentFailures.put(moduleName, failure.errors);
             }
-            else
+            else if(result == DoesNotExist.INSTANCE) {
                 if(currentFailures.remove(moduleName) == null)
                     return;
+            }
+            else {
+                CompilationError[] warnings = result.getResult().getWarnings();
+                if(warnings.length == 0) {
+                    if(currentFailures.remove(moduleName) == null)
+                        return;
+                }
+                else {
+                    currentFailures.put(moduleName, warnings);
+                }
+            }
         }
         refresh();
     }
@@ -133,8 +145,8 @@ public class SCLIssuesContentProvider implements IStructuredContentProvider {
             String[] moduleNames = currentFailures.keySet().toArray(new String[currentFailures.size()]);
             Arrays.sort(moduleNames);
             for(String moduleName : moduleNames) {
-                Failure failure = currentFailures.get(moduleName);
-                for(CompilationError error : failure.errors)
+                CompilationError[] errors = currentFailures.get(moduleName);
+                for(CompilationError error : errors)
                     result.add(new SCLIssuesTableEntry(moduleName, error));
                 if(result.size() >= MAX_ISSUE_COUNT)
                     break;
index 74e01066b36400c0fe6cc902c4829992c6c77dd2..2b49dd125b993c01afed536a8dff510ac73af6ce 100644 (file)
@@ -16,7 +16,10 @@ public class SCLIssuesTableEntry implements Comparable<SCLIssuesTableEntry> {
     public int compareTo(SCLIssuesTableEntry o) {
         if(this == o)
             return 0;
-        int cmp = moduleName.compareTo(o.moduleName);
+        int cmp = error.severity.compareTo(o.error.severity);
+        if(cmp != 0)
+            return cmp;
+        cmp = moduleName.compareTo(o.moduleName);
         if(cmp != 0)
             return cmp;
         cmp = Locations.compare(error.location, o.error.location);
index 112a5f4712e96c7aa054370964f9b232ea979f05..b4fd1edd8a1c8fdad594ff86e6a6b610f8b5abcb 100644 (file)
@@ -24,6 +24,7 @@ import org.eclipse.ui.IMemento;
 import org.eclipse.ui.IViewSite;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.ViewPart;
+import org.simantics.scl.compiler.errors.ErrorSeverity;
 import org.simantics.scl.osgi.SCLOsgi;
 import org.simantics.scl.ui.Activator;
 import org.simantics.scl.ui.editor2.OpenSCLDefinition;
@@ -86,7 +87,10 @@ public class SCLIssuesView extends ViewPart {
             }
             @Override
             public Image getImage(Object element) {
-                return imageRegistry.get("error");
+                SCLIssuesTableEntry entry = (SCLIssuesTableEntry)element;
+                return entry.error.severity == ErrorSeverity.ERROR
+                        ? imageRegistry.get("error")
+                        : imageRegistry.get("warning");
             }
         });