package hu.elte.txtuml.validation.model;

import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TypeDeclaration;

import hu.elte.txtuml.validation.common.AbstractValidationError;
import hu.elte.txtuml.validation.common.SourceInfo;

/**
 * Base class for all JtxtUML model validation errors.
 */
public abstract class ModelValidationError extends AbstractValidationError {

	public ModelValidationError(SourceInfo sourceInfo, ASTNode node) {
		super(sourceInfo, node);
		Class<?> c = ASTNode.nodeClassForType(node.getNodeType());
		if (c == MethodDeclaration.class || c == TypeDeclaration.class) {
			SimpleName name;
			if (c == MethodDeclaration.class) {
				name = ((MethodDeclaration) node).getName();
			} else {
				name = ((TypeDeclaration) node).getName();
			}
			this.sourceStart = name.getStartPosition();
			this.sourceEnd = name.getStartPosition() + name.getLength();
		}

	}

	@Override
	public String getMarkerType() {
		return JtxtUMLModelCompilationParticipant.JTXTUML_MODEL_MARKER_TYPE;
	}

	@Override
	public String toString() {
		return getType() + " (" + getMessage() + ")";
	}

}

@@ -581,109 +581,64 @@
 ;%0A%09%09
-Class%3C?%3E c = ASTNode.nodeClassForType(node.getNodeType());%0A%09%09if (c == MethodDeclaration.class %7C%7C c ==
+if (node instanceof MethodDeclaration %7C%7C node instanceof
  Typ
@@ -645,30 +645,24 @@
 eDeclaration
-.class
 ) %7B%0A%09%09%09Simpl
@@ -684,12 +684,23 @@
 if (
-c ==
+node instanceof
  Met
@@ -717,14 +717,8 @@
 tion
-.class
 ) %7B%0A

Replace class equality test with instanceof