@Test public void testSymbolInterfaceWithNoName() { GlobalExtensionManagement glex = new GlobalExtensionManagement(); ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "data", "DataInterface"); glex.setGlobalValue("service", new AbstractService(astcdCompilationUnit)); glex.setGlobalValue("astHelper", DecorationHelper.getInstance()); SymbolTableService symbolTableService = new SymbolTableService(astcdCompilationUnit); ASTService mockService = Mockito.spy(new ASTService(astcdCompilationUnit)); ASTCDInterface interfaceBy = getInterfaceBy("ASTA", astcdCompilationUnit); ASTInterfaceDecorator decorator = new ASTInterfaceDecorator(glex, mockService , new VisitorService(astcdCompilationUnit), new ASTSymbolDecorator(glex, symbolTableService), new ASTScopeDecorator(glex, symbolTableService), new MethodDecorator(glex, symbolTableService)); ASTCDInterface changeInterface = CD4AnalysisMill.cDInterfaceBuilder().setName(interfaceBy.getName()) .setModifier(interfaceBy.getModifier()) .build(); Mockito.doReturn(true).when(mockService).isSymbolWithoutName(Mockito.any(ASTCDType.class)); ASTCDInterface noNameSymbol = decorator.decorate(interfaceBy, changeInterface); assertEquals(6, noNameSymbol.sizeCDMethods()); ASTCDMethod method = getMethodBy("getName", noNameSymbol); assertDeepEquals(PUBLIC_ABSTRACT, method.getModifier()); assertTrue(method.getMCReturnType().isPresentMCType()); assertDeepEquals(String.class, method.getMCReturnType().getMCType()); assertTrue(method.isEmptyCDParameters()); }
@Override public ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput) { changedInput.addCDMethod(getAcceptMethod()); changedInput.addInterface(getMCTypeFacade().createQualifiedType(AST_INTERFACE)); changedInput.addInterface(astService.getASTBaseInterface()); changedInput.clearCDAttributes(); methodDecorator.disableTemplates(); List<ASTCDAttribute> symbolAttributes = symbolDecorator.decorate(originalInput); changedInput.addAllCDMethods(addSymbolMethods(symbolAttributes)); List<ASTCDAttribute> scopeAttributes = scopeDecorator.decorate(originalInput); changedInput.addAllCDMethods(addScopeMethods(scopeAttributes)); if (astService.isSymbolWithoutName(originalInput)) { changedInput.addCDMethod(astService.createGetNameMethod()); } return changedInput; }
ASTInterfaceDecorator extends AbstractTransformer<ASTCDInterface> { @Override public ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput) { changedInput.addCDMethod(getAcceptMethod()); changedInput.addInterface(getMCTypeFacade().createQualifiedType(AST_INTERFACE)); changedInput.addInterface(astService.getASTBaseInterface()); changedInput.clearCDAttributes(); methodDecorator.disableTemplates(); List<ASTCDAttribute> symbolAttributes = symbolDecorator.decorate(originalInput); changedInput.addAllCDMethods(addSymbolMethods(symbolAttributes)); List<ASTCDAttribute> scopeAttributes = scopeDecorator.decorate(originalInput); changedInput.addAllCDMethods(addScopeMethods(scopeAttributes)); if (astService.isSymbolWithoutName(originalInput)) { changedInput.addCDMethod(astService.createGetNameMethod()); } return changedInput; } }
ASTInterfaceDecorator extends AbstractTransformer<ASTCDInterface> { @Override public ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput) { changedInput.addCDMethod(getAcceptMethod()); changedInput.addInterface(getMCTypeFacade().createQualifiedType(AST_INTERFACE)); changedInput.addInterface(astService.getASTBaseInterface()); changedInput.clearCDAttributes(); methodDecorator.disableTemplates(); List<ASTCDAttribute> symbolAttributes = symbolDecorator.decorate(originalInput); changedInput.addAllCDMethods(addSymbolMethods(symbolAttributes)); List<ASTCDAttribute> scopeAttributes = scopeDecorator.decorate(originalInput); changedInput.addAllCDMethods(addScopeMethods(scopeAttributes)); if (astService.isSymbolWithoutName(originalInput)) { changedInput.addCDMethod(astService.createGetNameMethod()); } return changedInput; } ASTInterfaceDecorator(final GlobalExtensionManagement glex,
                               final ASTService astService,
                               final VisitorService visitorService,
                               final ASTSymbolDecorator symbolDecorator,
                               final ASTScopeDecorator scopeDecorator,
                               final MethodDecorator methodDecorator); }
ASTInterfaceDecorator extends AbstractTransformer<ASTCDInterface> { @Override public ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput) { changedInput.addCDMethod(getAcceptMethod()); changedInput.addInterface(getMCTypeFacade().createQualifiedType(AST_INTERFACE)); changedInput.addInterface(astService.getASTBaseInterface()); changedInput.clearCDAttributes(); methodDecorator.disableTemplates(); List<ASTCDAttribute> symbolAttributes = symbolDecorator.decorate(originalInput); changedInput.addAllCDMethods(addSymbolMethods(symbolAttributes)); List<ASTCDAttribute> scopeAttributes = scopeDecorator.decorate(originalInput); changedInput.addAllCDMethods(addScopeMethods(scopeAttributes)); if (astService.isSymbolWithoutName(originalInput)) { changedInput.addCDMethod(astService.createGetNameMethod()); } return changedInput; } ASTInterfaceDecorator(final GlobalExtensionManagement glex,
                               final ASTService astService,
                               final VisitorService visitorService,
                               final ASTSymbolDecorator symbolDecorator,
                               final ASTScopeDecorator scopeDecorator,
                               final MethodDecorator methodDecorator); @Override ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput); }
ASTInterfaceDecorator extends AbstractTransformer<ASTCDInterface> { @Override public ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput) { changedInput.addCDMethod(getAcceptMethod()); changedInput.addInterface(getMCTypeFacade().createQualifiedType(AST_INTERFACE)); changedInput.addInterface(astService.getASTBaseInterface()); changedInput.clearCDAttributes(); methodDecorator.disableTemplates(); List<ASTCDAttribute> symbolAttributes = symbolDecorator.decorate(originalInput); changedInput.addAllCDMethods(addSymbolMethods(symbolAttributes)); List<ASTCDAttribute> scopeAttributes = scopeDecorator.decorate(originalInput); changedInput.addAllCDMethods(addScopeMethods(scopeAttributes)); if (astService.isSymbolWithoutName(originalInput)) { changedInput.addCDMethod(astService.createGetNameMethod()); } return changedInput; } ASTInterfaceDecorator(final GlobalExtensionManagement glex,
                               final ASTService astService,
                               final VisitorService visitorService,
                               final ASTSymbolDecorator symbolDecorator,
                               final ASTScopeDecorator scopeDecorator,
                               final MethodDecorator methodDecorator); @Override ASTCDInterface decorate(final ASTCDInterface originalInput, ASTCDInterface changedInput);  }