forked from sdaschner/jaxrs-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added first version of JavaDoc analysis
- Loading branch information
Showing
13 changed files
with
269 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JAXRSDoclet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc; | ||
|
||
import com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils; | ||
import com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier; | ||
import com.sun.javadoc.ClassDoc; | ||
import com.sun.javadoc.MethodDoc; | ||
import com.sun.javadoc.RootDoc; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.getMethodSignature; | ||
import static com.sebastian_daschner.jaxrs_analyzer.model.Types.*; | ||
import static com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier.of; | ||
|
||
/** | ||
* @author Sebastian Daschner | ||
*/ | ||
public class JAXRSDoclet { | ||
|
||
public static boolean start(RootDoc rootDoc) { | ||
Stream.of(rootDoc.classes()).forEach(JAXRSDoclet::handleClassDoc); | ||
return true; | ||
} | ||
|
||
private static void handleClassDoc(final ClassDoc classDoc) { | ||
final String className = toClassName(classDoc.qualifiedName()); | ||
JavaDocAnalyzer.put(className, classDoc); | ||
Stream.of(classDoc.methods()).forEach(m -> handleMethodDoc(m, className)); | ||
} | ||
|
||
private static void handleMethodDoc(final MethodDoc methodDoc, final String className) { | ||
final String[] parameterTypes = Stream.of(methodDoc.parameters()) | ||
.map(p -> p.type().qualifiedTypeName()) | ||
.map(JAXRSDoclet::toType) | ||
.toArray(String[]::new); | ||
|
||
final String returnType = toType(methodDoc.returnType().qualifiedTypeName()); | ||
final String signature = getMethodSignature(returnType, parameterTypes); | ||
|
||
final MethodIdentifier identifier = of(className, methodDoc.name(), signature, methodDoc.isStatic()); | ||
JavaDocAnalyzer.put(identifier, methodDoc); | ||
} | ||
|
||
private static String toClassName(final String qualifiedName) { | ||
return qualifiedName.replace('.', '/'); | ||
} | ||
|
||
private static String toType(final String qualifiedName) { | ||
switch (qualifiedName) { | ||
case CLASS_PRIMITIVE_VOID: | ||
return PRIMITIVE_VOID; | ||
case CLASS_PRIMITIVE_BOOLEAN: | ||
return PRIMITIVE_BOOLEAN; | ||
case CLASS_PRIMITIVE_CHAR: | ||
return PRIMITIVE_CHAR; | ||
case CLASS_PRIMITIVE_INT: | ||
return PRIMITIVE_INT; | ||
case CLASS_PRIMITIVE_BYTE: | ||
return PRIMITIVE_BYTE; | ||
case CLASS_PRIMITIVE_SHORT: | ||
return PRIMITIVE_SHORT; | ||
case CLASS_PRIMITIVE_DOUBLE: | ||
return PRIMITIVE_DOUBLE; | ||
case CLASS_PRIMITIVE_FLOAT: | ||
return PRIMITIVE_FLOAT; | ||
case CLASS_PRIMITIVE_LONG: | ||
return PRIMITIVE_LONG; | ||
default: | ||
return JavaUtils.toType(toClassName(qualifiedName)); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.