private RefactoringStatus mappingErrorFound(RefactoringStatus result, ASTNode node) { if (node != null && (node.getFlags() & ASTNode.MALFORMED) != 0 && processCompilerError(result, node)) return result; result.addFatalError(getMappingErrorMessage()); return result; }
/* * @see edu.berkeley.eduride.isa.corext.dom.GenericVisitor#visitNode(org.eclipse.jdt.core.dom.ASTNode) */ protected boolean visitNode(ASTNode node) { if ((node.getFlags() & ASTNode.MALFORMED) == ASTNode.MALFORMED) { retainPositions(node.getStartPosition(), node.getLength()); return false; } return true; }
public static void setIsGeneratedFlag( org.eclipse.jdt.core.dom.ASTNode domNode, org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode) throws Exception { if (internalNode == null || domNode == null) return; boolean isGenerated = internalNode.getClass().getField("$generatedBy").get(internalNode) != null; if (isGenerated) { domNode.getClass().getField("$isGenerated").set(domNode, true); domNode.setFlags(domNode.getFlags() & ~org.eclipse.jdt.core.dom.ASTNode.ORIGINAL); } }
protected ISourceLocation getSourceLocation(ASTNode node) { try { int nodeLength = compilUnit.getExtendedLength(node); if (nodeLength > 0) { int start = compilUnit.getExtendedStartPosition(node); int end = start + nodeLength - 1; if (end < start && ((node.getFlags() & 9) > 0)) { insert( messages, values.constructor( DATATYPE_RASCAL_MESSAGE_ERROR_NODE_TYPE, values.string("Recovered/Malformed node, guessing the length"), values.sourceLocation(loc, 0, 0))); nodeLength = node.toString().length(); end = start + nodeLength - 1; } return values.sourceLocation( loc, start, nodeLength, compilUnit.getLineNumber(start), compilUnit.getLineNumber(end), // TODO: only adding 1 at the end seems to work, need to test. compilUnit.getColumnNumber(start), compilUnit.getColumnNumber(end) + 1); } } catch (IllegalArgumentException e) { insert( messages, values.constructor( DATATYPE_RASCAL_MESSAGE_ERROR_NODE_TYPE, values.string("Most probably missing dependency"), values.sourceLocation(loc, 0, 0))); } return values.sourceLocation(loc, 0, 0, 0, 0, 0, 0); }