-
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.
Merge pull request #20 from Saxonica/type-parameters
Support type parameters on methods
- Loading branch information
Showing
8 changed files
with
110 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
docletVersion=0.12.0 | ||
schemaVersion=0.12.0 | ||
docletVersion=0.13.0 | ||
schemaVersion=0.13.0 | ||
docletTitle=XmlDoclet | ||
docletName=xmldoclet |
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
17 changes: 17 additions & 0 deletions
17
xmldoclet/src/main/java/com/saxonica/xmldoclet/scanners/XmlTypeParameter.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,17 @@ | ||
package com.saxonica.xmldoclet.scanners; | ||
|
||
import com.saxonica.xmldoclet.builder.XmlProcessor; | ||
|
||
import javax.lang.model.element.TypeParameterElement; | ||
import javax.lang.model.element.VariableElement; | ||
|
||
public class XmlTypeParameter extends XmlTypeParameterElement { | ||
public XmlTypeParameter(XmlProcessor builder, TypeParameterElement element) { | ||
super(builder, element); | ||
} | ||
|
||
@Override | ||
public String typeName() { | ||
return "parameter"; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
xmldoclet/src/main/java/com/saxonica/xmldoclet/scanners/XmlTypeParameterElement.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,70 @@ | ||
package com.saxonica.xmldoclet.scanners; | ||
|
||
import com.saxonica.xmldoclet.builder.XmlProcessor; | ||
import com.saxonica.xmldoclet.utils.TypeUtils; | ||
import com.sun.source.doctree.DocCommentTree; | ||
import com.sun.source.doctree.DocTree; | ||
import com.sun.source.doctree.ParamTree; | ||
|
||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.ElementKind; | ||
import javax.lang.model.element.TypeParameterElement; | ||
import javax.lang.model.element.VariableElement; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public abstract class XmlTypeParameterElement extends XmlScanner { | ||
private final TypeParameterElement element; | ||
|
||
public XmlTypeParameterElement(XmlProcessor xmlproc, TypeParameterElement element) { | ||
super(xmlproc); | ||
this.element = element; | ||
} | ||
|
||
public abstract String typeName(); | ||
|
||
@Override | ||
public void scan(DocTree tree) { | ||
Map<String,String> attr = new HashMap<>(); | ||
attr.put("name", element.getSimpleName().toString()); | ||
attr.put("class", "type"); | ||
attr.putAll(modifierAttributes(element)); | ||
|
||
builder.startElement(typeName(), attr); | ||
|
||
// If this is a parameter, get the ParamTree block from | ||
// our parent... | ||
ParamTree paramTree = null; | ||
Element parent = element.getEnclosingElement(); | ||
if (parent.getKind() == ElementKind.METHOD || parent.getKind() == ElementKind.CONSTRUCTOR) { | ||
DocCommentTree parentTree = builder.environment.getDocTrees().getDocCommentTree(parent); | ||
if (parentTree != null) { | ||
for (DocTree block : parentTree.getBlockTags()) { | ||
if (block.getKind() == DocTree.Kind.PARAM) { | ||
ParamTree ptree = (ParamTree) block; | ||
if (ptree.getName().toString().equals(element.getSimpleName().toString())) { | ||
paramTree = ptree; | ||
break; | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
if (paramTree != null) { | ||
builder.processList("purpose", paramTree.getDescription()); | ||
} | ||
|
||
if (tree instanceof DocCommentTree) { | ||
DocCommentTree dcTree = (DocCommentTree) tree; | ||
builder.processList(dcTree.getBlockTags()); | ||
builder.processList("purpose", dcTree.getFirstSentence()); | ||
builder.processList("description", dcTree.getBody()); | ||
} | ||
|
||
TypeUtils.xmlType(builder, "type", element.asType()); | ||
|
||
builder.endElement(typeName()); | ||
} | ||
} |
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