Java Code Examples for org.eclipse.jdt.core.dom.TypeDeclaration#setName()
The following examples show how to use
org.eclipse.jdt.core.dom.TypeDeclaration#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmptyBuilderClassGeneratorFragment.java From SparkBuilderGenerator with MIT License | 6 votes |
public TypeDeclaration createBuilderClass(AST ast, TypeDeclaration originalType) { TypeDeclaration builderType = ast.newTypeDeclaration(); builderType.setName(ast.newSimpleName(getBuilderName(originalType))); if (preferencesManager.getPreferenceValue(ADD_GENERATED_ANNOTATION)) { generatedAnnotationPopulator.addGeneratedAnnotation(ast, builderType); } builderType.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD)); builderType.modifiers().add(ast.newModifier(ModifierKeyword.STATIC_KEYWORD)); builderType.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD)); if (preferencesManager.getPreferenceValue(ADD_JACKSON_DESERIALIZE_ANNOTATION)) { jsonPOJOBuilderAdderFragment.addJsonPOJOBuilder(ast, builderType); } if (preferencesManager.getPreferenceValue(GENERATE_JAVADOC_ON_BUILDER_CLASS)) { Javadoc javadoc = javadocGenerator.generateJavadoc(ast, String.format(Locale.ENGLISH, "Builder to build {@link %s}.", originalType.getName().toString()), Collections.emptyMap()); builderType.setJavadoc(javadoc); } return builderType; }
Example 2
Source File: StagedBuilderInterfaceTypeDefinitionCreatorFragment.java From SparkBuilderGenerator with MIT License | 5 votes |
public TypeDeclaration createStageBuilderInterface(AST ast, String interfaceName) { TypeDeclaration addedInterface = ast.newTypeDeclaration(); addedInterface.setInterface(true); addedInterface.setName(ast.newSimpleName(interfaceName)); addedInterface.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD)); javadocAdder.addJavadocForStagedInterface(ast, interfaceName, addedInterface); return addedInterface; }
Example 3
Source File: ConvertAnonymousToNestedRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private AbstractTypeDeclaration createNewNestedClass(CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException { final AST ast= fAnonymousInnerClassNode.getAST(); final TypeDeclaration newDeclaration= ast.newTypeDeclaration(); newDeclaration.setInterface(false); newDeclaration.setJavadoc(null); newDeclaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiersForNestedClass())); newDeclaration.setName(ast.newSimpleName(fClassName)); TypeParameter parameter= null; for (int index= 0; index < typeParameters.length; index++) { parameter= ast.newTypeParameter(); parameter.setName(ast.newSimpleName(typeParameters[index].getName())); newDeclaration.typeParameters().add(parameter); } setSuperType(newDeclaration); IJavaProject project= fCu.getJavaProject(); IVariableBinding[] bindings= getUsedLocalVariables(); ArrayList<String> fieldNames= new ArrayList<String>(); for (int i= 0; i < bindings.length; i++) { String name= StubUtility.getBaseName(bindings[i], project); String[] fieldNameProposals= StubUtility.getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, project, name, 0, fieldNames, true); fieldNames.add(fieldNameProposals[0]); if (fLinkedProposalModel != null) { LinkedProposalPositionGroup positionGroup= fLinkedProposalModel.getPositionGroup(KEY_FIELD_NAME_EXT + i, true); for (int k= 0; k < fieldNameProposals.length; k++) { positionGroup.addProposal(fieldNameProposals[k], null, fieldNameProposals.length - k); } } } String[] allFieldNames= fieldNames.toArray(new String[fieldNames.size()]); List<BodyDeclaration> newBodyDeclarations= newDeclaration.bodyDeclarations(); createFieldsForAccessedLocals(rewrite, bindings, allFieldNames, newBodyDeclarations); MethodDeclaration newConstructorDecl= createNewConstructor(rewrite, bindings, allFieldNames); if (newConstructorDecl != null) { newBodyDeclarations.add(newConstructorDecl); } updateAndMoveBodyDeclarations(rewrite, bindings, allFieldNames, newBodyDeclarations, newConstructorDecl); if (doAddComments()) { String[] parameterNames= new String[typeParameters.length]; for (int index= 0; index < parameterNames.length; index++) { parameterNames[index]= typeParameters[index].getName(); } String string= CodeGeneration.getTypeComment(rewrite.getCu(), fClassName, parameterNames, StubUtility.getLineDelimiterUsed(fCu)); if (string != null) { Javadoc javadoc= (Javadoc) rewrite.getASTRewrite().createStringPlaceholder(string, ASTNode.JAVADOC); newDeclaration.setJavadoc(javadoc); } } if (fLinkedProposalModel != null) { addLinkedPosition(KEY_TYPE_NAME, newDeclaration.getName(), rewrite.getASTRewrite(), false); ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(fLinkedProposalModel, rewrite.getASTRewrite(), newDeclaration.modifiers(), false); } return newDeclaration; }