package jetbrains.mps.ide.java.newparser; /*Generated by MPS */ import org.apache.log4j.Logger; import org.apache.log4j.LogManager; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import java.util.List; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import java.util.Map; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.internal.collections.runtime.MapSequence; import java.util.HashMap; import org.eclipse.jdt.internal.compiler.ast.Statement; import org.eclipse.jdt.internal.compiler.ast.AssertStatement; import org.eclipse.jdt.internal.compiler.ast.Block; import org.eclipse.jdt.internal.compiler.ast.BreakStatement; import org.eclipse.jdt.internal.compiler.ast.ContinueStatement; import org.eclipse.jdt.internal.compiler.ast.DoStatement; import org.eclipse.jdt.internal.compiler.ast.EmptyStatement; import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.ForStatement; import org.eclipse.jdt.internal.compiler.ast.ForeachStatement; import org.eclipse.jdt.internal.compiler.ast.IfStatement; import org.eclipse.jdt.internal.compiler.ast.LabeledStatement; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement; import org.eclipse.jdt.internal.compiler.ast.ThrowStatement; import org.eclipse.jdt.internal.compiler.ast.TryStatement; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.WhileStatement; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import org.eclipse.jdt.internal.compiler.ast.Initializer; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import org.eclipse.jdt.internal.compiler.ast.CaseStatement; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import org.jetbrains.mps.openapi.language.SAbstractConcept; import jetbrains.mps.smodel.behaviour.BHReflection; import jetbrains.mps.core.aspects.behaviour.SMethodTrimmedId; import jetbrains.mps.internal.collections.runtime.Sequence; import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.jetbrains.mps.openapi.persistence.PersistenceFacade; import jetbrains.mps.smodel.SModelUtil_new; import org.jetbrains.mps.openapi.model.SNodeAccessUtil; import jetbrains.mps.lang.typesystem.runtime.HUtil; public class FullASTConverter extends ASTConverterWithExpressions { private Logger LOG = LogManager.getLogger(FullASTConverter.class); private CompilationUnitDeclaration myCud; private List<FullASTConverter.CodeBlock> myBlocks = ListSequence.fromList(new ArrayList<FullASTConverter.CodeBlock>()); private Map<SNode, Integer> myPositions = MapSequence.fromMap(new HashMap<SNode, Integer>()); public FullASTConverter(CompilationUnitDeclaration cud) { super(false); } private FullASTConverter(FullASTConverter base) { super(base); } public SNode convertStatementWrap(Statement x) throws JavaParseException { SNode stmt = convertStatement(x); if ((stmt != null)) { MapSequence.fromMap(myPositions).put(stmt, x.sourceEnd()); } return stmt; } public SNode convertStatement(Statement x) throws JavaParseException { if (x instanceof AssertStatement) { return convertStatement((AssertStatement) x); } else if (x instanceof Block) { return convertStatement((Block) x); } else if (x instanceof BreakStatement) { return convertStatement((BreakStatement) x); } else if (x instanceof ContinueStatement) { return convertStatement((ContinueStatement) x); } else if (x instanceof DoStatement) { return convertStatement((DoStatement) x); } else if (x instanceof EmptyStatement) { return convertStatement((EmptyStatement) x); } else if (x instanceof ExplicitConstructorCall) { return convertStatement((ExplicitConstructorCall) x); } else if (x instanceof Expression) { return convertStatement((Expression) x); } else if (x instanceof ForStatement) { return convertStatement((ForStatement) x); } else if (x instanceof ForeachStatement) { return convertStatement((ForeachStatement) x); } else if (x instanceof IfStatement) { return convertStatement((IfStatement) x); } else if (x instanceof LabeledStatement) { return convertStatement((LabeledStatement) x); } else if (x instanceof LocalDeclaration) { return convertStatement((LocalDeclaration) x); } else if (x instanceof ReturnStatement) { return convertStatement((ReturnStatement) x); } else if (x instanceof SwitchStatement) { return convertStatement((SwitchStatement) x); } else if (x instanceof SynchronizedStatement) { return convertStatement((SynchronizedStatement) x); } else if (x instanceof ThrowStatement) { return convertStatement((ThrowStatement) x); } else if (x instanceof TryStatement) { return convertStatement((TryStatement) x); } else if (x instanceof TypeDeclaration) { return convertStatement((TypeDeclaration) x); } else if (x instanceof WhileStatement) { return convertStatement((WhileStatement) x); } else { return null; } } @Override protected void handleMethodBody(SNode result, AbstractMethodDeclaration x) throws JavaParseException { convertStatementsInto(x, SLinkOperations.getTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1ffL, "body"))); } @Override public SNode convertInitializer(Initializer x) throws JavaParseException { SNode block = convertStatement(x.block); if (block == null) { return null; } SNode result; if (flagSet(x.modifiers, ClassFileConstants.AccStatic)) { SNode initCode = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11c7538039dL, "jetbrains.mps.baseLanguage.structure.StaticInitializer")); SLinkOperations.setTarget(initCode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11c7538039dL, 0x11c7538039eL, "statementList"), SLinkOperations.getTarget(block, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, 0xfc092b6b78L, "statements"))); result = initCode; } else { SNode initCode = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x118f0b909f7L, "jetbrains.mps.baseLanguage.structure.InstanceInitializer")); SLinkOperations.setTarget(initCode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x118f0b909f7L, 0x118f0b95a3bL, "statementList"), SLinkOperations.getTarget(block, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, 0xfc092b6b78L, "statements"))); result = initCode; } return result; } @Override protected SNode convertEnumConst(FieldDeclaration x) throws JavaParseException { SNode constr = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b204L, "jetbrains.mps.baseLanguage.structure.ConstructorDeclaration")); // TODO SNode enm = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367388b3L, "jetbrains.mps.baseLanguage.structure.EnumConstantDeclaration")); SPropertyOperations.set(enm, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), enumConstantName(x)); // arguments of enum constant Expression[] args = ((AllocationExpression) x.initialization).arguments; if (args != null) { for (Expression arg : args) { ListSequence.fromList(SLinkOperations.getChildren(enm, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301aeL, "actualArgument"))).addElement(convertExpression(arg)); } } return enm; } public List<SNode> convertStatements(Statement[] ss) throws JavaParseException { List<SNode> result = new ArrayList<SNode>(); if (ss != null) { for (Statement stmt : ss) { SNode statement = convertStatementWrap(stmt); if (statement != null) { result.add(statement); } } } return result; } public void convertStatementsInto(AbstractMethodDeclaration x, SNode bodyInto) throws JavaParseException { addBlock(bodyInto, x.declarationSourceStart, x.declarationSourceEnd); List<SNode> stmts = convertStatements(x.statements); if (x instanceof ConstructorDeclaration) { ExplicitConstructorCall cntrCall = ((ConstructorDeclaration) x).constructorCall; if (cntrCall != null) { SNode firstCntrCall = convertStatement(cntrCall); if (firstCntrCall != null) { ListSequence.fromList(stmts).insertElement(0, firstCntrCall); } } } ListSequence.fromList(SLinkOperations.getChildren(bodyInto, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"))).addSequence(ListSequence.fromList(stmts)); } /*package*/ List<SNode> convertExpressionStatements(Statement[] statements) throws JavaParseException { List<SNode> expressionStatements = new ArrayList<SNode>(); if (statements != null) { for (int i = 0, n = statements.length; i < n; ++i) { SNode statement = convertStatementWrap(statements[i]); if ((statement != null)) { ListSequence.fromList(expressionStatements).addElement(SNodeOperations.cast(statement, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b213L, "jetbrains.mps.baseLanguage.structure.ExpressionStatement"))); } } } return expressionStatements; } /*package*/ SNode convertStatement(Expression x) throws JavaParseException { SNode stmt = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b213L, "jetbrains.mps.baseLanguage.structure.ExpressionStatement")); SLinkOperations.setTarget(stmt, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b213L, 0xf8cc56b214L, "expression"), convertExpressionWrap(x)); return stmt; } /*package*/ SNode convertStatement(AssertStatement x) throws JavaParseException { SNode expr = convertExpressionWrap(x.assertExpression); SNode arg = convertExpressionWrap(x.exceptionArgument); SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10e50ecba3dL, "jetbrains.mps.baseLanguage.structure.AssertStatement")); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10e50ecba3dL, 0x10e50ed44ceL, "condition"), expr); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10e50ecba3dL, 0x10e50ed92e0L, "message"), arg); return result; } /*package*/ SNode convertStatement(Block x) throws JavaParseException { if (x == null) { return null; } SNode blockStatement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, "jetbrains.mps.baseLanguage.structure.BlockStatement")); SNode statementList = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, "jetbrains.mps.baseLanguage.structure.StatementList")); SLinkOperations.setTarget(blockStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, 0xfc092b6b78L, "statements"), statementList); addBlock(statementList, x.sourceStart(), x.sourceEnd()); ListSequence.fromList(SLinkOperations.getChildren(statementList, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"))).addSequence(ListSequence.fromList(convertStatements(x.statements))); return blockStatement; } /*package*/ SNode convertStatement(BreakStatement x) { SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, "jetbrains.mps.baseLanguage.structure.BreakStatement")); if (x.label != null) { SPropertyOperations.set(result, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x11745bfb2d8L, "label"), new String(x.label)); } return result; } /*package*/ SNode convertStatement(SwitchStatement x) throws JavaParseException { SNode expression = convertExpressionWrap(x.expression); SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, "jetbrains.mps.baseLanguage.structure.SwitchStatement")); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02ec241L, "expression"), expression); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02c1b6eL, "defaultBlock"), SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, "jetbrains.mps.baseLanguage.structure.StatementList"))); // defaultCase is not set for me. Maybe eclipse sets it after resolving work if (x.statements != null) { SNode currentSwitchCase = null; for (Statement stmt : x.statements) { if (stmt instanceof CaseStatement) { // advance end of previous case block if ((currentSwitchCase != null)) { getBlock(currentSwitchCase).setEndPos(stmt.sourceStart); } CaseStatement caseStatement = (CaseStatement) stmt; if (caseStatement.constantExpression == null) { currentSwitchCase = SLinkOperations.getTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02c1b6eL, "defaultBlock")); addBlock(SLinkOperations.getTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02c1b6eL, "defaultBlock")), caseStatement.sourceStart, caseStatement.sourceEnd); } else { SNode switchCase = convertCaseStatement((CaseStatement) stmt); if ((switchCase != null)) { ListSequence.fromList(SLinkOperations.getChildren(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02edcafL, "case"))).addElement(switchCase); } currentSwitchCase = ((switchCase == null) ? null : SLinkOperations.getTarget(switchCase, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, 0x10ef02d8048L, "body"))); } } else if ((currentSwitchCase != null)) { // advance end of case block getBlock(currentSwitchCase).setEndPos(stmt.sourceEnd); ListSequence.fromList(SLinkOperations.getChildren(currentSwitchCase, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"))).addElement(convertStatementWrap(stmt)); } } // adjust end of last case block up to the end of switch statement if ((currentSwitchCase != null)) { getBlock(currentSwitchCase).setEndPos(x.sourceEnd); } } return result; } /*package*/ SNode convertCaseStatement(CaseStatement x) throws JavaParseException { SNode expression = convertExpressionWrap(x.constantExpression); SNode switchCase = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, "jetbrains.mps.baseLanguage.structure.SwitchCase")); SLinkOperations.setTarget(switchCase, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, 0x10ef02d67cfL, "expression"), expression); SLinkOperations.setTarget(switchCase, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, 0x10ef02d8048L, "body"), SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, "jetbrains.mps.baseLanguage.structure.StatementList"))); addBlock(SLinkOperations.getTarget(switchCase, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, 0x10ef02d8048L, "body")), x.sourceStart(), x.sourceEnd()); return switchCase; } /*package*/ SNode convertStatement(ContinueStatement x) { SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbf3043726L, "jetbrains.mps.baseLanguage.structure.ContinueStatement")); if (x.label != null) { // using new labels is commented out for now, something seems to be wrong with their scopes SPropertyOperations.set(result, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbf3043726L, 0x11745fca58eL, "label"), new String(x.label)); } return result; } /*package*/ SNode convertStatement(DoStatement x) throws JavaParseException { SNode loopTest = convertExpressionWrap(x.condition); SNode loopBody = convertStatementWrap(x.action); SNode doWhileStatement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, "jetbrains.mps.baseLanguage.structure.DoWhileStatement")); SLinkOperations.setTarget(doWhileStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, 0x11232679422L, "condition"), loopTest); SNode body = getStatementListFromStatement(loopBody, x.action); SLinkOperations.setTarget(doWhileStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), body); return doWhileStatement; } /*package*/ SNode convertStatement(EmptyStatement x) { return SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b215L, "jetbrains.mps.baseLanguage.structure.Statement")); } /*package*/ SNode convertStatement(LocalDeclaration x) throws JavaParseException { SNode decl = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7efL, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclaration")); SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement")); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, 0xf8cc67c7f1L, "localVariableDeclaration"), decl); SPropertyOperations.set(decl, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, 0x111f9e9f00cL, "isFinal"), "" + (flagSet(x.modifiers, ClassFileConstants.AccFinal))); SLinkOperations.setTarget(decl, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type"), convertTypeReference(x.type)); SPropertyOperations.set(decl, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), new String(x.name)); SLinkOperations.setTarget(decl, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, 0xf8c37f506eL, "initializer"), convertExpressionWrap(x.initialization)); return result; } /*package*/ SNode convertStatement(ReturnStatement x) throws JavaParseException { SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, "jetbrains.mps.baseLanguage.structure.ReturnStatement")); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, 0xf8cc6bf96cL, "expression"), convertExpressionWrap(x.expression)); return result; } /*package*/ SNode convertStatement(ExplicitConstructorCall x) throws JavaParseException { if (x.isImplicitSuper()) { return null; } SNode unkCall = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x7e4a5cff51167b74L, "jetbrains.mps.baseLanguage.structure.UnknownConsCall")); addCallArgs(unkCall, x.arguments); SPropertyOperations.set(unkCall, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x7e4a5cff51167b74L, 0x7e4a5cff51167ce2L, "isSuper"), "" + (x.isSuperAccess())); if (1 == 1) { return unkCall; } return unkCall; } /*package*/ SNode convertStatement(ForeachStatement x) throws JavaParseException { SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a6933ce33L, "jetbrains.mps.baseLanguage.structure.ForeachStatement")); SNode action = convertStatementWrap(x.action); SNode body = getStatementListFromStatement(action, x.action); SNode elementVar = SLinkOperations.getTarget(SNodeOperations.cast(convertStatement(x.elementVariable), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement")), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, 0xf8cc67c7f1L, "localVariableDeclaration")); SNode iterable = convertExpressionWrap(x.collection); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a6933ce33L, 0x10a6934ab66L, "iterable"), iterable); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a697996feL, 0x10a6979f36bL, "variable"), elementVar); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), body); return result; } /*package*/ SNode convertStatement(ForStatement x) throws JavaParseException { SNode forStatement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a698082feL, "jetbrains.mps.baseLanguage.structure.ForStatement")); List<SNode> init = convertStatements(x.initializations); SNode result = forStatement; if (ListSequence.fromList(init).any(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SNodeOperations.isInstanceOf(it, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b213L, "jetbrains.mps.baseLanguage.structure.ExpressionStatement")); } })) { // we don't support for ( a=5, b=6; ...) {} in baseLanguage, workaround here result = _quotation_createNode_f46ocm_a0b0d0gb(init, forStatement); } else if (!(init.isEmpty())) { boolean first = true; for (SNode statement : init) { if (SNodeOperations.isInstanceOf(statement, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement"))) { SNode lvds = SNodeOperations.cast(statement, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement")); SNode variableDeclaration = SLinkOperations.getTarget(lvds, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, 0xf8cc67c7f1L, "localVariableDeclaration")); if (first) { SLinkOperations.setTarget(forStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a697996feL, 0x10a6979f36bL, "variable"), variableDeclaration); first = false; } else { SNode additionalForLoopVariable = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x19659b074928781eL, "jetbrains.mps.baseLanguage.structure.AdditionalForLoopVariable")); SPropertyOperations.set(additionalForLoopVariable, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), SPropertyOperations.getString(variableDeclaration, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"))); SNode inititalizer = SLinkOperations.getTarget(variableDeclaration, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, 0xf8c37f506eL, "initializer")); if ((inititalizer != null)) { SLinkOperations.setTarget(additionalForLoopVariable, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, 0xf8c37f506eL, "initializer"), inititalizer); } SNode typeCandidate = SLinkOperations.getTarget(SLinkOperations.getTarget(forStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a697996feL, 0x10a6979f36bL, "variable")), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")); if ((typeCandidate != null)) { SLinkOperations.setTarget(additionalForLoopVariable, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type"), SNodeOperations.copyNode(typeCandidate)); } ListSequence.fromList(SLinkOperations.getChildren(forStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a698082feL, 0xe5318742b9d1411L, "additionalVar"))).addElement(additionalForLoopVariable); } } } } SNode expr = convertExpressionWrap(x.condition); SLinkOperations.setTarget(forStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a698082feL, 0x10a69819132L, "condition"), expr); List<SNode> incr = convertExpressionStatements(x.increments); if (!(incr.isEmpty())) { for (SNode expressionStatement : incr) { SNode expression = SLinkOperations.getTarget(expressionStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b213L, 0xf8cc56b214L, "expression")); SNodeOperations.deleteNode(expression); ListSequence.fromList(SLinkOperations.getChildren(forStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a698082feL, 0x10a6981b2c5L, "iteration"))).addElement(expression); } } SNode loopBody = convertStatementWrap(x.action); SNode body = getStatementListFromStatement(loopBody, x.action); SLinkOperations.setTarget(forStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), body); return result; } /*package*/ SNode convertStatement(IfStatement x) throws JavaParseException { SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, "jetbrains.mps.baseLanguage.structure.IfStatement")); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b218L, "condition"), convertExpressionWrap(x.condition)); SNode thenStmt = convertStatementWrap(x.thenStatement); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xfc092b6b76L, "ifFalseStatement"), convertStatementWrap(x.elseStatement)); SNode ifTrue = getStatementListFromStatement(thenStmt, x.thenStatement); // adjust start of the "if" statement list block to get comments from "if (...)" there getBlock(ifTrue).setStartPos(x.sourceStart); // replacing the ifTrue node SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b219L, "ifTrue"), ifTrue); return result; } /*package*/ SNode convertStatement(LabeledStatement x) throws JavaParseException { SNode statement = convertStatementWrap(x.statement); if ((statement == null)) { return null; } if (x.statement instanceof ForStatement) { // we do a trick to get our resulting mps LoopStatement here // because it could be converted into BlockStatement with the real loop inside SNode loopStatement = ListSequence.fromList(SNodeOperations.getNodeDescendants(statement, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, "jetbrains.mps.baseLanguage.structure.AbstractLoopStatement"), true, new SAbstractConcept[]{})).first(); if ((loopStatement == null)) { return null; } SNode label = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x50c493bf9552f6aL, "jetbrains.mps.baseLanguage.structure.LoopLabel")); SPropertyOperations.set(label, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), new String(x.label)); SLinkOperations.setTarget(loopStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel"), label); } else if (SNodeOperations.isInstanceOf(statement, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, "jetbrains.mps.baseLanguage.structure.SwitchStatement"))) { SNode switchStatement = SNodeOperations.cast(statement, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, "jetbrains.mps.baseLanguage.structure.SwitchStatement")); SNode label = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x50c493bf9552f6aL, "jetbrains.mps.baseLanguage.structure.LoopLabel")); SPropertyOperations.set(label, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), new String(x.label)); SLinkOperations.setTarget(switchStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x4091554b655a230eL, "switchLabel"), label); } return statement; } /*package*/ SNode convertStatement(SynchronizedStatement x) throws JavaParseException { SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x1106df1d8d8L, "jetbrains.mps.baseLanguage.structure.SynchronizedStatement")); SNode block = convertStatement(x.block); SNode expr = convertExpressionWrap(x.expression); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x1106df1d8d8L, 0x1106df2b910L, "expression"), expr); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x1106df1d8d8L, 0x1106df2d95cL, "block"), getStatementListFromStatement(block, x.block)); return result; } /*package*/ SNode convertStatement(ThrowStatement x) throws JavaParseException { SNode toThrow = convertExpressionWrap(x.exception); SNode throwStatement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f3ee082d8L, "jetbrains.mps.baseLanguage.structure.ThrowStatement")); SLinkOperations.setTarget(throwStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f3ee082d8L, 0x10f3ee0cd6fL, "throwable"), toThrow); return throwStatement; } /*package*/ SNode convertStatement(TryStatement x) throws JavaParseException { SNode tryBlock = convertStatement(x.tryBlock); List<SNode> catchArgs = new ArrayList<SNode>(); List<SNode> catchBlocks = new ArrayList<SNode>(); SNode finallyBlock = convertStatement(x.finallyBlock); if (x.catchBlocks != null) { for (int i = 0, c = x.catchArguments.length; i < c; ++i) { SNode local = SLinkOperations.getTarget(SNodeOperations.cast(convertStatement(x.catchArguments[i]), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement")), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, 0xf8cc67c7f1L, "localVariableDeclaration")); ListSequence.fromList(catchArgs).addElement(local); } for (int i = 0, c = x.catchBlocks.length; i < c; ++i) { ListSequence.fromList(catchBlocks).addElement(convertStatement(x.catchBlocks[i])); } } if ((finallyBlock != null)) { SNode tryStatement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cacebf556L, "jetbrains.mps.baseLanguage.structure.TryStatement")); for (int i = 0; i < catchBlocks.size(); i++) { SNode catchBlock = ListSequence.fromList(catchBlocks).getElement(i); SNode lvd = ListSequence.fromList(catchArgs).getElement(i); SNode catchClause = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, "jetbrains.mps.baseLanguage.structure.CatchClause")); ListSequence.fromList(SLinkOperations.getChildren(tryStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cacebf556L, 0x10f39abd97cL, "catchClause"))).addElement(catchClause); SLinkOperations.setTarget(catchClause, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, 0x10f39a6a2f2L, "catchBody"), getStatementListFromStatement(catchBlock, x.catchBlocks[i])); SLinkOperations.setTarget(catchClause, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, 0x10f39a6a2f1L, "throwable"), lvd); } SLinkOperations.setTarget(tryStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cacebf556L, 0x10cacecb713L, "finallyBody"), getStatementListFromStatement(finallyBlock, x.finallyBlock)); SLinkOperations.setTarget(tryStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cacebf556L, 0x10cacec83aeL, "body"), getStatementListFromStatement(tryBlock, x.tryBlock)); return tryStatement; } else { SNode tryCatchStatement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f383e6771L, "jetbrains.mps.baseLanguage.structure.TryCatchStatement")); for (int i = 0; i < catchBlocks.size(); i++) { SNode catchBlock = ListSequence.fromList(catchBlocks).getElement(i); SNode lvd = ListSequence.fromList(catchArgs).getElement(i); SNode catchClause = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, "jetbrains.mps.baseLanguage.structure.CatchClause")); ListSequence.fromList(SLinkOperations.getChildren(tryCatchStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f383e6771L, 0x10f39a8ba1fL, "catchClause"))).addElement(catchClause); SLinkOperations.setTarget(catchClause, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, 0x10f39a6a2f2L, "catchBody"), getStatementListFromStatement(catchBlock, x.catchBlocks[i])); SLinkOperations.setTarget(catchClause, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, 0x10f39a6a2f1L, "throwable"), lvd); } SLinkOperations.setTarget(tryCatchStatement, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f383e6771L, 0x10f383e83d4L, "body"), getStatementListFromStatement(tryBlock, x.tryBlock)); return tryCatchStatement; } } /*package*/ SNode convertStatement(WhileStatement x) throws JavaParseException { SNode loopTest = convertExpressionWrap(x.condition); SNode loopBody = convertStatementWrap(x.action); SNode result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfaa4bf0f2fL, "jetbrains.mps.baseLanguage.structure.WhileStatement")); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfaa4bf0f2fL, 0xfaa4bf0f30L, "condition"), loopTest); SLinkOperations.setTarget(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), getStatementListFromStatement(loopBody, x.action)); return result; } /*package*/ SNode convertStatement(TypeDeclaration x) { LOG.error("Local type declarations are not supported"); return null; } private SNode findConstructor(SNode claz, Expression[] args) { SNode result; Iterable<SNode> conss = ((Iterable<SNode>) BHReflection.invoke(claz, SMethodTrimmedId.create("constructors", MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"), "4_LVZ3pCvsd"))); if (Sequence.fromIterable(conss).isEmpty()) { result = null; } else if (Sequence.fromIterable(conss).count() == 1) { result = Sequence.fromIterable(conss).first(); } else { final int argCount = args.length; Iterable<SNode> subset = Sequence.fromIterable(conss).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return ListSequence.fromList(SLinkOperations.getChildren(it, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1feL, "parameter"))).count() == argCount; } }); result = Sequence.fromIterable(subset).first(); } return result; } private SNode getStatementListFromStatement(SNode possibleBlock, Statement x) { SNode result; if (SNodeOperations.isInstanceOf(possibleBlock, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, "jetbrains.mps.baseLanguage.structure.BlockStatement"))) { result = SLinkOperations.getTarget(SNodeOperations.cast(possibleBlock, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, "jetbrains.mps.baseLanguage.structure.BlockStatement")), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, 0xfc092b6b78L, "statements")); // FIXME should detach be called here? it depends on whether we're already in a model... } else { result = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, "jetbrains.mps.baseLanguage.structure.StatementList")); addBlock(result, x.sourceStart(), x.sourceEnd()); if ((possibleBlock != null)) { ListSequence.fromList(SLinkOperations.getChildren(result, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"))).addElement(possibleBlock); } } return result; } public TypeReference nameRefToTypeRef(Expression x) { TypeReference myTypeRef = null; if (x instanceof SingleNameReference) { myTypeRef = new SingleTypeReference(((SingleNameReference) x).token, -1); } else if (x instanceof QualifiedNameReference) { myTypeRef = new QualifiedTypeReference(((QualifiedNameReference) x).tokens, new long[]{-1}); } return myTypeRef; } public Map<SNode, Integer> getPositions() { return myPositions; } public Iterable<FullASTConverter.CodeBlock> getCodeBlocks() { return myBlocks; } private void addBlock(SNode node, int start, int end) { ListSequence.fromList(myBlocks).addElement(new FullASTConverter.CodeBlock(node, myCud, Math.abs(start), Math.abs(end))); } private FullASTConverter.CodeBlock getBlock(final SNode node) { return ListSequence.fromList(myBlocks).findFirst(new IWhereFilter<FullASTConverter.CodeBlock>() { public boolean accept(FullASTConverter.CodeBlock it) { return it.getStatementList() == node; } }); } private SNode findBlock(final int sourcePos) { long min = Long.MAX_VALUE; SNode stmt = null; // we could maintain the stack of blocks // then we would just take the topmost element from the stack for (FullASTConverter.CodeBlock block : ListSequence.fromList(myBlocks).where(new IWhereFilter<FullASTConverter.CodeBlock>() { public boolean accept(FullASTConverter.CodeBlock it) { return it.getStartPos() <= sourcePos && sourcePos <= it.getEndPos(); } })) { long w = block.getEndPos() - block.getStartPos(); if (w < min) { min = w; stmt = block.getStatementList(); } } return stmt; } public class CodeBlock { private CompilationUnitDeclaration cud; public CodeBlock(SNode n, CompilationUnitDeclaration d, int s, int e) { setStatementList(n); cud = d; setStartPos(s); setEndPos(e); } private SNode myStatementList; public SNode getStatementList() { return this.myStatementList; } private void setStatementList(SNode value) { this.myStatementList = value; } private int myStartPos; public int getStartPos() { return this.myStartPos; } private void setStartPos(int value) { this.myStartPos = value; } private int myEndPos; public int getEndPos() { return this.myEndPos; } private void setEndPos(int value) { this.myEndPos = value; } } @Override protected FullASTConverter withNewState(ASTConverter.State state) { return new FullASTConverter.FullASTConverterWithState(this, state); } private class FullASTConverterWithState extends FullASTConverter { private ASTConverter.State myState; private FullASTConverterWithState(FullASTConverter base, ASTConverter.State state) { super(base); myState = state; } @Override public ASTConverter.State getState() { return myState; } } private static SNode _quotation_createNode_f46ocm_a0b0d0gb(Object parameter_1, Object parameter_2) { PersistenceFacade facade = PersistenceFacade.getInstance(); SNode quotedNode_3 = null; SNode quotedNode_4 = null; SNode quotedNode_5 = null; SNode quotedNode_6 = null; SNode quotedNode_7 = null; SNode quotedNode_8 = null; quotedNode_3 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xfc092b6b77L, "BlockStatement"), null, null, false); quotedNode_4 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc56b200L, "StatementList"), null, null, false); quotedNode_5 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x57d533a7af15ed3aL, "SingleLineComment"), null, null, false); quotedNode_8 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x57d533a7af15ed3dL, "TextCommentPart"), null, null, false); SNodeAccessUtil.setProperty(quotedNode_8, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x57d533a7af15ed3dL, 0x57d533a7af15ed3eL, "text"), "converted: for ( expr; ...) {} -> { expr; for ( ; ...) {} }"); quotedNode_5.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x57d533a7af15ed3aL, 0x57d533a7af16ff73L, "commentPart"), quotedNode_8); quotedNode_4.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), quotedNode_5); { List<SNode> nodes = (List<SNode>) parameter_1; for (SNode child : nodes) { quotedNode_4.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), HUtil.copyIfNecessary(child)); } } quotedNode_7 = (SNode) parameter_2; if (quotedNode_7 != null) { quotedNode_4.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), HUtil.copyIfNecessary(quotedNode_7)); } quotedNode_3.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, 0xfc092b6b78L, "statements"), quotedNode_4); return quotedNode_3; } }