Bug 577414: [Ltk] Add StatusCodes

Change-Id: I4808adc53091206ad13cc0e4b07b23a4a6a8088c
diff --git a/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/ast/core/Asts.java b/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/ast/core/Asts.java
index 30b79ee..922377b 100644
--- a/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/ast/core/Asts.java
+++ b/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/ast/core/Asts.java
@@ -16,6 +16,8 @@
 
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 
+import org.eclipse.statet.ltk.core.StatusCodes;
+
 
 @NonNullByDefault
 public class Asts {
@@ -30,4 +32,11 @@
 	}
 	
 	
+	public static boolean hasErrors(final AstNode node) {
+		return ((node.getStatusCode() &
+						(StatusCodes.ERROR | StatusCodes.ERROR_IN_CHILD)
+				) != 0 );
+	}
+	
+	
 }
diff --git a/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/core/StatusCodes.java b/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/core/StatusCodes.java
new file mode 100644
index 0000000..6ea8856
--- /dev/null
+++ b/ltk/org.eclipse.statet.ltk.core/src/org/eclipse/statet/ltk/core/StatusCodes.java
@@ -0,0 +1,64 @@
+/*=============================================================================#
+ # Copyright (c) 2021 Stephan Wahlbrink and others.
+ # 
+ # This program and the accompanying materials are made available under the
+ # terms of the Eclipse Public License 2.0 which is available at
+ # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
+ # which is available at https://www.apache.org/licenses/LICENSE-2.0.
+ # 
+ # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
+ # 
+ # Contributors:
+ #     Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
+ #=============================================================================*/
+
+package org.eclipse.statet.ltk.core;
+
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+
+
+@NonNullByDefault
+public class StatusCodes {
+	
+	
+	public static final int SHIFT_SEVERITY=                 20;
+	public static final int SHIFT_SEVERITY_IN_CHILD=        24;
+	public static final int SHIFT_CTX1=                     16;
+	public static final int SHIFT_CTX2=                     12;
+	public static final int SHIFT_TYPE1=                     8;
+	public static final int SHIFT_TYPE2=                     4;
+	public static final int SHIFT_TYPE3=                     0;
+	
+	public static final int SEVERITY=                       0b111 << SHIFT_SEVERITY;
+	public static final int INFO=                           Status.INFO << SHIFT_SEVERITY;
+	public static final int WARNING=                        Status.WARNING << SHIFT_SEVERITY;
+	public static final int ERROR=                          Status.ERROR << SHIFT_SEVERITY;
+	
+	public static final int SUBSEQUENT=                     0b1 << SHIFT_SEVERITY + 3;
+	
+	public static final int SEVERITY_IN_CHILD=              SEVERITY << SHIFT_SEVERITY_IN_CHILD - SHIFT_SEVERITY;
+	public static final int WARNING_IN_CHILD=               WARNING << SHIFT_SEVERITY_IN_CHILD - SHIFT_SEVERITY;
+	public static final int ERROR_IN_CHILD=                 ERROR << SHIFT_SEVERITY_IN_CHILD - SHIFT_SEVERITY;
+	
+	public static final int CTX1=                           0xF << SHIFT_CTX1;
+	public static final int CTX2=                           0xF << SHIFT_CTX2;
+	public static final int CTX12=                          CTX1 | CTX2;
+	
+	public static final int TYPE1=                          0xF << SHIFT_TYPE1;
+	public static final int TYPE2=                          0xF << SHIFT_TYPE2;
+	public static final int TYPE3=                          0xF << SHIFT_TYPE3;
+	public static final int TYPE12=                         TYPE1 | TYPE2 | SEVERITY;
+	public static final int TYPE123=                        TYPE12 | TYPE3;
+	
+	
+	public static final int TYPE1_OK=                       0x0 << SHIFT_TYPE1;
+	public static final int TYPE1_SYNTAX_INCORRECT_TOKEN=   0x1 << SHIFT_TYPE1;
+	public static final int TYPE1_RUNTIME_ERROR=            0xF << SHIFT_TYPE1;
+	
+	
+	private StatusCodes() {
+	}
+	
+}