private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
@Override public void visitVariableDef(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideAnonymousInnerClass() && isFieldDefinition()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); if (currentClassDoc != null) { String fieldName = getIdentFor(t); currentFieldDoc = new SimpleGroovyFieldDoc(fieldName, currentClassDoc); currentFieldDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); boolean isProp = processModifiers(t, currentFieldDoc); currentFieldDoc.setType(new SimpleGroovyType(getTypeOrDefault(t))); processAnnotations(t, currentFieldDoc); if (isProp) { currentClassDoc.addProperty(currentFieldDoc); } else { currentClassDoc.add(currentFieldDoc); } } } }
@Override public void visitMethodDef(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); if (currentClassDoc == null) { // assume we have a script if ("true".equals(properties.getProperty("processScripts", "true"))) { currentClassDoc = new SimpleGroovyClassDoc(importedClassesAndPackages, aliases, className, links); currentClassDoc.setFullPathName(packagePath + FS + className); currentClassDoc.setPublic(true); currentClassDoc.setScript(true); currentClassDoc.setGroovy(isGroovy); currentClassDoc.setSuperClassName("groovy/lang/Script"); if ("true".equals(properties.getProperty("includeMainForScripts", "true"))) { currentClassDoc.add(createMainMethod(currentClassDoc)); } classDocs.put(currentClassDoc.getFullPathName(), currentClassDoc); if (foundClasses == null) { foundClasses = new HashMap<String, SimpleGroovyClassDoc>(); } foundClasses.put(className, currentClassDoc); } else { return; } } SimpleGroovyMethodDoc currentMethodDoc = createMethod(t, currentClassDoc); currentClassDoc.add(currentMethodDoc); } }
private void adjustForAutomaticEnumMethods(SimpleGroovyClassDoc currentClassDoc) { SimpleGroovyMethodDoc valueOf = new SimpleGroovyMethodDoc("valueOf", currentClassDoc); valueOf.setRawCommentText("Returns the enum constant of this type with the specified name."); SimpleGroovyParameter parameter = new SimpleGroovyParameter("name"); parameter.setTypeName("String"); valueOf.add(parameter); valueOf.setReturnType(new SimpleGroovyType(currentClassDoc.name())); currentClassDoc.add(valueOf); SimpleGroovyMethodDoc values = new SimpleGroovyMethodDoc("values", currentClassDoc); values.setRawCommentText("Returns an array containing the constants of this enum type, in the order they are declared."); values.setReturnType(new SimpleGroovyType(currentClassDoc.name() + "[]")); currentClassDoc.add(values); }
@Override public void visitCtorIdent(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); SimpleGroovyConstructorDoc currentConstructorDoc = new SimpleGroovyConstructorDoc(currentClassDoc.name(), currentClassDoc); currentConstructorDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); processModifiers(t, currentConstructorDoc); addParametersTo(t, currentConstructorDoc); processAnnotations(t, currentConstructorDoc); currentClassDoc.add(currentConstructorDoc); } }
@Override public void visitAnnotationFieldDef(GroovySourceAST t, int visit) { if (isGroovy && visit == OPENING_VISIT) { // TODO shouldn't really be treating annotation fields as methods - remove this hack SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); SimpleGroovyMethodDoc currentMethodDoc = createMethod(t, currentClassDoc); String defaultText = getDefaultValue(t); if (defaultText != null) { String orig = currentMethodDoc.getRawCommentText(); currentMethodDoc.setRawCommentText(orig + "\n* @default " + defaultText); } currentClassDoc.add(currentMethodDoc); } else if (visit == OPENING_VISIT) { // if (visit == OPENING_VISIT) { visitVariableDef(t, visit); String defaultText = getDefaultValue(t); if (isGroovy) { currentFieldDoc.setPublic(true); } if (defaultText != null) { currentFieldDoc.setConstantValueExpression(defaultText); String orig = currentFieldDoc.getRawCommentText(); currentFieldDoc.setRawCommentText(orig + "\n* @default " + defaultText); } } }
private void postProcessClassDocs() { Iterator classDocIterator = classDocs.values().iterator(); while (classDocIterator.hasNext()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) classDocIterator.next(); // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { // todo Enums, @Interfaces etc GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name()); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
private void adjustForAutomaticEnumMethods(SimpleGroovyClassDoc currentClassDoc) { SimpleGroovyMethodDoc valueOf = new SimpleGroovyMethodDoc("valueOf", currentClassDoc); valueOf.setRawCommentText("Returns the enum constant of this type with the specified name."); SimpleGroovyParameter parameter = new SimpleGroovyParameter("name"); parameter.setTypeName("String"); valueOf.add(parameter); valueOf.setReturnType(new SimpleGroovyType(currentClassDoc.name())); currentClassDoc.add(valueOf); SimpleGroovyMethodDoc values = new SimpleGroovyMethodDoc("values", currentClassDoc); values.setRawCommentText("Returns an array containing the constants of this enum type, in the order they are declared."); values.setReturnType(new SimpleGroovyType(currentClassDoc.name() + "[]")); currentClassDoc.add(values); }
private void adjustForAutomaticEnumMethods(SimpleGroovyClassDoc currentClassDoc) { SimpleGroovyMethodDoc valueOf = new SimpleGroovyMethodDoc("valueOf", currentClassDoc); valueOf.setRawCommentText("Returns the enum constant of this type with the specified name."); SimpleGroovyParameter parameter = new SimpleGroovyParameter("name"); parameter.setTypeName("String"); valueOf.add(parameter); valueOf.setReturnType(new SimpleGroovyType(currentClassDoc.name())); currentClassDoc.add(valueOf); SimpleGroovyMethodDoc values = new SimpleGroovyMethodDoc("values", currentClassDoc); values.setRawCommentText("Returns an array containing the constants of this enum type, in the order they are declared."); values.setReturnType(new SimpleGroovyType(currentClassDoc.name() + "[]")); currentClassDoc.add(values); }
private static void adjustForAutomaticEnumMethods(SimpleGroovyClassDoc currentClassDoc) { SimpleGroovyMethodDoc valueOf = new SimpleGroovyMethodDoc("valueOf", currentClassDoc); valueOf.setRawCommentText("Returns the enum constant of this type with the specified name."); SimpleGroovyParameter parameter = new SimpleGroovyParameter("name"); parameter.setTypeName("String"); valueOf.add(parameter); valueOf.setReturnType(new SimpleGroovyType(currentClassDoc.name())); currentClassDoc.add(valueOf); SimpleGroovyMethodDoc values = new SimpleGroovyMethodDoc("values", currentClassDoc); values.setRawCommentText("Returns an array containing the constants of this enum type, in the order they are declared."); values.setReturnType(new SimpleGroovyType(currentClassDoc.name() + "[]")); currentClassDoc.add(values); }
private void adjustForAutomaticEnumMethods(SimpleGroovyClassDoc currentClassDoc) { SimpleGroovyMethodDoc valueOf = new SimpleGroovyMethodDoc("valueOf", currentClassDoc); valueOf.setRawCommentText("Returns the enum constant of this type with the specified name."); SimpleGroovyParameter parameter = new SimpleGroovyParameter("name"); parameter.setTypeName("String"); valueOf.add(parameter); valueOf.setReturnType(new SimpleGroovyType(currentClassDoc.name())); currentClassDoc.add(valueOf); SimpleGroovyMethodDoc values = new SimpleGroovyMethodDoc("values", currentClassDoc); values.setRawCommentText("Returns an array containing the constants of this enum type, in the order they are declared."); values.setReturnType(new SimpleGroovyType(currentClassDoc.name() + "[]")); currentClassDoc.add(values); }
@Override public void visitCtorIdent(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); SimpleGroovyConstructorDoc currentConstructorDoc = new SimpleGroovyConstructorDoc(currentClassDoc.name(), currentClassDoc); currentConstructorDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); processModifiers(t, currentConstructorDoc); addParametersTo(t, currentConstructorDoc); processAnnotations(t, currentConstructorDoc); currentClassDoc.add(currentConstructorDoc); } }
@Override public void visitCtorIdent(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); SimpleGroovyConstructorDoc currentConstructorDoc = new SimpleGroovyConstructorDoc(currentClassDoc.name(), currentClassDoc); currentConstructorDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); processModifiers(t, currentConstructorDoc); addParametersTo(t, currentConstructorDoc); processAnnotations(t, currentConstructorDoc); currentClassDoc.add(currentConstructorDoc); } }
@Override public void visitCtorIdent(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); SimpleGroovyConstructorDoc currentConstructorDoc = new SimpleGroovyConstructorDoc(currentClassDoc.name(), currentClassDoc); currentConstructorDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); processModifiers(t, currentConstructorDoc); addParametersTo(t, currentConstructorDoc); processAnnotations(t, currentConstructorDoc); currentClassDoc.add(currentConstructorDoc); } }
@Override public void visitCtorIdent(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); SimpleGroovyConstructorDoc currentConstructorDoc = new SimpleGroovyConstructorDoc(currentClassDoc.name(), currentClassDoc); currentConstructorDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); processModifiers(t, currentConstructorDoc); addParametersTo(t, currentConstructorDoc); processAnnotations(t, currentConstructorDoc); currentClassDoc.add(currentConstructorDoc); } }
@Override public void visitMethodDef(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT && !insideEnum && !insideAnonymousInnerClass()) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); if (currentClassDoc != null) { String methodName = getIdentFor(t); SimpleGroovyMethodDoc currentMethodDoc = new SimpleGroovyMethodDoc(methodName, currentClassDoc); currentMethodDoc.setRawCommentText(getJavaDocCommentsBeforeNode(t)); processModifiers(t, currentMethodDoc); currentMethodDoc.setReturnType(new SimpleGroovyType(getTypeOrDefault(t))); addParametersTo(t, currentMethodDoc); processAnnotations(t, currentMethodDoc); currentClassDoc.add(currentMethodDoc); } } }