protected void insertCompilationUnitMessages(boolean insertErrors, IList otherMessages) { org.rascalmpl.value.type.Type args = TF.tupleType(TF.stringType(), TF.sourceLocationType()); IValueList result = new IValueList(values); if (otherMessages != null) { for (IValue message : otherMessages) { result.add(message); } } if (insertErrors) { int i; IProblem[] problems = compilUnit.getProblems(); for (i = 0; i < problems.length; i++) { int offset = problems[i].getSourceStart(); int length = problems[i].getSourceEnd() - offset + 1; int sl = problems[i].getSourceLineNumber(); ISourceLocation pos = values.sourceLocation(loc, offset, length, sl, sl, 0, 0); org.rascalmpl.value.type.Type constr; if (problems[i].isError()) { constr = typeStore.lookupConstructor( this.typeStore.lookupAbstractDataType("Message"), "error", args); } else { constr = typeStore.lookupConstructor( this.typeStore.lookupAbstractDataType("Message"), "warning", args); } result.add(values.constructor(constr, values.string(problems[i].getMessage()), pos)); } } setAnnotation("messages", result.asList()); }
protected IValueList parseModifiers(int modifiers) { IValueList extendedModifierList = new IValueList(values); for (String constructor : java.lang.reflect.Modifier.toString(modifiers).split(" ")) { Set<org.rascalmpl.value.type.Type> exConstr = typeStore.lookupConstructor(DATATYPE_RASCAL_AST_MODIFIER_NODE_TYPE, constructor); for (org.rascalmpl.value.type.Type con : exConstr) { extendedModifierList.add(values.constructor(con)); } } return extendedModifierList; }
@SuppressWarnings({"rawtypes"}) protected IValueList parseExtendedModifiers(List ext) { IValueList extendedModifierList = new IValueList(values); for (Iterator it = ext.iterator(); it.hasNext(); ) { ASTNode p = (ASTNode) it.next(); IValue val = visitChild(p); if (p instanceof Annotation) { val = constructModifierNode("annotation", val); } extendedModifierList.add(val); } return extendedModifierList; }
protected void setAnnotation(String annoName, IValueList annoList) { IList annos = (IList) annoList.asList(); if (this.ownValue == null) { return; } if (annoList != null && this.ownValue.getType().declaresAnnotation(this.typeStore, annoName) && !annos.isEmpty()) { this.ownValue = ((IConstructor) this.ownValue).asAnnotatable().setAnnotation(annoName, annos); } }