Skip to content

Commit

Permalink
@links to Java methods annotated with @JsProperty do not resolve corr…
Browse files Browse the repository at this point in the history
…ectly in Typescript (#90)

Fix #87

(cherry picked from commit 710aed2)
  • Loading branch information
vegegoku committed Oct 29, 2023
1 parent 8a4b103 commit 3127520
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.sun.source.util.DocTreePath;
import com.sun.source.util.DocTrees;
import com.sun.source.util.SimpleDocTreeVisitor;
import com.vertispan.tsdefs.impl.Formatting;
import com.vertispan.tsdefs.impl.HasProcessorEnv;
import com.vertispan.tsdefs.impl.builders.TsElement;
import java.util.Optional;
Expand Down Expand Up @@ -67,7 +68,12 @@ public String visitReference(ReferenceTree node, Element element) {
String refNamespace = refTsElement.getNamespace();
String parentNamespace = parentTsElement.getNamespace();

String name = refTsElement.getName();
boolean isSetterOrGetter = refTsElement.isSetter() || refTsElement.isGetter();

String name =
isSetterOrGetter
? Formatting.nonGetSetName(refTsElement.getName())
: refTsElement.getName();
String parentName = parentTsElement.getName();
if (refNamespace.equals(parentNamespace)) {
String fullName = refNamespace + "." + parentName + "." + name;
Expand Down Expand Up @@ -127,7 +133,7 @@ public String visitDocComment(DocCommentTree node, Element element) {
node.getBlockTags().stream()
.map(tag -> " " + tag.accept(this, element))
.collect(Collectors.joining("\n"));
return body + "\n" + tags;
return " " + body + "\n" + tags;
}

@Override
Expand All @@ -145,6 +151,6 @@ public String visitLiteral(LiteralTree node, Element element) {

@Override
public String visitText(TextTree node, Element element) {
return " " + node.getBody();
return "" + node.getBody();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright © 2023 Vertispan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.vertispan.tsdefs.tests.tsdocs.doclet.links.methods;

import jsinterop.annotations.JsProperty;

/** The entire point of this class is to let you use {@link #getSomethingImportant()}. */
public class MyClass {
@JsProperty
public String getSomethingImportant() {
return null;
}
}

0 comments on commit 3127520

Please sign in to comment.