localLookup = localLookupByFileName.get(metadataFile.getFileNameWithPath());
+ return new LookupContext(globalLookup, localLookup);
+ }
- /**
- * For each such item from items and references of metadata file:
- *
- * - uid: "com.microsoft.samples.subpackage.Person.setFirstName(java.lang.String, boolean)"
- * nameWithType: "Person.setFirstName(String firstName, boolean flag)"
- * ...
- *
- * add several key-value pairs to lookup where keys are:
- *
- * - Name with type without generics:
Person.setFirstName(String firstName, boolean flag)
- * - Uid as is:
com.microsoft.samples.subpackage.Person.setFirstName(java.lang.String, boolean)
- * - Uid with param types without package:
com.microsoft.samples.subpackage.Person.setFirstName(String,
- * boolean)
- * - Uid without package:
Person.setFirstName(java.lang.String, boolean)
- * - Name with type without generics and param names:
Person.setFirstName(String, boolean)
- * - Name with type as is:
Person.setFirstName(String, boolean)
- *
- * and value equals to uid:
com.microsoft.samples.subpackage.Person.setFirstName(java.lang.String)
- */
- private void consume(List metadataFiles) {
- metadataFiles.forEach(file -> {
- /**
- * It's important to use LinkedHashMap here, to put item related with owner class on first place.
- * Logic of {@link YmlFilesBuilder#resolveUidByLookup} based on this for case when @link starts from '#'
- */
- Map map = new LinkedHashMap<>();
- Map specForJavaMap = new LinkedHashMap<>();
+ /**
+ * For each such item from items and references of metadata file:
+ *
+ *
+ * - uid: "com.microsoft.samples.subpackage.Person.setFirstName(java.lang.String, boolean)"
+ * nameWithType: "Person.setFirstName(String firstName, boolean flag)"
+ * ...
+ *
+ *
+ * add several key-value pairs to lookup where keys are:
+ *
+ *
+ * - Name with type without generics:
+ * Person.setFirstName(String firstName, boolean flag)
+ * - Uid as is:
+ * com.microsoft.samples.subpackage.Person.setFirstName(java.lang.String, boolean)
+ * - Uid with param types without package:
+ * com.microsoft.samples.subpackage.Person.setFirstName(String, boolean)
+ * - Uid without package:
+ * Person.setFirstName(java.lang.String, boolean)
+ * - Name with type without generics and param names:
+ * Person.setFirstName(String, boolean)
+ * - Name with type as is:
+ * Person.setFirstName(String, boolean)
+ *
+ *
+ * and value equals to uid:
+ * com.microsoft.samples.subpackage.Person.setFirstName(java.lang.String)
+ */
+ private void consume(List metadataFiles) {
+ metadataFiles.forEach(
+ file -> {
+ /**
+ * It's important to use LinkedHashMap here, to put item related with owner class on first
+ * place. Logic of {@link YmlFilesBuilder#resolveUidByLookup} based on this for case
+ * when @link starts from '#'
+ */
+ Map map = new LinkedHashMap<>();
+ Map specForJavaMap = new LinkedHashMap<>();
- file.getItems().forEach(item -> {
- String uid = item.getUid();
- String nameWithType = item.getNameWithType();
- String nameWithTypeWithoutGenerics = removeAll(nameWithType, "<.*?>");
+ file.getItems()
+ .forEach(
+ item -> {
+ String uid = item.getUid();
+ String nameWithType = item.getNameWithType();
+ String nameWithTypeWithoutGenerics = removeAll(nameWithType, "<.*?>");
- map.put(nameWithTypeWithoutGenerics, uid); // This item should go first
- map.put(uid, uid);
- map.put(removeAll(uid, PARAM_PACKAGE_NAME_REGEXP), uid);
- map.put(removeAll(uid, UID_PACKAGE_NAME_REGEXP), uid);
- map.put(removeAll(nameWithTypeWithoutGenerics, METHOD_PARAMS_REGEXP), uid);
- map.put(removeAll(nameWithType, METHOD_PARAMS_REGEXP), uid);
+ map.put(nameWithTypeWithoutGenerics, uid); // This item should go first
+ map.put(uid, uid);
+ map.put(removeAll(uid, PARAM_PACKAGE_NAME_REGEXP), uid);
+ map.put(removeAll(uid, UID_PACKAGE_NAME_REGEXP), uid);
+ map.put(removeAll(nameWithTypeWithoutGenerics, METHOD_PARAMS_REGEXP), uid);
+ map.put(removeAll(nameWithType, METHOD_PARAMS_REGEXP), uid);
- map.put(replaceAll(uid, ",", ", "), uid);
- map.put(replaceAll(removeAll(uid, PARAM_PACKAGE_NAME_REGEXP), ",", ", "), uid);
- map.put(replaceAll(removeAll(uid, UID_PACKAGE_NAME_REGEXP), ",", ", "), uid);
- map.put(replaceAll(removeAll(nameWithTypeWithoutGenerics, METHOD_PARAMS_REGEXP), ", ", ","), uid);
- });
+ map.put(replaceAll(uid, ",", ", "), uid);
+ map.put(replaceAll(removeAll(uid, PARAM_PACKAGE_NAME_REGEXP), ",", ", "), uid);
+ map.put(replaceAll(removeAll(uid, UID_PACKAGE_NAME_REGEXP), ",", ", "), uid);
+ map.put(
+ replaceAll(
+ removeAll(nameWithTypeWithoutGenerics, METHOD_PARAMS_REGEXP),
+ ", ",
+ ","),
+ uid);
+ });
- file.getReferences().forEach(item -> {
- map.put(item.getUid(), item.getUid());
+ file.getReferences()
+ .forEach(
+ item -> {
+ map.put(item.getUid(), item.getUid());
- // complex types are recorded in "specForJava" as arrayList of items, thus it has no "NameWithType"
- // thus we need to get every reference item from specForJava, and add to localLookup
- if (item.getNameWithType() == null || item.getNameWithType().isEmpty()) {
- item.getSpecForJava().forEach(spec -> {
- specForJavaMap.put(spec.getName(), spec.getUid());
- specForJavaMap.put(spec.getFullName(), spec.getUid());
- });
- } else {
- map.put(item.getNameWithType(), item.getUid());
- }
- });
+ // complex types are recorded in "specForJava" as arrayList of items, thus it
+ // has no "NameWithType"
+ // thus we need to get every reference item from specForJava, and add to
+ // localLookup
+ if (item.getNameWithType() == null || item.getNameWithType().isEmpty()) {
+ item.getSpecForJava()
+ .forEach(
+ spec -> {
+ specForJavaMap.put(spec.getName(), spec.getUid());
+ specForJavaMap.put(spec.getFullName(), spec.getUid());
+ });
+ } else {
+ map.put(item.getNameWithType(), item.getUid());
+ }
+ });
- // to avoid conflict, the items from specForJava should only add to localLookup
- globalLookup.putAll(map);
- map.putAll(specForJavaMap);
- localLookupByFileName.put(file.getFileNameWithPath(), map);
+ // to avoid conflict, the items from specForJava should only add to localLookup
+ globalLookup.putAll(map);
+ map.putAll(specForJavaMap);
+ localLookupByFileName.put(file.getFileNameWithPath(), map);
});
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/LookupContext.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/LookupContext.java
index eee61c22..1ddc8f74 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/LookupContext.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/LookupContext.java
@@ -4,26 +4,26 @@
public class LookupContext {
- private final Map globalLookup;
- private final Map localLookup;
+ private final Map globalLookup;
+ private final Map localLookup;
- public LookupContext(Map globalLookup, Map localLookup) {
- this.globalLookup = globalLookup;
- this.localLookup = localLookup;
- }
+ public LookupContext(Map globalLookup, Map localLookup) {
+ this.globalLookup = globalLookup;
+ this.localLookup = localLookup;
+ }
- public String resolve(String key) {
- if (localLookup.containsKey(key)) {
- return localLookup.get(key);
- }
- return globalLookup.get(key);
+ public String resolve(String key) {
+ if (localLookup.containsKey(key)) {
+ return localLookup.get(key);
}
+ return globalLookup.get(key);
+ }
- public String getOwnerUid() {
- return localLookup.keySet().iterator().next();
- }
+ public String getOwnerUid() {
+ return localLookup.keySet().iterator().next();
+ }
- public boolean containsKey(String key) {
- return localLookup.containsKey(key) || globalLookup.containsKey(key);
- }
+ public boolean containsKey(String key) {
+ return localLookup.containsKey(key) || globalLookup.containsKey(key);
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/PackageBuilder.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/PackageBuilder.java
index 42228bbd..435de9e6 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/PackageBuilder.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/PackageBuilder.java
@@ -15,34 +15,36 @@
*/
package com.microsoft.build;
+import static com.microsoft.build.BuilderUtil.LANGS;
+import static com.microsoft.build.BuilderUtil.populateItemFields;
+
import com.microsoft.lookup.PackageLookup;
import com.microsoft.model.MetadataFile;
import com.microsoft.model.MetadataFileItem;
-
import javax.lang.model.element.PackageElement;
-import static com.microsoft.build.BuilderUtil.LANGS;
-import static com.microsoft.build.BuilderUtil.populateItemFields;
-
class PackageBuilder {
- private final PackageLookup packageLookup;
- private final String outputPath;
- private final ReferenceBuilder referenceBuilder;
+ private final PackageLookup packageLookup;
+ private final String outputPath;
+ private final ReferenceBuilder referenceBuilder;
- PackageBuilder(PackageLookup packageLookup, String outputPath, ReferenceBuilder referenceBuilder) {
- this.packageLookup = packageLookup;
- this.outputPath = outputPath;
- this.referenceBuilder = referenceBuilder;
- }
+ PackageBuilder(
+ PackageLookup packageLookup, String outputPath, ReferenceBuilder referenceBuilder) {
+ this.packageLookup = packageLookup;
+ this.outputPath = outputPath;
+ this.referenceBuilder = referenceBuilder;
+ }
- MetadataFile buildPackageMetadataFile(PackageElement packageElement) {
- String fileName = packageLookup.extractHref(packageElement);
- MetadataFile packageMetadataFile = new MetadataFile(outputPath, fileName);
- MetadataFileItem packageItem = new MetadataFileItem(LANGS, packageLookup.extractUid(packageElement));
- packageItem.setId(packageLookup.extractId(packageElement));
- referenceBuilder.addChildrenReferences(packageElement, packageItem.getChildren(), packageMetadataFile.getReferences());
- populateItemFields(packageItem, packageLookup, packageElement);
- packageMetadataFile.getItems().add(packageItem);
- return packageMetadataFile;
- }
+ MetadataFile buildPackageMetadataFile(PackageElement packageElement) {
+ String fileName = packageLookup.extractHref(packageElement);
+ MetadataFile packageMetadataFile = new MetadataFile(outputPath, fileName);
+ MetadataFileItem packageItem =
+ new MetadataFileItem(LANGS, packageLookup.extractUid(packageElement));
+ packageItem.setId(packageLookup.extractId(packageElement));
+ referenceBuilder.addChildrenReferences(
+ packageElement, packageItem.getChildren(), packageMetadataFile.getReferences());
+ populateItemFields(packageItem, packageLookup, packageElement);
+ packageMetadataFile.getItems().add(packageItem);
+ return packageMetadataFile;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ProjectBuilder.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ProjectBuilder.java
index f51f95d9..b43b1783 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ProjectBuilder.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ProjectBuilder.java
@@ -15,41 +15,43 @@
*/
package com.microsoft.build;
+import static com.microsoft.build.BuilderUtil.LANGS;
+
import com.microsoft.model.MetadataFile;
import com.microsoft.model.MetadataFileItem;
-
import java.util.ArrayList;
import java.util.List;
-import static com.microsoft.build.BuilderUtil.LANGS;
-
class ProjectBuilder {
- private final String projectName;
-
- ProjectBuilder(String projectName) {
- this.projectName = projectName;
- }
-
- void buildProjectMetadataFile(List packageItems, MetadataFile projectMetadataFile) {
- MetadataFileItem projectItem = new MetadataFileItem(LANGS, projectName);
- projectItem.setNameWithType(projectName);
- projectItem.setFullName(projectName);
- projectItem.setType("Namespace");
- projectItem.setJavaType("overview");
-
- List children = new ArrayList<>();
- List references = new ArrayList<>();
- packageItems.stream().forEach(i -> {
- children.add(i.getUid());
- MetadataFileItem refItem = new MetadataFileItem(i.getUid());
- refItem.setName(i.getName());
- refItem.setNameWithType(i.getNameWithType());
- refItem.setFullName(i.getFullName());
- references.add(refItem);
- });
-
- projectItem.getChildren().addAll(children);
- projectMetadataFile.getReferences().addAll(references);
- projectMetadataFile.getItems().add(projectItem);
- }
+ private final String projectName;
+
+ ProjectBuilder(String projectName) {
+ this.projectName = projectName;
+ }
+
+ void buildProjectMetadataFile(
+ List packageItems, MetadataFile projectMetadataFile) {
+ MetadataFileItem projectItem = new MetadataFileItem(LANGS, projectName);
+ projectItem.setNameWithType(projectName);
+ projectItem.setFullName(projectName);
+ projectItem.setType("Namespace");
+ projectItem.setJavaType("overview");
+
+ List children = new ArrayList<>();
+ List references = new ArrayList<>();
+ packageItems.stream()
+ .forEach(
+ i -> {
+ children.add(i.getUid());
+ MetadataFileItem refItem = new MetadataFileItem(i.getUid());
+ refItem.setName(i.getName());
+ refItem.setNameWithType(i.getNameWithType());
+ refItem.setFullName(i.getFullName());
+ references.add(refItem);
+ });
+
+ projectItem.getChildren().addAll(children);
+ projectMetadataFile.getReferences().addAll(references);
+ projectMetadataFile.getItems().add(projectItem);
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ReferenceBuilder.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ReferenceBuilder.java
index c1ed3387..f0a5658e 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ReferenceBuilder.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/ReferenceBuilder.java
@@ -15,17 +15,16 @@
*/
package com.microsoft.build;
+import static com.microsoft.build.BuilderUtil.getJavaSpec;
+import static com.microsoft.build.BuilderUtil.populateItemFields;
+import static com.microsoft.build.BuilderUtil.replaceUidAndSplit;
+import static com.microsoft.build.BuilderUtil.splitUidWithGenericsIntoClassNames;
+
import com.microsoft.lookup.ClassLookup;
import com.microsoft.model.MetadataFile;
import com.microsoft.model.MetadataFileItem;
import com.microsoft.model.SpecViewModel;
import com.microsoft.util.ElementUtil;
-import jdk.javadoc.doclet.DocletEnvironment;
-import org.apache.commons.lang3.RegExUtils;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.ElementFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -36,248 +35,286 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
-import static com.microsoft.build.BuilderUtil.getJavaSpec;
-import static com.microsoft.build.BuilderUtil.populateItemFields;
-import static com.microsoft.build.BuilderUtil.replaceUidAndSplit;
-import static com.microsoft.build.BuilderUtil.splitUidWithGenericsIntoClassNames;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
+import jdk.javadoc.doclet.DocletEnvironment;
+import org.apache.commons.lang3.RegExUtils;
class ReferenceBuilder {
- private final Pattern JAVA_PATTERN = Pattern.compile("^java.*");
- private final Pattern PROTOBUF_PATTERN = Pattern.compile("^com.google.protobuf.*");
- private final Pattern GAX_PATTERN = Pattern.compile("^com.google.api.gax.*");
- private final Pattern APICOMMON_PATTERN = Pattern.compile("^com.google.api.core.*");
- private final Pattern LONGRUNNING_PATTERN = Pattern.compile("^com.google.longrunning.*");
- private final Pattern ENDING_PATTERN = Pattern.compile(".*<\\?>$");
- private final String PRIMITIVE_URL = "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html";
- private final String JAVA_BASE_URL = "https://docs.oracle.com/javase/8/docs/api/";
- private final DocletEnvironment environment;
- private final ClassLookup classLookup;
- private final ElementUtil elementUtil;
-
- ReferenceBuilder(DocletEnvironment environment, ClassLookup classLookup, ElementUtil elementUtil) {
- this.environment = environment;
- this.classLookup = classLookup;
- this.elementUtil = elementUtil;
+ private final Pattern JAVA_PATTERN = Pattern.compile("^java.*");
+ private final Pattern PROTOBUF_PATTERN = Pattern.compile("^com.google.protobuf.*");
+ private final Pattern GAX_PATTERN = Pattern.compile("^com.google.api.gax.*");
+ private final Pattern APICOMMON_PATTERN = Pattern.compile("^com.google.api.core.*");
+ private final Pattern LONGRUNNING_PATTERN = Pattern.compile("^com.google.longrunning.*");
+ private final Pattern ENDING_PATTERN = Pattern.compile(".*<\\?>$");
+ private final String PRIMITIVE_URL =
+ "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html";
+ private final String JAVA_BASE_URL = "https://docs.oracle.com/javase/8/docs/api/";
+ private final DocletEnvironment environment;
+ private final ClassLookup classLookup;
+ private final ElementUtil elementUtil;
+
+ ReferenceBuilder(
+ DocletEnvironment environment, ClassLookup classLookup, ElementUtil elementUtil) {
+ this.environment = environment;
+ this.classLookup = classLookup;
+ this.elementUtil = elementUtil;
+ }
+
+ MetadataFileItem buildClassReference(TypeElement classElement) {
+ MetadataFileItem referenceItem = new MetadataFileItem(classLookup.extractUid(classElement));
+ referenceItem.setName(classLookup.extractName(classElement));
+ referenceItem.setNameWithType(classLookup.extractNameWithType(classElement));
+ referenceItem.setFullName(classLookup.extractFullName(classElement));
+ return referenceItem;
+ }
+
+ void addReferencesInfo(TypeElement classElement, MetadataFile classMetadataFile) {
+ MetadataFileItem classReference = new MetadataFileItem(classLookup.extractUid(classElement));
+ classReference.setParent(classLookup.extractParent(classElement));
+ populateItemFields(classReference, classLookup, classElement);
+ classReference.setTypeParameters(classLookup.extractTypeParameters(classElement));
+
+ addTypeParameterReferences(classReference, classMetadataFile);
+ addSuperclassAndInterfacesReferences(classElement, classMetadataFile);
+ addInnerClassesReferences(classElement, classMetadataFile);
+ }
+
+ void addChildrenReferences(
+ Element element, List packageChildren, Set referencesCollector) {
+ for (TypeElement classElement : elementUtil.extractSortedElements(element)) {
+ referencesCollector.add(buildClassReference(classElement));
+
+ packageChildren.add(classLookup.extractUid(classElement));
+ addChildrenReferences(classElement, packageChildren, referencesCollector);
}
+ }
- MetadataFileItem buildClassReference(TypeElement classElement) {
- MetadataFileItem referenceItem = new MetadataFileItem(classLookup.extractUid(classElement));
- referenceItem.setName(classLookup.extractName(classElement));
- referenceItem.setNameWithType(classLookup.extractNameWithType(classElement));
- referenceItem.setFullName(classLookup.extractFullName(classElement));
- return referenceItem;
+ String getJavaReferenceHref(String uid) {
+ if (uid == null || uid.equals("")) {
+ return JAVA_BASE_URL;
}
-
- void addReferencesInfo(TypeElement classElement, MetadataFile classMetadataFile) {
- MetadataFileItem classReference = new MetadataFileItem(classLookup.extractUid(classElement));
- classReference.setParent(classLookup.extractParent(classElement));
- populateItemFields(classReference, classLookup, classElement);
- classReference.setTypeParameters(classLookup.extractTypeParameters(classElement));
-
- addTypeParameterReferences(classReference, classMetadataFile);
- addSuperclassAndInterfacesReferences(classElement, classMetadataFile);
- addInnerClassesReferences(classElement, classMetadataFile);
+ // example1 uid: "java.lang.Object.equals(java.lang.Object)"
+ // example2 uid: "java.lang.Object"
+ String endURL = uid.replaceAll("", "");
+
+ Pattern argPattern = Pattern.compile(".*\\(.*\\).*");
+ if (argPattern.matcher(endURL).find()) {
+ // example1
+ // argumentSplit: ["java.lang.Object.equals", "java.lang.Object)"]
+ // nameSplit: ["java", "lang", "Object", "equals"]
+ List argumentSplit = Arrays.asList(endURL.split("\\("));
+ List nameSplit = Arrays.asList(argumentSplit.get(0).split("\\."));
+
+ // className: "java/lang/Object"
+ // methodName: "#equals"
+ // argumentsName: "#java.lang.Object-"
+ String className = String.join("/", nameSplit.subList(0, nameSplit.size() - 1));
+ String methodName = "#" + nameSplit.get(nameSplit.size() - 1);
+ String argumentsName = argumentSplit.get(1).replaceAll("[,)]", "-");
+
+ // endURL: "java/lang/Object.html#equals-java.lang.Object-"
+ endURL = className + ".html" + methodName + "-" + argumentsName;
+ } else {
+ // example2
+ // endURL = java/lang/Object.html
+ endURL = endURL.replaceAll("\\.", "/");
+ endURL = endURL + ".html";
}
+ return JAVA_BASE_URL + endURL;
+ }
- void addChildrenReferences(Element element, List packageChildren,
- Set referencesCollector) {
- for (TypeElement classElement : elementUtil.extractSortedElements(element)) {
- referencesCollector.add(buildClassReference(classElement));
+ void updateExternalReferences(List classMetadataFiles) {
+ classMetadataFiles.forEach(
+ file -> file.getReferences().forEach(ref -> updateExternalReference(ref)));
+ }
- packageChildren.add(classLookup.extractUid(classElement));
- addChildrenReferences(classElement, packageChildren, referencesCollector);
- }
- }
+ private void updateExternalReference(MetadataFileItem reference) {
+ String uid = reference.getUid();
+ uid = updateReferenceUid(uid);
- String getJavaReferenceHref(String uid) {
- if (uid == null || uid.equals("")) {
- return JAVA_BASE_URL;
- }
- // example1 uid: "java.lang.Object.equals(java.lang.Object)"
- // example2 uid: "java.lang.Object"
- String endURL = uid.replaceAll("", "");
-
- Pattern argPattern = Pattern.compile(".*\\(.*\\).*");
- if (argPattern.matcher(endURL).find()) {
- // example1
- // argumentSplit: ["java.lang.Object.equals", "java.lang.Object)"]
- // nameSplit: ["java", "lang", "Object", "equals"]
- List argumentSplit = Arrays.asList(endURL.split("\\("));
- List nameSplit = Arrays.asList(argumentSplit.get(0).split("\\."));
-
- // className: "java/lang/Object"
- // methodName: "#equals"
- // argumentsName: "#java.lang.Object-"
- String className = String.join("/", nameSplit.subList(0, nameSplit.size() - 1));
- String methodName = "#" + nameSplit.get(nameSplit.size() - 1);
- String argumentsName = argumentSplit.get(1).replaceAll("[,)]", "-");
-
- // endURL: "java/lang/Object.html#equals-java.lang.Object-"
- endURL = className + ".html" + methodName + "-" + argumentsName;
- } else {
- // example2
- // endURL = java/lang/Object.html
- endURL = endURL.replaceAll("\\.", "/");
- endURL = endURL + ".html";
- }
- return JAVA_BASE_URL + endURL;
+ if (isJavaPrimitive(uid)) {
+ reference.setHref(PRIMITIVE_URL);
+ return;
}
-
- void updateExternalReferences(List classMetadataFiles) {
- classMetadataFiles.forEach(file -> file.getReferences()
- .forEach(ref -> updateExternalReference(ref)));
+ if (isJavaLibrary(uid)) {
+ reference.setHref(getJavaReferenceHref(uid));
}
-
- private void updateExternalReference(MetadataFileItem reference) {
- String uid = reference.getUid();
- uid = updateReferenceUid(uid);
-
- if (isJavaPrimitive(uid)) {
- reference.setHref(PRIMITIVE_URL);
- return;
- }
- if (isJavaLibrary(uid)) {
- reference.setHref(getJavaReferenceHref(uid));
- }
- if (isExternalReference(uid)) {
- reference.setIsExternal(true);
- }
- if (reference.getSpecForJava().size() > 0) {
- for (SpecViewModel spec : reference.getSpecForJava()) {
- String specUid = spec.getUid();
- if (specUid != null) {
- if (isJavaPrimitive(specUid)) {
- spec.setHref(PRIMITIVE_URL);
- }
- if (isJavaLibrary(specUid)) {
- spec.setHref(getJavaReferenceHref(specUid));
- }
- if (isExternalReference(specUid)) {
- spec.setIsExternal(true);
- }
- }
- }
- }
+ if (isExternalReference(uid)) {
+ reference.setIsExternal(true);
}
-
- private String updateReferenceUid(String uid) {
- if (ENDING_PATTERN.matcher(uid).find()) {
- uid = uid.replace(">", "");
+ if (reference.getSpecForJava().size() > 0) {
+ for (SpecViewModel spec : reference.getSpecForJava()) {
+ String specUid = spec.getUid();
+ if (specUid != null) {
+ if (isJavaPrimitive(specUid)) {
+ spec.setHref(PRIMITIVE_URL);
+ }
+ if (isJavaLibrary(specUid)) {
+ spec.setHref(getJavaReferenceHref(specUid));
+ }
+ if (isExternalReference(specUid)) {
+ spec.setIsExternal(true);
+ }
}
- return uid;
- }
-
- private boolean isExternalReference(String uid) {
- return (PROTOBUF_PATTERN.matcher(uid).find() || GAX_PATTERN.matcher(uid).find() || APICOMMON_PATTERN.matcher(uid).find() || GAX_PATTERN.matcher(uid).find() || LONGRUNNING_PATTERN.matcher(uid).find());
+ }
}
+ }
- private boolean isJavaPrimitive(String uid) {
- return (uid.equals("boolean") || uid.equals("int") || uid.equals("byte") || uid.equals("long") || uid.equals("float") || uid.equals("double") || uid.equals("char") || uid.equals("short"));
+ private String updateReferenceUid(String uid) {
+ if (ENDING_PATTERN.matcher(uid).find()) {
+ uid = uid.replace(">", "");
}
-
- private boolean isJavaLibrary(String uid) {
- return JAVA_PATTERN.matcher(uid).find();
- }
-
- void addParameterReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().addAll(
- methodItem.getSyntax().getParameters().stream()
- .map(parameter -> buildRefItem(parameter.getType()))
- .filter(o -> !classMetadataFile.getItems().contains(o))
- .collect(Collectors.toList()));
- }
-
- void addReturnReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().addAll(
- Stream.of(methodItem.getSyntax().getReturnValue())
- .filter(Objects::nonNull)
- .map(returnValue -> buildRefItem(returnValue.getReturnType()))
- .filter(o -> !classMetadataFile.getItems().contains(o))
- .collect(Collectors.toList()));
- }
-
- void addExceptionReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().addAll(
- methodItem.getExceptions().stream()
- .map(exceptionItem -> buildRefItem(exceptionItem.getType()))
- .filter(o -> !classMetadataFile.getItems().contains(o))
- .collect(Collectors.toList()));
+ return uid;
+ }
+
+ private boolean isExternalReference(String uid) {
+ return (PROTOBUF_PATTERN.matcher(uid).find()
+ || GAX_PATTERN.matcher(uid).find()
+ || APICOMMON_PATTERN.matcher(uid).find()
+ || GAX_PATTERN.matcher(uid).find()
+ || LONGRUNNING_PATTERN.matcher(uid).find());
+ }
+
+ private boolean isJavaPrimitive(String uid) {
+ return (uid.equals("boolean")
+ || uid.equals("int")
+ || uid.equals("byte")
+ || uid.equals("long")
+ || uid.equals("float")
+ || uid.equals("double")
+ || uid.equals("char")
+ || uid.equals("short"));
+ }
+
+ private boolean isJavaLibrary(String uid) {
+ return JAVA_PATTERN.matcher(uid).find();
+ }
+
+ void addParameterReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
+ classMetadataFile
+ .getReferences()
+ .addAll(
+ methodItem.getSyntax().getParameters().stream()
+ .map(parameter -> buildRefItem(parameter.getType()))
+ .filter(o -> !classMetadataFile.getItems().contains(o))
+ .collect(Collectors.toList()));
+ }
+
+ void addReturnReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
+ classMetadataFile
+ .getReferences()
+ .addAll(
+ Stream.of(methodItem.getSyntax().getReturnValue())
+ .filter(Objects::nonNull)
+ .map(returnValue -> buildRefItem(returnValue.getReturnType()))
+ .filter(o -> !classMetadataFile.getItems().contains(o))
+ .collect(Collectors.toList()));
+ }
+
+ void addExceptionReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
+ classMetadataFile
+ .getReferences()
+ .addAll(
+ methodItem.getExceptions().stream()
+ .map(exceptionItem -> buildRefItem(exceptionItem.getType()))
+ .filter(o -> !classMetadataFile.getItems().contains(o))
+ .collect(Collectors.toList()));
+ }
+
+ void addTypeParameterReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
+ classMetadataFile
+ .getReferences()
+ .addAll(
+ methodItem.getSyntax().getTypeParameters().stream()
+ .map(
+ typeParameter -> {
+ String id = typeParameter.getId();
+ return new MetadataFileItem(id, id, false);
+ })
+ .collect(Collectors.toList()));
+ }
+
+ void addSuperclassAndInterfacesReferences(
+ TypeElement classElement, MetadataFile classMetadataFile) {
+ classMetadataFile.getReferences().addAll(classLookup.extractReferences(classElement));
+ }
+
+ void addInnerClassesReferences(TypeElement classElement, MetadataFile classMetadataFile) {
+ classMetadataFile
+ .getReferences()
+ .addAll(
+ ElementFilter.typesIn(elementUtil.extractSortedElements(classElement)).stream()
+ .map(this::buildClassReference)
+ .collect(Collectors.toList()));
+ }
+
+ void addOverloadReferences(MetadataFileItem item, MetadataFile classMetadataFile) {
+ classMetadataFile
+ .getReferences()
+ .add(
+ new MetadataFileItem(item.getOverload()) {
+ {
+ setName(RegExUtils.removeAll(item.getName(), "\\(.*\\)$"));
+ setNameWithType(RegExUtils.removeAll(item.getNameWithType(), "\\(.*\\)$"));
+ setFullName(RegExUtils.removeAll(item.getFullName(), "\\(.*\\)$"));
+ setPackageName(item.getPackageName());
+ }
+ });
+ }
+
+ /**
+ * Replace one record in 'references' with several records in this way:
+ *
+ *
+ * a.b.c.List> ->
+ * - a.b.c.List
+ * - df.mn.ClassOne
+ * - tr.T
+ *
+ */
+ void expandComplexGenericsInReferences(MetadataFile classMetadataFile) {
+ Set additionalItems = new LinkedHashSet<>();
+ Iterator iterator = classMetadataFile.getReferences().iterator();
+ while (iterator.hasNext()) {
+ MetadataFileItem item = iterator.next();
+ String uid = item.getUid();
+ if (!uid.endsWith("*") && uid.contains("<")) {
+ List classNames = splitUidWithGenericsIntoClassNames(uid);
+ additionalItems.addAll(
+ classNames.stream()
+ .map(s -> new MetadataFileItem(s, classLookup.makeTypeShort(s), false))
+ .collect(Collectors.toSet()));
+ }
}
-
- void addTypeParameterReferences(MetadataFileItem methodItem, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().addAll(
- methodItem.getSyntax().getTypeParameters().stream()
- .map(typeParameter -> {
- String id = typeParameter.getId();
- return new MetadataFileItem(id, id, false);
- }).collect(Collectors.toList()));
- }
-
- void addSuperclassAndInterfacesReferences(TypeElement classElement, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().addAll(classLookup.extractReferences(classElement));
- }
-
- void addInnerClassesReferences(TypeElement classElement, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().addAll(
- ElementFilter.typesIn(elementUtil.extractSortedElements(classElement)).stream()
- .map(this::buildClassReference)
- .collect(Collectors.toList()));
- }
-
- void addOverloadReferences(MetadataFileItem item, MetadataFile classMetadataFile) {
- classMetadataFile.getReferences().add(new MetadataFileItem(item.getOverload()) {{
- setName(RegExUtils.removeAll(item.getName(), "\\(.*\\)$"));
- setNameWithType(RegExUtils.removeAll(item.getNameWithType(), "\\(.*\\)$"));
- setFullName(RegExUtils.removeAll(item.getFullName(), "\\(.*\\)$"));
- setPackageName(item.getPackageName());
- }});
- }
-
- /**
- * Replace one record in 'references' with several records in this way:
- *
- * a.b.c.List> ->
- * - a.b.c.List
- * - df.mn.ClassOne
- * - tr.T
- *
- */
- void expandComplexGenericsInReferences(MetadataFile classMetadataFile) {
- Set additionalItems = new LinkedHashSet<>();
- Iterator iterator = classMetadataFile.getReferences().iterator();
- while (iterator.hasNext()) {
- MetadataFileItem item = iterator.next();
- String uid = item.getUid();
- if (!uid.endsWith("*") && uid.contains("<")) {
- List classNames = splitUidWithGenericsIntoClassNames(uid);
- additionalItems.addAll(classNames.stream()
- .map(s -> new MetadataFileItem(s, classLookup.makeTypeShort(s), false))
- .collect(Collectors.toSet()));
- }
- }
- // Remove items which already exist in 'items' section (compared by 'uid' field)
- additionalItems.removeAll(classMetadataFile.getItems());
-
- classMetadataFile.getReferences().addAll(additionalItems);
- }
-
- MetadataFileItem buildRefItem(String uid) {
- if (!uid.endsWith("*") && (uid.contains("<") || uid.contains("[]"))) {
- return new MetadataFileItem(uid, getJavaSpec(replaceUidAndSplit(uid)));
- } else {
- List fullNameList = new ArrayList<>();
-
- environment.getIncludedElements().forEach(
- element -> elementUtil.extractSortedElements(element).forEach(
- typeElement -> fullNameList.add(classLookup.extractFullName(typeElement)))
- );
-
- if (fullNameList.contains(uid)) {
- return new MetadataFileItem(uid, classLookup.makeTypeShort(uid), false);
- } else {
- return new MetadataFileItem(uid, getJavaSpec(replaceUidAndSplit(uid)));
- }
- }
+ // Remove items which already exist in 'items' section (compared by 'uid' field)
+ additionalItems.removeAll(classMetadataFile.getItems());
+
+ classMetadataFile.getReferences().addAll(additionalItems);
+ }
+
+ MetadataFileItem buildRefItem(String uid) {
+ if (!uid.endsWith("*") && (uid.contains("<") || uid.contains("[]"))) {
+ return new MetadataFileItem(uid, getJavaSpec(replaceUidAndSplit(uid)));
+ } else {
+ List fullNameList = new ArrayList<>();
+
+ environment
+ .getIncludedElements()
+ .forEach(
+ element ->
+ elementUtil
+ .extractSortedElements(element)
+ .forEach(
+ typeElement ->
+ fullNameList.add(classLookup.extractFullName(typeElement))));
+
+ if (fullNameList.contains(uid)) {
+ return new MetadataFileItem(uid, classLookup.makeTypeShort(uid), false);
+ } else {
+ return new MetadataFileItem(uid, getJavaSpec(replaceUidAndSplit(uid)));
+ }
}
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/YmlFilesBuilder.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/YmlFilesBuilder.java
index 7288b135..7e0d1f66 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/YmlFilesBuilder.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/build/YmlFilesBuilder.java
@@ -1,5 +1,7 @@
package com.microsoft.build;
+import static com.microsoft.build.BuilderUtil.populateUidValues;
+
import com.microsoft.lookup.ClassItemsLookup;
import com.microsoft.lookup.ClassLookup;
import com.microsoft.lookup.PackageLookup;
@@ -10,105 +12,115 @@
import com.microsoft.model.TocTypeMap;
import com.microsoft.util.ElementUtil;
import com.microsoft.util.FileUtil;
-import jdk.javadoc.doclet.DocletEnvironment;
-
-import javax.lang.model.element.PackageElement;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
-
-import static com.microsoft.build.BuilderUtil.populateUidValues;
+import javax.lang.model.element.PackageElement;
+import jdk.javadoc.doclet.DocletEnvironment;
public class YmlFilesBuilder {
- private DocletEnvironment environment;
- private String outputPath;
- private ElementUtil elementUtil;
- private PackageLookup packageLookup;
- private String projectName;
- private boolean disableChangelog;
- private ProjectBuilder projectBuilder;
- private PackageBuilder packageBuilder;
- private ClassBuilder classBuilder;
- private ReferenceBuilder referenceBuilder;
+ private DocletEnvironment environment;
+ private String outputPath;
+ private ElementUtil elementUtil;
+ private PackageLookup packageLookup;
+ private String projectName;
+ private boolean disableChangelog;
+ private ProjectBuilder projectBuilder;
+ private PackageBuilder packageBuilder;
+ private ClassBuilder classBuilder;
+ private ReferenceBuilder referenceBuilder;
- public YmlFilesBuilder(DocletEnvironment environment, String outputPath,
- String[] excludePackages, String[] excludeClasses, String projectName, boolean disableChangelog) {
- this.environment = environment;
- this.outputPath = outputPath;
- this.elementUtil = new ElementUtil(excludePackages, excludeClasses);
- this.packageLookup = new PackageLookup(environment);
- this.projectName = projectName;
- this.disableChangelog = disableChangelog;
- this.projectBuilder = new ProjectBuilder(projectName);
- ClassLookup classLookup = new ClassLookup(environment, elementUtil);
- this.referenceBuilder = new ReferenceBuilder(environment, classLookup, elementUtil);
- this.packageBuilder = new PackageBuilder(packageLookup, outputPath, referenceBuilder);
- this.classBuilder = new ClassBuilder(elementUtil, classLookup, new ClassItemsLookup(environment, elementUtil), outputPath, referenceBuilder);
- }
+ public YmlFilesBuilder(
+ DocletEnvironment environment,
+ String outputPath,
+ String[] excludePackages,
+ String[] excludeClasses,
+ String projectName,
+ boolean disableChangelog) {
+ this.environment = environment;
+ this.outputPath = outputPath;
+ this.elementUtil = new ElementUtil(excludePackages, excludeClasses);
+ this.packageLookup = new PackageLookup(environment);
+ this.projectName = projectName;
+ this.disableChangelog = disableChangelog;
+ this.projectBuilder = new ProjectBuilder(projectName);
+ ClassLookup classLookup = new ClassLookup(environment, elementUtil);
+ this.referenceBuilder = new ReferenceBuilder(environment, classLookup, elementUtil);
+ this.packageBuilder = new PackageBuilder(packageLookup, outputPath, referenceBuilder);
+ this.classBuilder =
+ new ClassBuilder(
+ elementUtil,
+ classLookup,
+ new ClassItemsLookup(environment, elementUtil),
+ outputPath,
+ referenceBuilder);
+ }
- public boolean build() {
- // table of contents
- TocFile tocFile = new TocFile(outputPath, projectName, disableChangelog);
- // overview page
- MetadataFile projectMetadataFile = new MetadataFile(outputPath, "overview.yml");
- // package summary pages
- List packageMetadataFiles = new ArrayList<>();
- // packages
- List packageItems = new ArrayList<>();
- // class/enum/interface/etc. pages
- List classMetadataFiles = new ArrayList<>();
+ public boolean build() {
+ // table of contents
+ TocFile tocFile = new TocFile(outputPath, projectName, disableChangelog);
+ // overview page
+ MetadataFile projectMetadataFile = new MetadataFile(outputPath, "overview.yml");
+ // package summary pages
+ List packageMetadataFiles = new ArrayList<>();
+ // packages
+ List packageItems = new ArrayList<>();
+ // class/enum/interface/etc. pages
+ List classMetadataFiles = new ArrayList<>();
- for (PackageElement packageElement :
- elementUtil.extractPackageElements(environment.getIncludedElements())) {
- String packageUid = packageLookup.extractUid(packageElement);
- String packageStatus = packageLookup.extractStatus(packageElement);
- TocItem packageTocItem = new TocItem(packageUid, packageUid, packageStatus);
- // build package summary
- packageMetadataFiles.add(packageBuilder.buildPackageMetadataFile(packageElement));
- // add package summary to toc
- packageTocItem.getItems().add(new TocItem(packageUid, "Package summary"));
- tocFile.addTocItem(packageTocItem);
+ for (PackageElement packageElement :
+ elementUtil.extractPackageElements(environment.getIncludedElements())) {
+ String packageUid = packageLookup.extractUid(packageElement);
+ String packageStatus = packageLookup.extractStatus(packageElement);
+ TocItem packageTocItem = new TocItem(packageUid, packageUid, packageStatus);
+ // build package summary
+ packageMetadataFiles.add(packageBuilder.buildPackageMetadataFile(packageElement));
+ // add package summary to toc
+ packageTocItem.getItems().add(new TocItem(packageUid, "Package summary"));
+ tocFile.addTocItem(packageTocItem);
- // build classes/interfaces/enums/exceptions/annotations
- TocTypeMap typeMap = new TocTypeMap();
- classBuilder.buildFilesForInnerClasses(packageElement, typeMap, classMetadataFiles);
- packageTocItem.getItems().addAll(joinTocTypeItems(typeMap));
- }
+ // build classes/interfaces/enums/exceptions/annotations
+ TocTypeMap typeMap = new TocTypeMap();
+ classBuilder.buildFilesForInnerClasses(packageElement, typeMap, classMetadataFiles);
+ packageTocItem.getItems().addAll(joinTocTypeItems(typeMap));
+ }
- for (MetadataFile packageFile : packageMetadataFiles) {
- packageItems.addAll(packageFile.getItems());
- String packageFileName = packageFile.getFileName();
- for (MetadataFile classFile : classMetadataFiles) {
- String classFileName = classFile.getFileName();
- if (packageFileName.equalsIgnoreCase(classFileName)) {
- packageFile.setFileName(packageFileName.replaceAll("\\.yml$", "(package).yml"));
- classFile.setFileName(classFileName.replaceAll("\\.yml$", "(class).yml"));
- break;
- }
- }
+ for (MetadataFile packageFile : packageMetadataFiles) {
+ packageItems.addAll(packageFile.getItems());
+ String packageFileName = packageFile.getFileName();
+ for (MetadataFile classFile : classMetadataFiles) {
+ String classFileName = classFile.getFileName();
+ if (packageFileName.equalsIgnoreCase(classFileName)) {
+ packageFile.setFileName(packageFileName.replaceAll("\\.yml$", "(package).yml"));
+ classFile.setFileName(classFileName.replaceAll("\\.yml$", "(class).yml"));
+ break;
}
- // build project summary page
- projectBuilder.buildProjectMetadataFile(packageItems, projectMetadataFile);
+ }
+ }
+ // build project summary page
+ projectBuilder.buildProjectMetadataFile(packageItems, projectMetadataFile);
- // post-processing
- populateUidValues(packageMetadataFiles, classMetadataFiles);
- referenceBuilder.updateExternalReferences(classMetadataFiles);
+ // post-processing
+ populateUidValues(packageMetadataFiles, classMetadataFiles);
+ referenceBuilder.updateExternalReferences(classMetadataFiles);
- // write to yaml files
- FileUtil.dumpToFile(projectMetadataFile);
- packageMetadataFiles.forEach(FileUtil::dumpToFile);
- classMetadataFiles.forEach(FileUtil::dumpToFile);
- FileUtil.dumpToFile(tocFile);
+ // write to yaml files
+ FileUtil.dumpToFile(projectMetadataFile);
+ packageMetadataFiles.forEach(FileUtil::dumpToFile);
+ classMetadataFiles.forEach(FileUtil::dumpToFile);
+ FileUtil.dumpToFile(tocFile);
- return true;
- }
+ return true;
+ }
- List joinTocTypeItems(TocTypeMap tocTypeMap) {
- return tocTypeMap.getTitleList().stream()
- .filter(kindTitle -> tocTypeMap.get(kindTitle.getElementKind()).size() > 0)
- .flatMap(kindTitle -> {
- tocTypeMap.get(kindTitle.getElementKind()).add(0, new TocItem(kindTitle.getTitle()));
- return tocTypeMap.get(kindTitle.getElementKind()).stream();
- }).collect(Collectors.toList());
- }
+ List joinTocTypeItems(TocTypeMap tocTypeMap) {
+ return tocTypeMap.getTitleList().stream()
+ .filter(kindTitle -> tocTypeMap.get(kindTitle.getElementKind()).size() > 0)
+ .flatMap(
+ kindTitle -> {
+ tocTypeMap.get(kindTitle.getElementKind()).add(0, new TocItem(kindTitle.getTitle()));
+ return tocTypeMap.get(kindTitle.getElementKind()).stream();
+ })
+ .collect(Collectors.toList());
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocFxDoclet.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocFxDoclet.java
index 20050e74..7d9c5f15 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocFxDoclet.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocFxDoclet.java
@@ -1,156 +1,171 @@
package com.microsoft.doclet;
import com.microsoft.build.YmlFilesBuilder;
+import java.util.*;
+import javax.lang.model.SourceVersion;
+import javax.tools.Diagnostic.Kind;
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter;
import org.apache.commons.lang3.StringUtils;
-import javax.lang.model.SourceVersion;
-import javax.tools.Diagnostic.Kind;
-import java.util.*;
-
public class DocFxDoclet implements Doclet {
- private Reporter reporter;
+ private Reporter reporter;
+
+ @Override
+ public void init(Locale locale, Reporter reporter) {
+ reporter.print(Kind.NOTE, "Doclet using locale: " + locale);
+ this.reporter = reporter;
+ }
+
+ @Override
+ public boolean run(DocletEnvironment environment) {
+ reporter.print(Kind.NOTE, "Output path: " + outputPath);
+ reporter.print(Kind.NOTE, "Excluded packages: " + Arrays.toString(excludePackages));
+ reporter.print(Kind.NOTE, "Excluded classes: " + Arrays.toString(excludeClasses));
+ reporter.print(Kind.NOTE, "Project name: " + projectName);
+ reporter.print(Kind.NOTE, "Disable changelog: " + disableChangelog);
+
+ return (new YmlFilesBuilder(
+ environment,
+ outputPath,
+ excludePackages,
+ excludeClasses,
+ projectName,
+ disableChangelog))
+ .build();
+ }
+
+ @Override
+ public String getName() {
+ return "DocFxDoclet";
+ }
+
+ private String outputPath;
+ private String[] excludePackages = {};
+ private String[] excludeClasses = {};
+ private String projectName;
+ private boolean disableChangelog;
+
+ @Override
+ public Set extends Option> getSupportedOptions() {
+ Option[] options = {
+ new CustomOption("Output path", Arrays.asList("-outputpath", "--output-path", "-d"), "path") {
+ @Override
+ public boolean process(String option, List arguments) {
+ outputPath = arguments.get(0);
+ return true;
+ }
+ },
+ new CustomOption(
+ "Exclude packages",
+ Arrays.asList("-excludepackages", "--exclude-packages", "-ep"),
+ "packages") {
+ @Override
+ public boolean process(String option, List arguments) {
+ excludePackages = StringUtils.split(arguments.get(0), ":");
+ return true;
+ }
+ },
+ new CustomOption(
+ "Exclude classes",
+ Arrays.asList("-excludeclasses", "--exclude-classes", "-ec"),
+ "classes") {
+ @Override
+ public boolean process(String option, List arguments) {
+ excludeClasses = StringUtils.split(arguments.get(0), ":");
+ return true;
+ }
+ },
+ new CustomOption(
+ "Project name", Arrays.asList("-projectname", "--project-name", "-pn"), "name") {
+ @Override
+ public boolean process(String option, List arguments) {
+ // using artifact id as projectName - remove "-parent" since generation runs in parent
+ // pom
+ projectName = arguments.get(0).replaceAll("-parent", "");
+ return true;
+ }
+ },
+ new CustomOption(
+ "Disable changelog",
+ Arrays.asList("-disable-changelog", "--disable-changelog"),
+ "disableChangelog") {
+ @Override
+ public boolean process(String option, List arguments) {
+ if (arguments.get(0).equalsIgnoreCase("false")) {
+ disableChangelog = false;
+ } else {
+ disableChangelog = true;
+ }
+ return true;
+ }
+ },
+ // Support next properties for compatibility with Gradle javadoc task.
+ // According to javadoc spec - these properties used by StandardDoclet and used only when
+ // 'doclet' parameter not populated. But Gradle javadoc not align with this rule and
+ // passes them in spite of 'doclet' parameter existence
+ new FakeOptionForCompatibilityWithStandardDoclet(
+ "Fake support of doctitle property", "-doctitle"),
+ new FakeOptionForCompatibilityWithStandardDoclet(
+ "Fake support of windowtitle property", "-windowtitle")
+ };
+ return new HashSet<>(Arrays.asList(options));
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ abstract static class CustomOption implements Option {
+
+ private final String description;
+ private final List names;
+ private final String parameters;
+
+ public CustomOption(String description, List names, String parameters) {
+ this.description = description;
+ this.names = names;
+ this.parameters = parameters;
+ }
@Override
- public void init(Locale locale, Reporter reporter) {
- reporter.print(Kind.NOTE, "Doclet using locale: " + locale);
- this.reporter = reporter;
+ public int getArgumentCount() {
+ return 1;
}
@Override
- public boolean run(DocletEnvironment environment) {
- reporter.print(Kind.NOTE, "Output path: " + outputPath);
- reporter.print(Kind.NOTE, "Excluded packages: " + Arrays.toString(excludePackages));
- reporter.print(Kind.NOTE, "Excluded classes: " + Arrays.toString(excludeClasses));
- reporter.print(Kind.NOTE, "Project name: " + projectName);
- reporter.print(Kind.NOTE, "Disable changelog: " + disableChangelog);
-
- return (new YmlFilesBuilder(environment, outputPath, excludePackages, excludeClasses, projectName, disableChangelog)).build();
+ public String getDescription() {
+ return description;
}
@Override
- public String getName() {
- return "DocFxDoclet";
+ public Kind getKind() {
+ return Kind.STANDARD;
}
- private String outputPath;
- private String[] excludePackages = {};
- private String[] excludeClasses = {};
- private String projectName;
- private boolean disableChangelog;
-
@Override
- public Set extends Option> getSupportedOptions() {
- Option[] options = {
- new CustomOption("Output path", Arrays.asList("-outputpath", "--output-path", "-d"), "path") {
- @Override
- public boolean process(String option, List arguments) {
- outputPath = arguments.get(0);
- return true;
- }
- },
- new CustomOption("Exclude packages", Arrays.asList("-excludepackages", "--exclude-packages", "-ep"),
- "packages") {
- @Override
- public boolean process(String option, List arguments) {
- excludePackages = StringUtils.split(arguments.get(0), ":");
- return true;
- }
- },
- new CustomOption("Exclude classes", Arrays.asList("-excludeclasses", "--exclude-classes", "-ec"),
- "classes") {
- @Override
- public boolean process(String option, List arguments) {
- excludeClasses = StringUtils.split(arguments.get(0), ":");
- return true;
- }
- },
- new CustomOption(
- "Project name", Arrays.asList("-projectname", "--project-name", "-pn"), "name") {
- @Override
- public boolean process(String option, List arguments) {
- // using artifact id as projectName - remove "-parent" since generation runs in parent pom
- projectName = arguments.get(0).replaceAll("-parent", "");
- return true;
- }
- },
- new CustomOption(
- "Disable changelog", Arrays.asList("-disable-changelog", "--disable-changelog"), "disableChangelog") {
- @Override
- public boolean process(String option, List arguments) {
- if (arguments.get(0).equalsIgnoreCase("false")){
- disableChangelog = false;
- } else {
- disableChangelog = true;
- }
- return true;
- }
- },
- // Support next properties for compatibility with Gradle javadoc task.
- // According to javadoc spec - these properties used by StandardDoclet and used only when
- // 'doclet' parameter not populated. But Gradle javadoc not align with this rule and
- // passes them in spite of 'doclet' parameter existence
- new FakeOptionForCompatibilityWithStandardDoclet("Fake support of doctitle property", "-doctitle"),
- new FakeOptionForCompatibilityWithStandardDoclet("Fake support of windowtitle property", "-windowtitle")
- };
- return new HashSet<>(Arrays.asList(options));
+ public List getNames() {
+ return names;
}
@Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
+ public String getParameters() {
+ return parameters;
}
+ }
- abstract static class CustomOption implements Option {
+ static class FakeOptionForCompatibilityWithStandardDoclet extends CustomOption {
- private final String description;
- private final List names;
- private final String parameters;
-
- public CustomOption(String description, List names, String parameters) {
- this.description = description;
- this.names = names;
- this.parameters = parameters;
- }
-
- @Override
- public int getArgumentCount() {
- return 1;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public Kind getKind() {
- return Kind.STANDARD;
- }
-
- @Override
- public List getNames() {
- return names;
- }
-
- @Override
- public String getParameters() {
- return parameters;
- }
+ public FakeOptionForCompatibilityWithStandardDoclet(String description, String name) {
+ super(description, Collections.singletonList(name), "none");
}
- static class FakeOptionForCompatibilityWithStandardDoclet extends CustomOption {
-
- public FakeOptionForCompatibilityWithStandardDoclet(String description, String name) {
- super(description, Collections.singletonList(name), "none");
- }
-
- @Override
- public boolean process(String option, List arguments) {
- return true;
- }
+ @Override
+ public boolean process(String option, List arguments) {
+ return true;
}
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocletRunner.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocletRunner.java
index a96a8af0..f7153bb8 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocletRunner.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/doclet/DocletRunner.java
@@ -14,20 +14,20 @@
*/
public class DocletRunner {
- public static void main(final String[] args) {
- if (args.length < 1) {
- System.err.println("Usage: java DocletRunner ");
- return;
- }
+ public static void main(final String[] args) {
+ if (args.length < 1) {
+ System.err.println("Usage: java DocletRunner ");
+ return;
+ }
- List combined = new ArrayList<>();
- for (String arg : args) {
- if (!(new java.io.File(arg)).isFile()) {
- System.err.println(String.format("File '%s' does not exist", args[0]));
- }
- combined.addAll(OptionsFileUtil.processOptionsFile(arg));
- }
- ToolProvider.getSystemDocumentationTool()
- .run(null, null, null, combined.toArray(new String[0]));
+ List combined = new ArrayList<>();
+ for (String arg : args) {
+ if (!(new java.io.File(arg)).isFile()) {
+ System.err.println(String.format("File '%s' does not exist", args[0]));
+ }
+ combined.addAll(OptionsFileUtil.processOptionsFile(arg));
}
+ ToolProvider.getSystemDocumentationTool()
+ .run(null, null, null, combined.toArray(new String[0]));
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/BaseLookup.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/BaseLookup.java
index ba6b808b..df5eb075 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/BaseLookup.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/BaseLookup.java
@@ -13,13 +13,6 @@
import com.sun.source.doctree.LinkTree;
import com.sun.source.doctree.LiteralTree;
import com.sun.source.doctree.SeeTree;
-import jdk.javadoc.doclet.DocletEnvironment;
-import org.apache.commons.lang3.RegExUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.text.StringEscapeUtils;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -29,276 +22,295 @@
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import jdk.javadoc.doclet.DocletEnvironment;
+import org.apache.commons.lang3.RegExUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
public abstract class BaseLookup {
- private static final int INITIAL_CAPACITY = 500000;
- protected final Map elementKindLookup = new HashMap<>() {{
- put(ElementKind.PACKAGE, "Namespace");
- put(ElementKind.CLASS, "Class");
- put(ElementKind.ENUM, "Enum");
- put(ElementKind.ENUM_CONSTANT, "Field");
- put(ElementKind.INTERFACE, "Interface");
- put(ElementKind.ANNOTATION_TYPE, "Interface");
- put(ElementKind.CONSTRUCTOR, "Constructor");
- put(ElementKind.METHOD, "Method");
- put(ElementKind.FIELD, "Field");
- }};
-
- protected Map map;
- protected final DocletEnvironment environment;
-
- protected BaseLookup(DocletEnvironment environment) {
- this.environment = environment;
- this.map = new HashMap<>(INITIAL_CAPACITY);
- }
-
- protected ExtendedMetadataFileItem resolve(T key) {
- map.computeIfAbsent(key, this::buildMetadataFileItem);
- return map.get(key);
- }
-
- protected abstract ExtendedMetadataFileItem buildMetadataFileItem(T key);
-
- public String extractPackageName(T key) {
- return resolve(key).getPackageName();
- }
-
- public String extractFullName(T key) {
- return resolve(key).getFullName();
- }
-
- public String extractName(T key) {
- return resolve(key).getName();
- }
-
- public String extractHref(T key) {
- return resolve(key).getHref();
- }
-
- public String extractParent(T key) {
- return resolve(key).getParent();
- }
-
- public String extractId(T key) {
- return resolve(key).getId();
- }
-
- public String extractUid(T key) {
- return resolve(key).getUid();
- }
-
- public String extractNameWithType(T key) {
- return resolve(key).getNameWithType();
- }
-
- public String extractMethodContent(T key) {
- return resolve(key).getMethodContent();
- }
-
- public String extractFieldContent(T key) {
- return resolve(key).getFieldContent();
- }
-
- public String extractConstructorContent(T key) {
- return resolve(key).getConstructorContent();
- }
-
- public String extractOverload(T key) {
- return resolve(key).getOverload();
- }
-
- public List extractParameters(T key) {
- return resolve(key).getParameters();
- }
-
- public List extractExceptions(T key) {
- return resolve(key).getExceptions();
- }
-
- public Return extractReturn(T key) {
- return resolve(key).getReturn();
- }
-
- public String extractSummary(T key) {
- return resolve(key).getSummary();
- }
-
- public String extractType(T key) {
- return resolve(key).getType();
- }
-
- public String extractJavaType(T element) {return null;}
-
- public String extractContent(T key) {
- return resolve(key).getContent();
- }
-
- public List extractTypeParameters(T key) {
- return resolve(key).getTypeParameters();
- }
-
- public List extractSuperclass(T key) {
- List reversed = resolve(key).getSuperclass();
- Collections.reverse(reversed);
- return reversed;
- }
-
- public List extractInheritedMethods(T key) {
- List sorted = resolve(key).getInheritedMethods();
- Collections.sort(sorted);
- return sorted;
- }
-
- public List extractInterfaces(T key) {
- return resolve(key).getInterfaces();
- }
-
- public String extractTocName(T key) {
- return resolve(key).getTocName();
- }
-
- public Set extractReferences(T key) {
- return resolve(key).getReferences();
- }
+ private static final int INITIAL_CAPACITY = 500000;
+ protected final Map elementKindLookup =
+ new HashMap<>() {
+ {
+ put(ElementKind.PACKAGE, "Namespace");
+ put(ElementKind.CLASS, "Class");
+ put(ElementKind.ENUM, "Enum");
+ put(ElementKind.ENUM_CONSTANT, "Field");
+ put(ElementKind.INTERFACE, "Interface");
+ put(ElementKind.ANNOTATION_TYPE, "Interface");
+ put(ElementKind.CONSTRUCTOR, "Constructor");
+ put(ElementKind.METHOD, "Method");
+ put(ElementKind.FIELD, "Field");
+ }
+ };
- public String extractOverridden(T key) {
- return resolve(key).getOverridden();
- }
+ protected Map map;
+ protected final DocletEnvironment environment;
- public String extractStatus(T element) {
- Optional docCommentTree = getDocCommentTree(element);
- if (docCommentTree.isPresent()) {
- boolean isDeprecated = docCommentTree.get().getBlockTags().stream()
- .filter(docTree -> docTree.getKind().equals(DocTree.Kind.DEPRECATED))
- .findFirst()
- .isPresent();
- if (isDeprecated) {
- return DocTree.Kind.DEPRECATED.name().toLowerCase();
- }
- }
- return null;
- }
+ protected BaseLookup(DocletEnvironment environment) {
+ this.environment = environment;
+ this.map = new HashMap<>(INITIAL_CAPACITY);
+ }
- protected String determineType(T element) {
- return elementKindLookup.get(element.getKind());
- }
+ protected ExtendedMetadataFileItem resolve(T key) {
+ map.computeIfAbsent(key, this::buildMetadataFileItem);
+ return map.get(key);
+ }
- protected String determinePackageName(T element) {
- return String.valueOf(environment.getElementUtils().getPackageOf(element));
- }
+ protected abstract ExtendedMetadataFileItem buildMetadataFileItem(T key);
- protected String determineComment(T element) {
- Optional docCommentTree = getDocCommentTree(element);
- if (docCommentTree.isPresent()) {
- String comment = docCommentTree
- .map(DocCommentTree::getFullBody)
- .map(this::replaceLinksAndCodes)
- .orElse(null);
- return replaceBlockTags(docCommentTree.get(), comment);
- }
- return null;
- }
+ public String extractPackageName(T key) {
+ return resolve(key).getPackageName();
+ }
- /**
- * Provides support for deprecated and see tags
- */
- String replaceBlockTags(DocCommentTree docCommentTree, String comment) {
- Set seeItems = new HashSet<>();
- String commentWithBlockTags = comment;
- for (DocTree blockTag : docCommentTree.getBlockTags()) {
- switch (blockTag.getKind()) {
- case DEPRECATED:
- commentWithBlockTags = getDeprecatedSummary((DeprecatedTree) blockTag).concat(comment);
- break;
- case SEE:
- seeItems.add(getSeeTagRef((SeeTree) blockTag));
- break;
- default:
- }
- }
- if (!seeItems.isEmpty()) {
- commentWithBlockTags = commentWithBlockTags.concat(getSeeAlsoSummary(seeItems));
- }
- return commentWithBlockTags;
- }
+ public String extractFullName(T key) {
+ return resolve(key).getFullName();
+ }
- /**
- *
- * - Replace @link and @linkplain with tags
- * - Replace @code with
tags
- *
- */
- String replaceLinksAndCodes(List extends DocTree> items) {
- return YamlUtil.cleanupHtml(items.stream().map(
- bodyItem -> {
- switch (bodyItem.getKind()) {
+ public String extractName(T key) {
+ return resolve(key).getName();
+ }
+
+ public String extractHref(T key) {
+ return resolve(key).getHref();
+ }
+
+ public String extractParent(T key) {
+ return resolve(key).getParent();
+ }
+
+ public String extractId(T key) {
+ return resolve(key).getId();
+ }
+
+ public String extractUid(T key) {
+ return resolve(key).getUid();
+ }
+
+ public String extractNameWithType(T key) {
+ return resolve(key).getNameWithType();
+ }
+
+ public String extractMethodContent(T key) {
+ return resolve(key).getMethodContent();
+ }
+
+ public String extractFieldContent(T key) {
+ return resolve(key).getFieldContent();
+ }
+
+ public String extractConstructorContent(T key) {
+ return resolve(key).getConstructorContent();
+ }
+
+ public String extractOverload(T key) {
+ return resolve(key).getOverload();
+ }
+
+ public List extractParameters(T key) {
+ return resolve(key).getParameters();
+ }
+
+ public List extractExceptions(T key) {
+ return resolve(key).getExceptions();
+ }
+
+ public Return extractReturn(T key) {
+ return resolve(key).getReturn();
+ }
+
+ public String extractSummary(T key) {
+ return resolve(key).getSummary();
+ }
+
+ public String extractType(T key) {
+ return resolve(key).getType();
+ }
+
+ public String extractJavaType(T element) {
+ return null;
+ }
+
+ public String extractContent(T key) {
+ return resolve(key).getContent();
+ }
+
+ public List extractTypeParameters(T key) {
+ return resolve(key).getTypeParameters();
+ }
+
+ public List extractSuperclass(T key) {
+ List reversed = resolve(key).getSuperclass();
+ Collections.reverse(reversed);
+ return reversed;
+ }
+
+ public List extractInheritedMethods(T key) {
+ List sorted = resolve(key).getInheritedMethods();
+ Collections.sort(sorted);
+ return sorted;
+ }
+
+ public List extractInterfaces(T key) {
+ return resolve(key).getInterfaces();
+ }
+
+ public String extractTocName(T key) {
+ return resolve(key).getTocName();
+ }
+
+ public Set extractReferences(T key) {
+ return resolve(key).getReferences();
+ }
+
+ public String extractOverridden(T key) {
+ return resolve(key).getOverridden();
+ }
+
+ public String extractStatus(T element) {
+ Optional docCommentTree = getDocCommentTree(element);
+ if (docCommentTree.isPresent()) {
+ boolean isDeprecated =
+ docCommentTree.get().getBlockTags().stream()
+ .filter(docTree -> docTree.getKind().equals(DocTree.Kind.DEPRECATED))
+ .findFirst()
+ .isPresent();
+ if (isDeprecated) {
+ return DocTree.Kind.DEPRECATED.name().toLowerCase();
+ }
+ }
+ return null;
+ }
+
+ protected String determineType(T element) {
+ return elementKindLookup.get(element.getKind());
+ }
+
+ protected String determinePackageName(T element) {
+ return String.valueOf(environment.getElementUtils().getPackageOf(element));
+ }
+
+ protected String determineComment(T element) {
+ Optional docCommentTree = getDocCommentTree(element);
+ if (docCommentTree.isPresent()) {
+ String comment =
+ docCommentTree
+ .map(DocCommentTree::getFullBody)
+ .map(this::replaceLinksAndCodes)
+ .orElse(null);
+ return replaceBlockTags(docCommentTree.get(), comment);
+ }
+ return null;
+ }
+
+ /** Provides support for deprecated and see tags */
+ String replaceBlockTags(DocCommentTree docCommentTree, String comment) {
+ Set seeItems = new HashSet<>();
+ String commentWithBlockTags = comment;
+ for (DocTree blockTag : docCommentTree.getBlockTags()) {
+ switch (blockTag.getKind()) {
+ case DEPRECATED:
+ commentWithBlockTags = getDeprecatedSummary((DeprecatedTree) blockTag).concat(comment);
+ break;
+ case SEE:
+ seeItems.add(getSeeTagRef((SeeTree) blockTag));
+ break;
+ default:
+ }
+ }
+ if (!seeItems.isEmpty()) {
+ commentWithBlockTags = commentWithBlockTags.concat(getSeeAlsoSummary(seeItems));
+ }
+ return commentWithBlockTags;
+ }
+
+ /**
+ *
+ * - Replace @link and @linkplain with tags
+ * - Replace @code with
tags
+ *
+ */
+ String replaceLinksAndCodes(List extends DocTree> items) {
+ return YamlUtil.cleanupHtml(
+ items.stream()
+ .map(
+ bodyItem -> {
+ switch (bodyItem.getKind()) {
case LINK:
case LINK_PLAIN:
- return buildXrefTag((LinkTree) bodyItem);
+ return buildXrefTag((LinkTree) bodyItem);
case CODE:
- return buildCodeTag((LiteralTree) bodyItem);
+ return buildCodeTag((LiteralTree) bodyItem);
case LITERAL:
- return expandLiteralBody((LiteralTree) bodyItem);
+ return expandLiteralBody((LiteralTree) bodyItem);
default:
- return String.valueOf(StringEscapeUtils.unescapeJava(bodyItem.toString()));
- }
- }
- ).collect(Collectors.joining()));
- }
-
- /**
- * By using this way of processing links we provide support of @links with label, like this: {@link List someLabel}
- */
- String buildXrefTag(LinkTree linkTree) {
- String signature = linkTree.getReference().getSignature();
- String label = linkTree.getLabel().stream().map(String::valueOf).collect(Collectors.joining(" "));
- if (StringUtils.isEmpty(label)) {
- label = signature;
- }
- return String.format("%s", signature, label);
- }
-
- String buildCodeTag(LiteralTree literalTree) {
- return String.format("%s
", StringEscapeUtils.unescapeJava(literalTree.getBody().toString()));
- }
-
- String expandLiteralBody(LiteralTree bodyItem) {
- return String.valueOf(StringEscapeUtils.unescapeJava(bodyItem.getBody().toString()));
- }
-
- protected Optional getDocCommentTree(T element) {
- return Optional.ofNullable(environment.getDocTrees().getDocCommentTree(element));
- }
-
- /**
- * We make type shortening in assumption that package name doesn't contain uppercase characters
- */
- public String makeTypeShort(String value) {
- if (!value.contains(".")) {
- return value;
- }
- return Stream.of(StringUtils.split(value, "<"))
- .map(s -> RegExUtils.removeAll(s, "\\b[a-z0-9_.]+\\."))
- .collect(Collectors.joining("<"));
- }
-
- private String getSeeAlsoSummary(Set seeItems) {
- return String.format("\nSee Also: %s\n", String.join(", ", seeItems));
- }
-
- private String getDeprecatedSummary(DeprecatedTree deprecatedTree) {
- return String.format("\nDeprecated. %s\n\n",
- replaceLinksAndCodes(deprecatedTree.getBody()));
- }
-
- private String getSeeTagRef(SeeTree seeTree) {
- String ref = seeTree.getReference().stream()
- .map(r -> String.valueOf(r)).collect(Collectors.joining(""));
- // if it's already a tag, use that otherwise build xref tag
- if (ref.matches("^<.+>(.|\n)*")) {
- return ref.replaceAll("\n", "").replaceAll("( )+", " ");
- }
- return String.format("%1$s", ref);
- }
-}
\ No newline at end of file
+ return String.valueOf(StringEscapeUtils.unescapeJava(bodyItem.toString()));
+ }
+ })
+ .collect(Collectors.joining()));
+ }
+
+ /**
+ * By using this way of processing links we provide support of @links with label, like this:
+ * {@link List someLabel}
+ */
+ String buildXrefTag(LinkTree linkTree) {
+ String signature = linkTree.getReference().getSignature();
+ String label =
+ linkTree.getLabel().stream().map(String::valueOf).collect(Collectors.joining(" "));
+ if (StringUtils.isEmpty(label)) {
+ label = signature;
+ }
+ return String.format(
+ "%s", signature, label);
+ }
+
+ String buildCodeTag(LiteralTree literalTree) {
+ return String.format(
+ "%s
", StringEscapeUtils.unescapeJava(literalTree.getBody().toString()));
+ }
+
+ String expandLiteralBody(LiteralTree bodyItem) {
+ return String.valueOf(StringEscapeUtils.unescapeJava(bodyItem.getBody().toString()));
+ }
+
+ protected Optional getDocCommentTree(T element) {
+ return Optional.ofNullable(environment.getDocTrees().getDocCommentTree(element));
+ }
+
+ /**
+ * We make type shortening in assumption that package name doesn't contain uppercase characters
+ */
+ public String makeTypeShort(String value) {
+ if (!value.contains(".")) {
+ return value;
+ }
+ return Stream.of(StringUtils.split(value, "<"))
+ .map(s -> RegExUtils.removeAll(s, "\\b[a-z0-9_.]+\\."))
+ .collect(Collectors.joining("<"));
+ }
+
+ private String getSeeAlsoSummary(Set seeItems) {
+ return String.format("\nSee Also: %s\n", String.join(", ", seeItems));
+ }
+
+ private String getDeprecatedSummary(DeprecatedTree deprecatedTree) {
+ return String.format(
+ "\nDeprecated. %s\n\n",
+ replaceLinksAndCodes(deprecatedTree.getBody()));
+ }
+
+ private String getSeeTagRef(SeeTree seeTree) {
+ String ref =
+ seeTree.getReference().stream().map(r -> String.valueOf(r)).collect(Collectors.joining(""));
+ // if it's already a tag, use that otherwise build xref tag
+ if (ref.matches("^<.+>(.|\n)*")) {
+ return ref.replaceAll("\n", "").replaceAll("( )+", " ");
+ }
+ return String.format(
+ "%1$s", ref);
+ }
+}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassItemsLookup.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassItemsLookup.java
index f2da89d6..ecb5ca2e 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassItemsLookup.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassItemsLookup.java
@@ -13,8 +13,10 @@
import com.sun.source.doctree.ParamTree;
import com.sun.source.doctree.ReturnTree;
import com.sun.source.doctree.ThrowsTree;
-import jdk.javadoc.doclet.DocletEnvironment;
-
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
@@ -22,30 +24,30 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeKind;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
+import jdk.javadoc.doclet.DocletEnvironment;
public class ClassItemsLookup extends BaseLookup {
- private Utils utils;
+ private Utils utils;
- public ClassItemsLookup(DocletEnvironment environment, ElementUtil elementUtil) {
- super(environment);
- utils = new Utils(environment, elementUtil);
- }
+ public ClassItemsLookup(DocletEnvironment environment, ElementUtil elementUtil) {
+ super(environment);
+ utils = new Utils(environment, elementUtil);
+ }
+
+ @Override
+ protected ExtendedMetadataFileItem buildMetadataFileItem(Element element) {
+ String packageName = determinePackageName(element);
+ TypeElement classElement = (TypeElement) element.getEnclosingElement();
+ String classQName = String.valueOf(classElement.getQualifiedName());
+ String elementQName = String.valueOf(element);
+ String classQNameWithGenericsSupport = String.valueOf(classElement.asType());
+ String classSNameWithGenericsSupport =
+ classQNameWithGenericsSupport.replace(packageName.concat("."), "");
+ String uid = String.format("%s.%s", classQName, elementQName);
- @Override
- protected ExtendedMetadataFileItem buildMetadataFileItem(Element element) {
- String packageName = determinePackageName(element);
- TypeElement classElement = (TypeElement) element.getEnclosingElement();
- String classQName = String.valueOf(classElement.getQualifiedName());
- String elementQName = String.valueOf(element);
- String classQNameWithGenericsSupport = String.valueOf(classElement.asType());
- String classSNameWithGenericsSupport = classQNameWithGenericsSupport.replace(packageName.concat("."), "");
- String uid = String.format("%s.%s", classQName, elementQName);
-
- ExtendedMetadataFileItem result = new ExtendedMetadataFileItem(uid) {{
+ ExtendedMetadataFileItem result =
+ new ExtendedMetadataFileItem(uid) {
+ {
setId(elementQName);
setParent(classQName);
setHref(classQName + ".yml");
@@ -53,171 +55,202 @@ protected ExtendedMetadataFileItem buildMetadataFileItem(Element element) {
setType(determineType(element));
setPackageName(packageName);
setSummary(determineComment(element));
- }};
-
- String modifiers = element.getModifiers().stream().map(String::valueOf).collect(Collectors.joining(" "));
- if (element instanceof ExecutableElement) {
- ExecutableElement exeElement = (ExecutableElement) element;
- List parameters = extractParameters(exeElement);
- String paramsString = parameters.stream()
- .map(parameter -> String.format("%s %s", makeTypeShort(parameter.getType()), parameter.getId()))
- .collect(Collectors.joining(", "));
- String nameWithoutBrackets = elementQName.replaceAll("\\(.*\\)", "");
- String methodName = String.format("%s(%s)", nameWithoutBrackets, paramsString);
-
- result.setName(methodName);
- result.setMethodContent(String.format("%s %s %s", modifiers,
- makeTypeShort(String.valueOf(exeElement.getReturnType())), result.getName()));
- result.setConstructorContent(String.format("%s %s", modifiers, result.getName()));
- result.setParameters(parameters);
- result.setExceptions(extractExceptions(exeElement));
- result.setReturn(extractReturn(exeElement));
- if (exeElement.getKind() == ElementKind.METHOD) {
- result.setOverridden(extractOverriddenUid(utils.overriddenMethod(exeElement)));
- result.setSummary(determineComment(exeElement));
- }
- }
- result.setNameWithType(String.format("%s.%s", classSNameWithGenericsSupport, result.getName()));
- result.setFullName(String.format("%s.%s", classQNameWithGenericsSupport, result.getName()));
- result.setOverload(convertFullNameToOverload(result.getFullName()));
-
- if (element instanceof VariableElement) {
- String type = makeTypeShort(String.valueOf(element.asType()));
- result.setFieldContent(String.format("%s %s %s", modifiers, type, elementQName));
- result.setReturn(extractReturn((VariableElement) element));
- }
-
- return result;
- }
+ }
+ };
- List extractParameters(ExecutableElement element) {
- return element.getParameters().stream().map(o -> {
- String paramName = String.valueOf(o.getSimpleName());
- String paramType = String.valueOf(o.asType());
- return new MethodParameter(paramName, paramType, extractParameterDescription(element, paramName));
- }).collect(Collectors.toList());
- }
+ String modifiers =
+ element.getModifiers().stream().map(String::valueOf).collect(Collectors.joining(" "));
+ if (element instanceof ExecutableElement) {
+ ExecutableElement exeElement = (ExecutableElement) element;
+ List parameters = extractParameters(exeElement);
+ String paramsString =
+ parameters.stream()
+ .map(
+ parameter ->
+ String.format("%s %s", makeTypeShort(parameter.getType()), parameter.getId()))
+ .collect(Collectors.joining(", "));
+ String nameWithoutBrackets = elementQName.replaceAll("\\(.*\\)", "");
+ String methodName = String.format("%s(%s)", nameWithoutBrackets, paramsString);
- String extractParameterDescription(ExecutableElement method, String paramName) {
- return getDocCommentTree(method).map(docTree -> docTree.getBlockTags().stream()
- .filter(o -> o.getKind() == Kind.PARAM)
- .map(o -> (ParamTree) o)
- .filter(o -> paramName.equals(String.valueOf(o.getName())))
- .map(o -> replaceLinksAndCodes(o.getDescription()))
- .findFirst().orElse(null)
- ).orElse(null);
+ result.setName(methodName);
+ result.setMethodContent(
+ String.format(
+ "%s %s %s",
+ modifiers,
+ makeTypeShort(String.valueOf(exeElement.getReturnType())),
+ result.getName()));
+ result.setConstructorContent(String.format("%s %s", modifiers, result.getName()));
+ result.setParameters(parameters);
+ result.setExceptions(extractExceptions(exeElement));
+ result.setReturn(extractReturn(exeElement));
+ if (exeElement.getKind() == ElementKind.METHOD) {
+ result.setOverridden(extractOverriddenUid(utils.overriddenMethod(exeElement)));
+ result.setSummary(determineComment(exeElement));
+ }
}
+ result.setNameWithType(String.format("%s.%s", classSNameWithGenericsSupport, result.getName()));
+ result.setFullName(String.format("%s.%s", classQNameWithGenericsSupport, result.getName()));
+ result.setOverload(convertFullNameToOverload(result.getFullName()));
- List extractExceptions(ExecutableElement methodElement) {
- return methodElement.getThrownTypes().stream().map(o -> {
- String exceptionType = String.valueOf(o);
- return new ExceptionItem(exceptionType, extractExceptionDescription(methodElement));
- }).collect(Collectors.toList());
+ if (element instanceof VariableElement) {
+ String type = makeTypeShort(String.valueOf(element.asType()));
+ result.setFieldContent(String.format("%s %s %s", modifiers, type, elementQName));
+ result.setReturn(extractReturn((VariableElement) element));
}
- String extractExceptionDescription(ExecutableElement methodElement) {
- return getDocCommentTree(methodElement).map(docTree -> docTree.getBlockTags().stream()
- .filter(o -> o.getKind() == Kind.THROWS)
- .map(o -> (ThrowsTree) o)
- .map(o -> replaceLinksAndCodes(o.getDescription()))
- .findFirst().orElse(null)
- ).orElse(null);
- }
+ return result;
+ }
- Return extractReturn(ExecutableElement methodElement) {
- if (methodElement.getReturnType().getKind() == TypeKind.VOID) {
- return null;
- }
- return new Return(String.valueOf(methodElement.getReturnType()), extractReturnDescription(methodElement));
- }
+ List extractParameters(ExecutableElement element) {
+ return element.getParameters().stream()
+ .map(
+ o -> {
+ String paramName = String.valueOf(o.getSimpleName());
+ String paramType = String.valueOf(o.asType());
+ return new MethodParameter(
+ paramName, paramType, extractParameterDescription(element, paramName));
+ })
+ .collect(Collectors.toList());
+ }
- String extractReturnDescription(ExecutableElement methodElement) {
- return getDocCommentTree(methodElement).map(docTree -> docTree.getBlockTags().stream()
- .filter(o -> o.getKind() == Kind.RETURN)
- .map(o -> (ReturnTree) o)
- .map(o -> replaceLinksAndCodes(o.getDescription()))
- .findFirst().orElse(null)
- ).orElse(null);
- }
+ String extractParameterDescription(ExecutableElement method, String paramName) {
+ return getDocCommentTree(method)
+ .map(
+ docTree ->
+ docTree.getBlockTags().stream()
+ .filter(o -> o.getKind() == Kind.PARAM)
+ .map(o -> (ParamTree) o)
+ .filter(o -> paramName.equals(String.valueOf(o.getName())))
+ .map(o -> replaceLinksAndCodes(o.getDescription()))
+ .findFirst()
+ .orElse(null))
+ .orElse(null);
+ }
+
+ List extractExceptions(ExecutableElement methodElement) {
+ return methodElement.getThrownTypes().stream()
+ .map(
+ o -> {
+ String exceptionType = String.valueOf(o);
+ return new ExceptionItem(exceptionType, extractExceptionDescription(methodElement));
+ })
+ .collect(Collectors.toList());
+ }
+
+ String extractExceptionDescription(ExecutableElement methodElement) {
+ return getDocCommentTree(methodElement)
+ .map(
+ docTree ->
+ docTree.getBlockTags().stream()
+ .filter(o -> o.getKind() == Kind.THROWS)
+ .map(o -> (ThrowsTree) o)
+ .map(o -> replaceLinksAndCodes(o.getDescription()))
+ .findFirst()
+ .orElse(null))
+ .orElse(null);
+ }
- Return extractReturn(VariableElement fieldElement) {
- return new Return(String.valueOf(fieldElement.asType()));
+ Return extractReturn(ExecutableElement methodElement) {
+ if (methodElement.getReturnType().getKind() == TypeKind.VOID) {
+ return null;
}
+ return new Return(
+ String.valueOf(methodElement.getReturnType()), extractReturnDescription(methodElement));
+ }
- String convertFullNameToOverload(String fullName) {
- return fullName.replaceAll("\\(.*\\)", "*");
+ String extractReturnDescription(ExecutableElement methodElement) {
+ return getDocCommentTree(methodElement)
+ .map(
+ docTree ->
+ docTree.getBlockTags().stream()
+ .filter(o -> o.getKind() == Kind.RETURN)
+ .map(o -> (ReturnTree) o)
+ .map(o -> replaceLinksAndCodes(o.getDescription()))
+ .findFirst()
+ .orElse(null))
+ .orElse(null);
+ }
+
+ Return extractReturn(VariableElement fieldElement) {
+ return new Return(String.valueOf(fieldElement.asType()));
+ }
+
+ String convertFullNameToOverload(String fullName) {
+ return fullName.replaceAll("\\(.*\\)", "*");
+ }
+
+ String extractOverriddenUid(ExecutableElement ovr) {
+ if (ovr != null) {
+ TypeElement te = utils.getEnclosingTypeElement(ovr);
+ String uid = te.getQualifiedName().toString().concat(".") + String.valueOf(ovr);
+ return uid;
}
- String extractOverriddenUid(ExecutableElement ovr) {
- if (ovr != null) {
- TypeElement te = utils.getEnclosingTypeElement(ovr);
- String uid = te.getQualifiedName().toString().concat(".") + String.valueOf(ovr);
- return uid;
- }
+ return "";
+ }
- return "";
+ private String determineComment(ExecutableElement methodElement) {
+ String inheritedInlineComment = getInheritedInlineCommentString(methodElement);
+ Optional docCommentTree = getDocCommentTree(methodElement);
+ if (docCommentTree.isPresent()) {
+ return replaceBlockTags(docCommentTree.get(), inheritedInlineComment);
}
+ return inheritedInlineComment;
+ }
- private String determineComment(ExecutableElement methodElement) {
- String inheritedInlineComment = getInheritedInlineCommentString(methodElement);
- Optional docCommentTree = getDocCommentTree(methodElement);
- if (docCommentTree.isPresent()) {
- return replaceBlockTags(docCommentTree.get(), inheritedInlineComment);
- }
- return inheritedInlineComment;
+ /**
+ * If the item being inherited from is declared from external compiled package, or is declared in
+ * the packages like java.lang.Object, comments may be not available as doclet resolves from byte
+ * code.
+ */
+ private String getInheritedInlineCommentString(ExecutableElement exeElement) {
+ CommentHelper ch = getInheritedInlineTags(new CommentHelper(exeElement, utils));
+ // Remove unresolved "@inheritDoc" tag.
+ List extends DocTree> dctree = utils.removeBlockTag(ch.inlineTags, DocTree.Kind.INHERIT_DOC);
+ return replaceLinksAndCodes(dctree);
+ }
+
+ private CommentHelper getInheritedInlineTags(CommentHelper input) {
+ CommentHelper output = input.copy();
+ if (!output.hasInheritDocTag() && !output.isSimpleOverride()) {
+ return output;
}
- /**
- * If the item being inherited from is declared from external compiled package,
- * or is declared in the packages like java.lang.Object,
- * comments may be not available as doclet resolves from byte code.
- */
- private String getInheritedInlineCommentString(ExecutableElement exeElement) {
- CommentHelper ch = getInheritedInlineTags(new CommentHelper(exeElement, utils));
- // Remove unresolved "@inheritDoc" tag.
- List extends DocTree> dctree = utils.removeBlockTag(ch.inlineTags, DocTree.Kind.INHERIT_DOC);
- return replaceLinksAndCodes(dctree);
+ CommentHelper inheritedSearchInput = input.copy();
+ ExecutableElement overriddenMethod = utils.overriddenMethod((ExecutableElement) input.element);
+
+ if (overriddenMethod != null) {
+ inheritedSearchInput.element = overriddenMethod;
+ CommentHelper ch = getInheritedInlineTags(inheritedSearchInput);
+ if (!ch.isSimpleOverride()) {
+ output = output.inherit(ch);
+ }
}
- private CommentHelper getInheritedInlineTags(CommentHelper input) {
- CommentHelper output = input.copy();
- if (!output.hasInheritDocTag() && !output.isSimpleOverride()) {
- return output;
- }
-
- CommentHelper inheritedSearchInput = input.copy();
- ExecutableElement overriddenMethod = utils.overriddenMethod((ExecutableElement) input.element);
-
- if (overriddenMethod != null) {
- inheritedSearchInput.element = overriddenMethod;
- CommentHelper ch = getInheritedInlineTags(inheritedSearchInput);
- if (!ch.isSimpleOverride()) {
- output = output.inherit(ch);
- }
- }
-
- TypeElement encl = utils.getEnclosingTypeElement(input.element);
- List implementedMethods = utils.getImplementedMethods(input.element.toString(), encl, new ArrayList());
- for (Element implementedMethod : implementedMethods) {
- inheritedSearchInput.element = implementedMethod;
- CommentHelper ch = getInheritedInlineTags(inheritedSearchInput);
- if (!ch.isSimpleOverride()) {
- output = output.inherit(ch);
- }
- }
-
- return output;
+ TypeElement encl = utils.getEnclosingTypeElement(input.element);
+ List implementedMethods =
+ utils.getImplementedMethods(input.element.toString(), encl, new ArrayList());
+ for (Element implementedMethod : implementedMethods) {
+ inheritedSearchInput.element = implementedMethod;
+ CommentHelper ch = getInheritedInlineTags(inheritedSearchInput);
+ if (!ch.isSimpleOverride()) {
+ output = output.inherit(ch);
+ }
}
- public String extractJavaType(Element element) {
- if (element.getModifiers().contains(Modifier.STATIC)) {
- if (element.getKind().equals(ElementKind.METHOD)) {
- return "static method";
- }
- if (element.getKind().equals(ElementKind.FIELD) || element.getKind().equals(ElementKind.ENUM_CONSTANT)) {
- return "static field";
- }
- }
- return null;
+ return output;
+ }
+
+ public String extractJavaType(Element element) {
+ if (element.getModifiers().contains(Modifier.STATIC)) {
+ if (element.getKind().equals(ElementKind.METHOD)) {
+ return "static method";
+ }
+ if (element.getKind().equals(ElementKind.FIELD)
+ || element.getKind().equals(ElementKind.ENUM_CONSTANT)) {
+ return "static field";
+ }
}
+ return null;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassLookup.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassLookup.java
index 3f1fcd9a..5d3889f3 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassLookup.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/ClassLookup.java
@@ -5,16 +5,6 @@
import com.microsoft.model.TypeParameter;
import com.microsoft.util.ElementUtil;
import com.microsoft.util.Utils;
-import java.util.Collections;
-import jdk.javadoc.doclet.DocletEnvironment;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -22,199 +12,225 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import jdk.javadoc.doclet.DocletEnvironment;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
public class ClassLookup extends BaseLookup {
- private static final String JAVA_LANG_OBJECT = "java.lang.Object";
-
- private final ElementUtil elementUtil;
-
- public ClassLookup(DocletEnvironment environment, ElementUtil elementUtil) {
- super(environment);
- this.elementUtil = elementUtil;
- }
-
- @Override
- protected ExtendedMetadataFileItem buildMetadataFileItem(TypeElement classElement) {
- List inheritedMethods = new ArrayList<>();
-
- String packageName = determinePackageName(classElement);
- String classQName = String.valueOf(classElement.getQualifiedName());
- String classSName = String.valueOf(classElement.getSimpleName());
- String classQNameWithGenericsSupport = String.valueOf(classElement.asType());
- String classSNameWithGenericsSupport = classQNameWithGenericsSupport.replace(packageName.concat("."), "");
-
- ExtendedMetadataFileItem result = new ExtendedMetadataFileItem(classQName);
- result.setId(classSName);
- result.setParent(packageName);
- result.setHref(classQName + ".yml");
- result.setName(classSNameWithGenericsSupport);
- result.setNameWithType(classSNameWithGenericsSupport);
- result.setFullName(classQNameWithGenericsSupport);
- result.setType(determineType(classElement));
- result.setPackageName(packageName);
- result.setSummary(determineComment(classElement));
- result.setSuperclass(determineNestedSuperclass(classElement, result, inheritedMethods));
- result.setTypeParameters(determineTypeParameters(classElement));
- result.setInheritedMethods(determineInheritedMembers(inheritedMethods));
- result.setJavaType(extractJavaType(classElement));
- populateContent(classElement, classSNameWithGenericsSupport, result);
- result.setTocName(classQName.replace(packageName.concat("."), ""));
- return result;
- }
-
- void populateContent(TypeElement classElement, String shortNameWithGenericsSupport,
- ExtendedMetadataFileItem container) {
- String type = elementKindLookup.get(classElement.getKind());
- String result = String.format("%s %s %s",
- classElement.getModifiers().stream().map(String::valueOf)
+ private static final String JAVA_LANG_OBJECT = "java.lang.Object";
+
+ private final ElementUtil elementUtil;
+
+ public ClassLookup(DocletEnvironment environment, ElementUtil elementUtil) {
+ super(environment);
+ this.elementUtil = elementUtil;
+ }
+
+ @Override
+ protected ExtendedMetadataFileItem buildMetadataFileItem(TypeElement classElement) {
+ List inheritedMethods = new ArrayList<>();
+
+ String packageName = determinePackageName(classElement);
+ String classQName = String.valueOf(classElement.getQualifiedName());
+ String classSName = String.valueOf(classElement.getSimpleName());
+ String classQNameWithGenericsSupport = String.valueOf(classElement.asType());
+ String classSNameWithGenericsSupport =
+ classQNameWithGenericsSupport.replace(packageName.concat("."), "");
+
+ ExtendedMetadataFileItem result = new ExtendedMetadataFileItem(classQName);
+ result.setId(classSName);
+ result.setParent(packageName);
+ result.setHref(classQName + ".yml");
+ result.setName(classSNameWithGenericsSupport);
+ result.setNameWithType(classSNameWithGenericsSupport);
+ result.setFullName(classQNameWithGenericsSupport);
+ result.setType(determineType(classElement));
+ result.setPackageName(packageName);
+ result.setSummary(determineComment(classElement));
+ result.setSuperclass(determineNestedSuperclass(classElement, result, inheritedMethods));
+ result.setTypeParameters(determineTypeParameters(classElement));
+ result.setInheritedMethods(determineInheritedMembers(inheritedMethods));
+ result.setJavaType(extractJavaType(classElement));
+ populateContent(classElement, classSNameWithGenericsSupport, result);
+ result.setTocName(classQName.replace(packageName.concat("."), ""));
+ return result;
+ }
+
+ void populateContent(
+ TypeElement classElement,
+ String shortNameWithGenericsSupport,
+ ExtendedMetadataFileItem container) {
+ String type = elementKindLookup.get(classElement.getKind());
+ String result =
+ String.format(
+ "%s %s %s",
+ classElement.getModifiers().stream()
+ .map(String::valueOf)
.filter(modifier -> !("Interface".equals(type) && "abstract".equals(modifier)))
- .filter(modifier -> !("Enum".equals(type) && ("static".equals(modifier) || "final".equals(modifier))))
+ .filter(
+ modifier ->
+ !("Enum".equals(type)
+ && ("static".equals(modifier) || "final".equals(modifier))))
.collect(Collectors.joining(" ")),
- StringUtils.lowerCase(type), shortNameWithGenericsSupport);
+ StringUtils.lowerCase(type),
+ shortNameWithGenericsSupport);
- String superclass = determineSuperclass(classElement);
- if (superclass != null && !JAVA_LANG_OBJECT.equals(superclass)) {
- result += " extends " + makeTypeShort(superclass);
+ String superclass = determineSuperclass(classElement);
+ if (superclass != null && !JAVA_LANG_OBJECT.equals(superclass)) {
+ result += " extends " + makeTypeShort(superclass);
- addSuperclassToReferencesMap(superclass, container);
- }
-
- List extends TypeMirror> interfaces = classElement.getInterfaces();
- if (CollectionUtils.isNotEmpty(interfaces)) {
- String prefix = (classElement.getKind() == ElementKind.INTERFACE) ? " extends " : " implements ";
- result += prefix + interfaces.stream().map(String::valueOf).map(this::makeTypeShort)
- .collect(Collectors.joining(", "));
-
- container.setInterfaces(interfaces.stream()
- .map(String::valueOf)
- .collect(Collectors.toList()));
-
- addInterfacesToReferencesMap(interfaces, container);
-
- }
- addInheritedMethodsToReferencesMap(container);
- container.setContent(result);
+ addSuperclassToReferencesMap(superclass, container);
}
- void addSuperclassToReferencesMap(String superclass, ExtendedMetadataFileItem container) {
- container.addReferences(Set.of(new MetadataFileItem(superclass, makeTypeShort(superclass), false)));
+ List extends TypeMirror> interfaces = classElement.getInterfaces();
+ if (CollectionUtils.isNotEmpty(interfaces)) {
+ String prefix =
+ (classElement.getKind() == ElementKind.INTERFACE) ? " extends " : " implements ";
+ result +=
+ prefix
+ + interfaces.stream()
+ .map(String::valueOf)
+ .map(this::makeTypeShort)
+ .collect(Collectors.joining(", "));
+
+ container.setInterfaces(
+ interfaces.stream().map(String::valueOf).collect(Collectors.toList()));
+
+ addInterfacesToReferencesMap(interfaces, container);
}
-
- void addInheritedMethodsToReferencesMap(ExtendedMetadataFileItem container) {
- container.addReferences(container.getInheritedMethods().stream()
+ addInheritedMethodsToReferencesMap(container);
+ container.setContent(result);
+ }
+
+ void addSuperclassToReferencesMap(String superclass, ExtendedMetadataFileItem container) {
+ container.addReferences(
+ Set.of(new MetadataFileItem(superclass, makeTypeShort(superclass), false)));
+ }
+
+ void addInheritedMethodsToReferencesMap(ExtendedMetadataFileItem container) {
+ container.addReferences(
+ container.getInheritedMethods().stream()
.map(o -> new MetadataFileItem(o, makeTypeShort(o), false))
- .collect(Collectors.toSet())
- );
- }
+ .collect(Collectors.toSet()));
+ }
- void addInterfacesToReferencesMap(List extends TypeMirror> interfaces, ExtendedMetadataFileItem container) {
- container.addReferences(interfaces.stream()
+ void addInterfacesToReferencesMap(
+ List extends TypeMirror> interfaces, ExtendedMetadataFileItem container) {
+ container.addReferences(
+ interfaces.stream()
.map(String::valueOf)
.map(o -> new MetadataFileItem(o, makeTypeShort(o), false))
- .collect(Collectors.toSet())
- );
- }
+ .collect(Collectors.toSet()));
+ }
- String determineSuperclass(TypeElement classElement) {
- TypeMirror superclass = classElement.getSuperclass();
- if (superclass.getKind() == TypeKind.NONE) {
- return null;
- }
- return String.valueOf(superclass);
+ String determineSuperclass(TypeElement classElement) {
+ TypeMirror superclass = classElement.getSuperclass();
+ if (superclass.getKind() == TypeKind.NONE) {
+ return null;
}
+ return String.valueOf(superclass);
+ }
- List determineNestedSuperclass(TypeElement classElement, ExtendedMetadataFileItem result, List inheritedMethods) {
- List nestedList = new ArrayList<>();
+ List determineNestedSuperclass(
+ TypeElement classElement,
+ ExtendedMetadataFileItem result,
+ List inheritedMethods) {
+ List nestedList = new ArrayList<>();
- if (result.getSuperclass() != null) {
- nestedList = result.getSuperclass();
- }
+ if (result.getSuperclass() != null) {
+ nestedList = result.getSuperclass();
+ }
- TypeMirror superclass = classElement.getSuperclass();
- if (superclass.getKind() != TypeKind.NONE) {
- TypeElement superClassElement = (TypeElement) environment.getTypeUtils().asElement(superclass);
+ TypeMirror superclass = classElement.getSuperclass();
+ if (superclass.getKind() != TypeKind.NONE) {
+ TypeElement superClassElement =
+ (TypeElement) environment.getTypeUtils().asElement(superclass);
- nestedList.add(superClassElement.getQualifiedName().toString());
- result.setSuperclass(nestedList);
- appendInheritedMethods(superClassElement, inheritedMethods);
+ nestedList.add(superClassElement.getQualifiedName().toString());
+ result.setSuperclass(nestedList);
+ appendInheritedMethods(superClassElement, inheritedMethods);
- determineNestedSuperclass(superClassElement, result, inheritedMethods);
- }
- return nestedList;
+ determineNestedSuperclass(superClassElement, result, inheritedMethods);
}
-
- List determineTypeParameters(TypeElement element) {
- return element.getTypeParameters().stream()
- .map(typeParameter -> new TypeParameter(String.valueOf(typeParameter)))
- .collect(Collectors.toList());
+ return nestedList;
+ }
+
+ List determineTypeParameters(TypeElement element) {
+ return element.getTypeParameters().stream()
+ .map(typeParameter -> new TypeParameter(String.valueOf(typeParameter)))
+ .collect(Collectors.toList());
+ }
+
+ void appendInheritedMethods(
+ TypeElement element, List inheritedMethods) {
+ List extends Element> members = elementUtil.getEnclosedElements(element);
+ Integer level = Optional.ofNullable(getMaxNestedLevel(inheritedMethods)).orElse(0);
+
+ for (Element m : members) {
+ if (m.getKind() == ElementKind.METHOD && !Utils.isPrivateOrPackagePrivate(m)) {
+ String uid = element.getQualifiedName().toString().concat(".") + String.valueOf(m);
+
+ ExtendedMetadataFileItem item = new ExtendedMetadataFileItem(uid);
+ item.setName(String.valueOf(m));
+ item.setNestedLevel(level + 1);
+
+ inheritedMethods.add(item);
+ }
}
+ }
- void appendInheritedMethods(TypeElement element, List inheritedMethods) {
- List extends Element> members = elementUtil.getEnclosedElements(element);
- Integer level = Optional.ofNullable(getMaxNestedLevel(inheritedMethods))
- .orElse(0);
-
- for (Element m : members) {
- if (m.getKind() == ElementKind.METHOD && !Utils.isPrivateOrPackagePrivate(m)) {
- String uid = element.getQualifiedName().toString().concat(".") + String.valueOf(m);
+ Integer getMaxNestedLevel(List inheritedMethods) {
+ Integer level = 0;
- ExtendedMetadataFileItem item = new ExtendedMetadataFileItem(uid);
- item.setName(String.valueOf(m));
- item.setNestedLevel(level + 1);
-
- inheritedMethods.add(item);
- }
- }
+ if (inheritedMethods.size() > 0) {
+ level =
+ inheritedMethods.stream()
+ .mapToInt(v -> v.getNestedLevel())
+ .max()
+ .orElseThrow(NoSuchElementException::new);
}
-
- Integer getMaxNestedLevel(List inheritedMethods) {
- Integer level = 0;
-
- if (inheritedMethods.size() > 0) {
- level = inheritedMethods
- .stream()
- .mapToInt(v -> v.getNestedLevel())
- .max().orElseThrow(NoSuchElementException::new);
+ return level;
+ }
+
+ List determineInheritedMembers(List inheritedMethods) {
+
+ if (inheritedMethods.size() > 0) {
+ HashMap map = new HashMap<>();
+ for (ExtendedMetadataFileItem item : inheritedMethods) {
+ String key = item.getName();
+
+ if (map.containsKey(key) && map.get(key).getNestedLevel() > item.getNestedLevel()) {
+ // child class will have smaller than superclass, we only need the nearest methods
+ // inherited with same signature
+ map.put(key, item);
+ } else if (!map.containsKey(key)) {
+ map.put(key, item);
}
- return level;
- }
+ }
+ List methods =
+ map.values().stream().map(x -> x.getUid()).collect(Collectors.toList());
- List determineInheritedMembers(List inheritedMethods) {
-
- if (inheritedMethods.size() > 0) {
- HashMap map = new HashMap<>();
- for (ExtendedMetadataFileItem item : inheritedMethods
- ) {
- String key = item.getName();
-
- if (map.containsKey(key) && map.get(key).getNestedLevel() > item.getNestedLevel()) {
- // child class will have smaller than superclass, we only need the nearest methods inherited with same signature
- map.put(key, item);
- } else if (!map.containsKey(key)) {
- map.put(key, item);
- }
- }
- List methods = map.values()
- .stream()
- .map(x -> x.getUid())
- .collect(Collectors.toList());
-
- return methods;
- }
- return new ArrayList<>();
+ return methods;
}
+ return new ArrayList<>();
+ }
- public String extractJavaType(TypeElement element) {
- String superClass = determineSuperclass(element);
- if (superClass != null && superClass.contains("Exception")) {
- return "exception";
- }
+ public String extractJavaType(TypeElement element) {
+ String superClass = determineSuperclass(element);
+ if (superClass != null && superClass.contains("Exception")) {
+ return "exception";
+ }
- String javatype = element.getKind().name().toLowerCase().replaceAll("_","");
- if (javatype.equals("annotationtype")){
- return javatype;
- }
- return null;
+ String javatype = element.getKind().name().toLowerCase().replaceAll("_", "");
+ if (javatype.equals("annotationtype")) {
+ return javatype;
}
-}
\ No newline at end of file
+ return null;
+ }
+}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/PackageLookup.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/PackageLookup.java
index 8f939d49..a5953895 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/PackageLookup.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/PackageLookup.java
@@ -2,54 +2,53 @@
import com.microsoft.lookup.model.ExtendedMetadataFileItem;
import com.microsoft.model.Status;
-import jdk.javadoc.doclet.DocletEnvironment;
-
import javax.lang.model.element.PackageElement;
+import jdk.javadoc.doclet.DocletEnvironment;
public class PackageLookup extends BaseLookup {
- public PackageLookup(DocletEnvironment environment) {
- super(environment);
+ public PackageLookup(DocletEnvironment environment) {
+ super(environment);
+ }
+
+ @Override
+ protected ExtendedMetadataFileItem buildMetadataFileItem(PackageElement packageElement) {
+ String qName = String.valueOf(packageElement.getQualifiedName());
+ String sName = String.valueOf(packageElement.getSimpleName());
+
+ ExtendedMetadataFileItem result = new ExtendedMetadataFileItem(qName);
+ result.setId(sName);
+ result.setHref(qName + ".yml");
+ result.setName(qName);
+ result.setNameWithType(qName);
+ result.setFullName(qName);
+ result.setType(determineType(packageElement));
+ result.setJavaType(extractJavaType(packageElement));
+ result.setSummary(determineComment(packageElement));
+ result.setContent(determinePackageContent(packageElement));
+ return result;
+ }
+
+ public String extractStatus(PackageElement packageElement) {
+ String name = String.valueOf(packageElement.getQualifiedName());
+ if (name.contains(Status.ALPHA.toString())) {
+ return Status.ALPHA.toString();
}
-
- @Override
- protected ExtendedMetadataFileItem buildMetadataFileItem(PackageElement packageElement) {
- String qName = String.valueOf(packageElement.getQualifiedName());
- String sName = String.valueOf(packageElement.getSimpleName());
-
- ExtendedMetadataFileItem result = new ExtendedMetadataFileItem(qName);
- result.setId(sName);
- result.setHref(qName + ".yml");
- result.setName(qName);
- result.setNameWithType(qName);
- result.setFullName(qName);
- result.setType(determineType(packageElement));
- result.setJavaType(extractJavaType(packageElement));
- result.setSummary(determineComment(packageElement));
- result.setContent(determinePackageContent(packageElement));
- return result;
+ if (name.contains(Status.BETA.toString())) {
+ return Status.BETA.toString();
}
+ return null;
+ }
- public String extractStatus(PackageElement packageElement) {
- String name = String.valueOf(packageElement.getQualifiedName());
- if (name.contains(Status.ALPHA.toString())) {
- return Status.ALPHA.toString();
- }
- if (name.contains(Status.BETA.toString())) {
- return Status.BETA.toString();
- }
- return null;
- }
-
- String determinePackageContent(PackageElement packageElement) {
- return "package " + packageElement.getQualifiedName();
- }
+ String determinePackageContent(PackageElement packageElement) {
+ return "package " + packageElement.getQualifiedName();
+ }
- public String extractJavaType(PackageElement element) {
- String javaType = element.getKind().name().toLowerCase();
- if (javaType.equals("package")) {
- return javaType;
- }
- return null;
+ public String extractJavaType(PackageElement element) {
+ String javaType = element.getKind().name().toLowerCase();
+ if (javaType.equals("package")) {
+ return javaType;
}
+ return null;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/model/ExtendedMetadataFileItem.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/model/ExtendedMetadataFileItem.java
index dea5e61a..c4238280 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/model/ExtendedMetadataFileItem.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/lookup/model/ExtendedMetadataFileItem.java
@@ -8,112 +8,114 @@
import java.util.List;
import java.util.Set;
-/**
- * Just container to keep cached precalculated values for lookup
- */
+/** Just container to keep cached precalculated values for lookup */
public class ExtendedMetadataFileItem extends MetadataFileItem {
- private String methodContent;
- private String fieldContent;
- private String constructorContent;
- private List parameters;
- private Return returnValue;
- private String content;
- private List typeParameters;
- private List superclass;
- private String tocName;
- private Set references = new LinkedHashSet<>();
- private Integer nestedLevel;
-
- public ExtendedMetadataFileItem(String uid) {
- super(uid);
- }
-
- public String getMethodContent() {
- return methodContent;
- }
-
- public void setMethodContent(String methodContent) {
- this.methodContent = methodContent;
- }
-
- public String getFieldContent() {
- return fieldContent;
- }
-
- public void setFieldContent(String fieldContent) {
- this.fieldContent = fieldContent;
- }
-
- public String getConstructorContent() {
- return constructorContent;
- }
-
- public void setConstructorContent(String constructorContent) {
- this.constructorContent = constructorContent;
- }
-
- public List getParameters() {
- return parameters;
- }
-
- public Integer getNestedLevel() {return nestedLevel;}
-
- public void setNestedLevel(Integer level) {this.nestedLevel = level;}
-
- @Override
- public void setParameters(List parameters) {
- this.parameters = parameters;
- }
-
- public Return getReturn() {
- return returnValue;
- }
-
- @Override
- public void setReturn(Return returnValue) {
- this.returnValue = returnValue;
- }
-
- public String getContent() {
- return content;
- }
-
- @Override
- public void setContent(String content) {
- this.content = content;
- }
-
- public List getTypeParameters() {
- return typeParameters;
- }
-
- @Override
- public void setTypeParameters(List typeParameters) {
- this.typeParameters = typeParameters;
- }
-
- public List getSuperclass() {
- return superclass;
- }
-
- public void setSuperclass(List superclass) {
- this.superclass = superclass;
- }
-
- public void setTocName(String tocName) {
- this.tocName = tocName;
- }
-
- public String getTocName() {
- return tocName;
- }
-
- public void addReferences(Set references) {
- this.references.addAll(references);
- }
-
- public Set getReferences() {
- return references;
- }
+ private String methodContent;
+ private String fieldContent;
+ private String constructorContent;
+ private List parameters;
+ private Return returnValue;
+ private String content;
+ private List typeParameters;
+ private List superclass;
+ private String tocName;
+ private Set references = new LinkedHashSet<>();
+ private Integer nestedLevel;
+
+ public ExtendedMetadataFileItem(String uid) {
+ super(uid);
+ }
+
+ public String getMethodContent() {
+ return methodContent;
+ }
+
+ public void setMethodContent(String methodContent) {
+ this.methodContent = methodContent;
+ }
+
+ public String getFieldContent() {
+ return fieldContent;
+ }
+
+ public void setFieldContent(String fieldContent) {
+ this.fieldContent = fieldContent;
+ }
+
+ public String getConstructorContent() {
+ return constructorContent;
+ }
+
+ public void setConstructorContent(String constructorContent) {
+ this.constructorContent = constructorContent;
+ }
+
+ public List getParameters() {
+ return parameters;
+ }
+
+ public Integer getNestedLevel() {
+ return nestedLevel;
+ }
+
+ public void setNestedLevel(Integer level) {
+ this.nestedLevel = level;
+ }
+
+ @Override
+ public void setParameters(List parameters) {
+ this.parameters = parameters;
+ }
+
+ public Return getReturn() {
+ return returnValue;
+ }
+
+ @Override
+ public void setReturn(Return returnValue) {
+ this.returnValue = returnValue;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ @Override
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public List getTypeParameters() {
+ return typeParameters;
+ }
+
+ @Override
+ public void setTypeParameters(List typeParameters) {
+ this.typeParameters = typeParameters;
+ }
+
+ public List getSuperclass() {
+ return superclass;
+ }
+
+ public void setSuperclass(List superclass) {
+ this.superclass = superclass;
+ }
+
+ public void setTocName(String tocName) {
+ this.tocName = tocName;
+ }
+
+ public String getTocName() {
+ return tocName;
+ }
+
+ public void addReferences(Set references) {
+ this.references.addAll(references);
+ }
+
+ public Set getReferences() {
+ return references;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/ExceptionItem.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/ExceptionItem.java
index b833f6bd..2fda6b0f 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/ExceptionItem.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/ExceptionItem.java
@@ -2,19 +2,19 @@
public class ExceptionItem {
- private final String type;
- private final String description;
+ private final String type;
+ private final String description;
- public ExceptionItem(String type, String description) {
- this.type = type;
- this.description = description;
- }
+ public ExceptionItem(String type, String description) {
+ this.type = type;
+ this.description = description;
+ }
- public String getType() {
- return type;
- }
+ public String getType() {
+ return type;
+ }
- public String getDescription() {
- return description;
- }
+ public String getDescription() {
+ return description;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/Guide.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/Guide.java
index 55708f69..ebd071ce 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/Guide.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/Guide.java
@@ -24,19 +24,19 @@
// name: name,
// uid: package.name,...]]
public class Guide {
- private final String name;
- private final String href;
+ private final String name;
+ private final String href;
- public Guide(String name, String href) {
- this.name = name;
- this.href = href;
- }
+ public Guide(String name, String href) {
+ this.name = name;
+ this.href = href;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public String getHref() {
- return href;
- }
-}
\ No newline at end of file
+ public String getHref() {
+ return href;
+ }
+}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/KindTitle.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/KindTitle.java
index b098336c..65f438a7 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/KindTitle.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/KindTitle.java
@@ -16,13 +16,19 @@
package com.microsoft.model;
public class KindTitle {
- private final String elementKind;
- private final String title;
+ private final String elementKind;
+ private final String title;
- public KindTitle(String elementKind, String title) {
- this.elementKind = elementKind;
- this.title = title;
- }
- public String getElementKind() { return elementKind; }
- public String getTitle() { return title; }
+ public KindTitle(String elementKind, String title) {
+ this.elementKind = elementKind;
+ this.title = title;
+ }
+
+ public String getElementKind() {
+ return elementKind;
+ }
+
+ public String getTitle() {
+ return title;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFile.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFile.java
index 15e7ebe6..c47de634 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFile.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFile.java
@@ -2,7 +2,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.microsoft.util.YamlUtil;
-
import java.io.File;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -10,45 +9,45 @@
public class MetadataFile implements YmlFile {
- private final static String METADATA_FILE_HEADER = "### YamlMime:ManagedReference\n";
- private final String outputPath;
- private String fileName;
- private Set items = new LinkedHashSet<>();
- private Set references = new LinkedHashSet<>();
-
- public MetadataFile(String outputPath, String fileName) {
- this.outputPath = outputPath;
- this.fileName = fileName;
- }
-
- public Set getItems() {
- return items;
- }
-
- public Set getReferences() {
- return references;
- }
-
- @JsonIgnore
- @Override
- public String getFileContent() {
- Set sortedSet = new TreeSet<>(this.items);
- this.items = sortedSet;
- return METADATA_FILE_HEADER + YamlUtil.objectToYamlString(this);
- }
-
- @JsonIgnore
- @Override
- public String getFileNameWithPath() {
- return outputPath + File.separator + fileName;
- }
-
- @JsonIgnore
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
+ private static final String METADATA_FILE_HEADER = "### YamlMime:ManagedReference\n";
+ private final String outputPath;
+ private String fileName;
+ private Set items = new LinkedHashSet<>();
+ private Set references = new LinkedHashSet<>();
+
+ public MetadataFile(String outputPath, String fileName) {
+ this.outputPath = outputPath;
+ this.fileName = fileName;
+ }
+
+ public Set getItems() {
+ return items;
+ }
+
+ public Set getReferences() {
+ return references;
+ }
+
+ @JsonIgnore
+ @Override
+ public String getFileContent() {
+ Set sortedSet = new TreeSet<>(this.items);
+ this.items = sortedSet;
+ return METADATA_FILE_HEADER + YamlUtil.objectToYamlString(this);
+ }
+
+ @JsonIgnore
+ @Override
+ public String getFileNameWithPath() {
+ return outputPath + File.separator + fileName;
+ }
+
+ @JsonIgnore
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
}
diff --git a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFileItem.java b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFileItem.java
index a608148c..90192004 100644
--- a/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFileItem.java
+++ b/third_party/docfx-doclet-143274/src/main/java/com/microsoft/model/MetadataFileItem.java
@@ -2,282 +2,318 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import org.apache.commons.lang3.RegExUtils;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.apache.commons.lang3.RegExUtils;
-@JsonPropertyOrder({"uid", "id", "parent", "children", "href", "langs", "isExternal", "name", "nameWithType",
- "fullName", "overload", "overridden", "type", "javatype", "package", "summary", "syntax", "inheritance", "implements", "exceptions",
- "spec.java", "inheritedMembers", "status"})
+@JsonPropertyOrder({
+ "uid",
+ "id",
+ "parent",
+ "children",
+ "href",
+ "langs",
+ "isExternal",
+ "name",
+ "nameWithType",
+ "fullName",
+ "overload",
+ "overridden",
+ "type",
+ "javatype",
+ "package",
+ "summary",
+ "syntax",
+ "inheritance",
+ "implements",
+ "exceptions",
+ "spec.java",
+ "inheritedMembers",
+ "status"
+})
public class MetadataFileItem implements Comparable {
- private final String uid;
- private String id;
- private String parent;
- private List children = new ArrayList<>();
- private String href;
- private String[] langs;
- private String name;
- private String nameWithType;
- private String fullName;
- private String overload;
- private String overridden;
- private String type;
- private String javatype;
- @JsonProperty("package")
- private String packageName;
- private String summary;
- private Syntax syntax;
- private List inheritance;
- @JsonProperty("implements")
- private List interfaces;
- private List exceptions;
- private boolean isExternal;
- @JsonProperty("spec.java")
- private List specForJava = new ArrayList<>();
- @JsonProperty("inheritedMembers")
- private List inheritedMethods = new ArrayList<>();
- private String status;
-
- @Override
- public int compareTo(MetadataFileItem item) {
- return this.getUid().compareTo(item.getUid());
- }
+ private final String uid;
+ private String id;
+ private String parent;
+ private List children = new ArrayList<>();
+ private String href;
+ private String[] langs;
+ private String name;
+ private String nameWithType;
+ private String fullName;
+ private String overload;
+ private String overridden;
+ private String type;
+ private String javatype;
+
+ @JsonProperty("package")
+ private String packageName;
+
+ private String summary;
+ private Syntax syntax;
+ private List inheritance;
+
+ @JsonProperty("implements")
+ private List interfaces;
+
+ private List exceptions;
+ private boolean isExternal;
+
+ @JsonProperty("spec.java")
+ private List specForJava = new ArrayList<>();
+
+ @JsonProperty("inheritedMembers")
+ private List inheritedMethods = new ArrayList<>();
+
+ private String status;
+
+ @Override
+ public int compareTo(MetadataFileItem item) {
+ return this.getUid().compareTo(item.getUid());
+ }
+
+ public MetadataFileItem(String[] langs, String uid) {
+ this(uid);
+ this.langs = langs;
+ }
+
+ public MetadataFileItem(String uid) {
+ this.uid = uid;
+ }
+
+ public MetadataFileItem(String uid, String name, boolean isExternal) {
+ this(uid);
+ this.name = name;
+ this.nameWithType = name;
+ this.fullName = uid;
+ this.isExternal = isExternal;
+ }
+
+ public MetadataFileItem(String uid, List specs) {
+ this(uid);
+ this.specForJava = specs;
+ }
+
+ public String getUid() {
+ return uid;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getParent() {
+ return parent;
+ }
+
+ public void setParent(String parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ Collections.sort(children);
+ return children;
+ }
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public String[] getLangs() {
+ return langs;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNameWithType() {
+ return nameWithType;
+ }
- public MetadataFileItem(String[] langs, String uid) {
- this(uid);
- this.langs = langs;
- }
+ public void setNameWithType(String nameWithType) {
+ this.nameWithType = nameWithType;
+ }
- public MetadataFileItem(String uid) {
- this.uid = uid;
- }
+ public String getFullName() {
+ return fullName;
+ }
- public MetadataFileItem(String uid, String name, boolean isExternal) {
- this(uid);
- this.name = name;
- this.nameWithType = name;
- this.fullName = uid;
- this.isExternal = isExternal;
- }
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
- public MetadataFileItem(String uid, List specs) {
- this(uid);
- this.specForJava = specs;
- }
+ public String getOverload() {
+ return overload;
+ }
- public String getUid() {
- return uid;
- }
+ public void setOverload(String overload) {
+ this.overload = handleGenericForOverLoad(overload);
+ }
+
+ public String getType() {
+ return type;
+ }
- public String getId() {
- return id;
- }
+ public String getJavaType() {
+ return javatype;
+ }
- public void setId(String id) {
- this.id = id;
- }
+ public void setType(String type) {
+ this.type = type;
+ }
- public String getParent() {
- return parent;
- }
+ public void setJavaType(String javaType) {
+ this.javatype = javaType;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
- public void setParent(String parent) {
- this.parent = parent;
- }
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
- public List getChildren() {
- Collections.sort(children);
- return children;
- }
+ public String getSummary() {
+ return summary;
+ }
- public String getHref() {
- return href;
- }
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
- public void setHref(String href) {
- this.href = href;
- }
+ public Syntax getSyntax() {
+ return syntax;
+ }
- public String[] getLangs() {
- return langs;
- }
+ public void setSyntax(Syntax syntax) {
+ this.syntax = syntax;
+ }
- public String getName() {
- return name;
- }
+ public List getInheritance() {
+ return inheritance;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setInheritance(List superclass) {
+ this.inheritance = (superclass == null) ? null : superclass;
+ }
- public String getNameWithType() {
- return nameWithType;
- }
+ public List getInterfaces() {
+ return interfaces;
+ }
- public void setNameWithType(String nameWithType) {
- this.nameWithType = nameWithType;
- }
+ public void setInheritedMethods(List inheritedMethods) {
+ this.inheritedMethods = (inheritedMethods == null) ? null : inheritedMethods;
+ }
- public String getFullName() {
- return fullName;
- }
+ public List getInheritedMethods() {
+ return inheritedMethods;
+ }
- public void setFullName(String fullName) {
- this.fullName = fullName;
- }
+ public List getSpecForJava() {
+ return specForJava;
+ }
- public String getOverload() {
- return overload;
- }
+ public void setInterfaces(List interfaces) {
+ this.interfaces = interfaces;
+ }
- public void setOverload(String overload) {
- this.overload = handleGenericForOverLoad(overload);
- }
+ public List getExceptions() {
+ return exceptions;
+ }
- public String getType() {
- return type;
- }
+ public void setExceptions(List exceptions) {
+ this.exceptions = exceptions;
+ }
- public String getJavaType() {
- return javatype;
+ public void setContent(String content) {
+ if (syntax == null) {
+ syntax = new Syntax();
}
+ syntax.setContent(content);
+ }
- public void setType(String type) {
- this.type = type;
+ public void setTypeParameters(List typeParameters) {
+ if (syntax == null) {
+ syntax = new Syntax();
}
+ syntax.setTypeParameters(typeParameters);
+ }
- public void setJavaType(String javaType) {
- this.javatype = javaType;
+ public void setParameters(List parameters) {
+ if (syntax == null) {
+ syntax = new Syntax();
}
+ syntax.setParameters(parameters);
+ }
- public String getPackageName() {
- return packageName;
+ public void setReturn(Return returnValue) {
+ if (syntax == null) {
+ syntax = new Syntax();
}
+ syntax.setReturnValue(returnValue);
+ }
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
+ public void setOverridden(String overridden) {
+ this.overridden = overridden;
+ }
- public String getSummary() {
- return summary;
- }
+ public String getOverridden() {
+ return overridden;
+ }
- public void setSummary(String summary) {
- this.summary = summary;
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
}
- public Syntax getSyntax() {
- return syntax;
+ if (o == null || getClass() != o.getClass()) {
+ return false;
}
- public void setSyntax(Syntax syntax) {
- this.syntax = syntax;
- }
+ MetadataFileItem that = (MetadataFileItem) o;
- public List getInheritance() {
- return inheritance;
- }
+ return uid.equals(that.uid);
+ }
- public void setInheritance(List superclass) {
- this.inheritance = (superclass == null) ? null : superclass;
- }
+ @Override
+ public int hashCode() {
+ return uid.hashCode();
+ }
- public List getInterfaces() {
- return interfaces;
- }
+ public Boolean getIsExternal() {
+ return isExternal ? true : null;
+ }
- public void setInheritedMethods(List inheritedMethods) {
- this.inheritedMethods = (inheritedMethods == null) ? null : inheritedMethods;
- }
+ public void setIsExternal(boolean external) {
+ isExternal = external;
+ }
- public List getInheritedMethods() {
- return inheritedMethods;
- }
-
- public List getSpecForJava() {
- return specForJava;
- }
-
- public void setInterfaces(List interfaces) {
- this.interfaces = interfaces;
- }
-
- public List getExceptions() {
- return exceptions;
- }
-
- public void setExceptions(List exceptions) {
- this.exceptions = exceptions;
- }
-
- public void setContent(String content) {
- if (syntax == null) {
- syntax = new Syntax();
- }
- syntax.setContent(content);
- }
-
- public void setTypeParameters(List typeParameters) {
- if (syntax == null) {
- syntax = new Syntax();
- }
- syntax.setTypeParameters(typeParameters);
- }
-
- public void setParameters(List