X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ferrors%2FCompilationError.java;h=a26823fe88a6ba31d3ebf89c603d6cf85524fc12;hp=5f2aff156f29f1c1f8b4d45af3e9f7d13aea4b2d;hb=84b211a0aa05c956d33e038a1106bb0464ce373a;hpb=b35573372259ace60d8827766fe41443f4c57629 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/CompilationError.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/CompilationError.java index 5f2aff156..a26823fe8 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/CompilationError.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/CompilationError.java @@ -1,80 +1,86 @@ -package org.simantics.scl.compiler.errors; - -import java.io.PrintWriter; -import java.io.StringWriter; - -public class CompilationError implements Comparable { - - public static final CompilationError[] EMPTY_ARRAY = new CompilationError[0]; - - public final long location; - public final String description; - - public CompilationError(long location, String description) { - if(description == null) - throw new NullPointerException(); - this.location = location; - this.description = description; - } - - public CompilationError(long location, Exception exception) { - this(location, exceptionToString(exception)); - } - - public CompilationError(String description) { - this(Locations.NO_LOCATION, description); - } - - public CompilationError(Exception exception) { - this(Locations.NO_LOCATION, exception); - } - - private static String exceptionToString(Exception e) { - StringWriter w = new StringWriter(); - e.printStackTrace(new PrintWriter(w)); - return w.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((description == null) ? 0 : description.hashCode()); - result = prime * result + (int) (location ^ (location >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CompilationError other = (CompilationError) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (location != other.location) - return false; - return true; - } - - @Override - public int compareTo(CompilationError o) { - if(location < o.location) - return -1; - if(location > o.location) - return 1; - return description.compareTo(o.description); - } - - @Override - public String toString() { - return new StringBuilder().append("CompilationError: \"").append(description).append("\" at location ").append(location).toString(); - } -} +package org.simantics.scl.compiler.errors; + +import java.io.PrintWriter; +import java.io.StringWriter; + +public class CompilationError implements Comparable { + + public static final CompilationError[] EMPTY_ARRAY = new CompilationError[0]; + + public final long location; + public final String description; + public final ErrorSeverity severity; + + 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)); + } + + public CompilationError(String description) { + this(Locations.NO_LOCATION, description); + } + + public CompilationError(Exception exception) { + this(Locations.NO_LOCATION, exception); + } + + private static String exceptionToString(Exception e) { + StringWriter w = new StringWriter(); + e.printStackTrace(new PrintWriter(w)); + return w.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + (int) (location ^ (location >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CompilationError other = (CompilationError) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (location != other.location) + return false; + return true; + } + + @Override + public int compareTo(CompilationError o) { + if(location < o.location) + return -1; + if(location > o.location) + return 1; + return description.compareTo(o.description); + } + + @Override + public String toString() { + return new StringBuilder().append("CompilationError: \"").append(description).append("\" at location ").append(location).toString(); + } +}