forked from jasder/antlr
Merge branch 'ModelElement'
This commit is contained in:
commit
8b4a461262
|
@ -30,6 +30,7 @@
|
||||||
package org.antlr.v4.codegen;
|
package org.antlr.v4.codegen;
|
||||||
|
|
||||||
import org.antlr.v4.Tool;
|
import org.antlr.v4.Tool;
|
||||||
|
import org.antlr.v4.codegen.model.ModelElement;
|
||||||
import org.antlr.v4.codegen.model.OutputModelObject;
|
import org.antlr.v4.codegen.model.OutputModelObject;
|
||||||
import org.antlr.v4.tool.ErrorType;
|
import org.antlr.v4.tool.ErrorType;
|
||||||
import org.stringtemplate.v4.*;
|
import org.stringtemplate.v4.*;
|
||||||
|
@ -94,13 +95,24 @@ public class OutputModelWalker {
|
||||||
st.add(modelArgName, omo);
|
st.add(modelArgName, omo);
|
||||||
|
|
||||||
// COMPUTE STs FOR EACH NESTED MODEL OBJECT MARKED WITH @ModelElement AND MAKE ST ATTRIBUTE
|
// COMPUTE STs FOR EACH NESTED MODEL OBJECT MARKED WITH @ModelElement AND MAKE ST ATTRIBUTE
|
||||||
|
Set<String> usedFieldNames = new HashSet<String>();
|
||||||
Field fields[] = cl.getFields();
|
Field fields[] = cl.getFields();
|
||||||
for (Field fi : fields) {
|
for (Field fi : fields) {
|
||||||
Annotation[] annotations = fi.getAnnotations();
|
ModelElement annotation = fi.getAnnotation(ModelElement.class);
|
||||||
if ( annotations.length==0 ) continue;
|
if (annotation == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String fieldName = fi.getName();
|
String fieldName = fi.getName();
|
||||||
|
|
||||||
|
if (!usedFieldNames.add(fieldName)) {
|
||||||
|
tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, "Model object " + omo.getClass().getSimpleName() + " has multiple fields named '" + fieldName + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Just don't set @ModelElement fields w/o formal arg in target ST
|
// Just don't set @ModelElement fields w/o formal arg in target ST
|
||||||
if ( formalArgs.get(fieldName)==null ) continue;
|
if ( formalArgs.get(fieldName)==null ) continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object o = fi.get(omo);
|
Object o = fi.get(omo);
|
||||||
if ( o instanceof OutputModelObject ) { // SINGLE MODEL OBJECT?
|
if ( o instanceof OutputModelObject ) { // SINGLE MODEL OBJECT?
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class LL1PlusBlock extends LL1Loop {
|
||||||
public String loopCounterVar;
|
public String loopCounterVar;
|
||||||
public String[] exitLook;
|
public String[] exitLook;
|
||||||
|
|
||||||
@ModelElement public SrcOp loopExpr;
|
|
||||||
@ModelElement public ThrowNoViableAlt error;
|
@ModelElement public ThrowNoViableAlt error;
|
||||||
|
|
||||||
public LL1PlusBlock(OutputModelFactory factory, GrammarAST plusRoot, List<CodeBlockForAlt> alts) {
|
public LL1PlusBlock(OutputModelFactory factory, GrammarAST plusRoot, List<CodeBlockForAlt> alts) {
|
||||||
|
|
Loading…
Reference in New Issue