Skip to content

Commit

Permalink
Consume javadoc pushdown from jdt.ui to jdt.core.manipulation
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>

Adjust two tests to newest behavior

Signed-off-by: Rob Stryker <[email protected]>

Override code tag on link

Signed-off-by: Rob Stryker <[email protected]>

WIP - more test cases

Signed-off-by: Rob Stryker <[email protected]>

WIP - more test cases

Signed-off-by: Rob Stryker <[email protected]>

Another test green

Signed-off-by: Rob Stryker <[email protected]>

Fix failing test

Signed-off-by: Rob Stryker <[email protected]>

Delete more files

Signed-off-by: Rob Stryker <[email protected]>

Delete more files

Signed-off-by: Rob Stryker <[email protected]>

Update to platform and jdt ibuilds

Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
robstryker committed Dec 7, 2023
1 parent 936a964 commit 64af2b8
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 5,230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jdt.internal.core.BinaryMember;
import org.eclipse.jdt.ls.core.internal.handlers.CompletionResolveHandler;
import org.eclipse.jdt.internal.core.manipulation.JavaElementLabelsCore;
import org.eclipse.jdt.ls.core.internal.javadoc.JavaDocSnippetStringEvaluator;
import org.eclipse.jdt.ls.core.internal.handlers.CompletionResolveHandler;
import org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2;
import org.eclipse.jdt.ls.core.internal.managers.IBuildSupport;
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
Expand Down Expand Up @@ -164,13 +163,13 @@ public List<Either<String, MarkedString>> computeHover(int line, int column, IPr
}

private String fixSnippet(String value) {
if (value.contains(JavaDocSnippetStringEvaluator.SNIPPET)) {
if (value.contains(JavadocContentAccess2.SNIPPET)) {
StringBuilder builder = new StringBuilder();
value.lines().forEach((line) -> {
if (line.contains(JavaDocSnippetStringEvaluator.SNIPPET)) {
if (line.contains(JavadocContentAccess2.SNIPPET)) {
line = line.stripLeading();
if (line.startsWith(JavaDocSnippetStringEvaluator.SNIPPET)) {
line = line.replaceFirst(JavaDocSnippetStringEvaluator.SNIPPET, "");
if (line.startsWith(JavadocContentAccess2.SNIPPET)) {
line = line.replaceFirst(JavadocContentAccess2.SNIPPET, "");
line = replaceLeadingSpaces(line);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@
import org.eclipse.jdt.internal.corext.template.java.SignatureUtil;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
import org.eclipse.jdt.internal.ui.viewsupport.CoreJavaElementLinks;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.jdt.ls.core.internal.handlers.JsonRpcHelpers;
import org.eclipse.jdt.ls.core.internal.javadoc.JavaElementLinks;
import org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager;
import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager;
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
Expand Down Expand Up @@ -999,7 +999,7 @@ public static String toURI(ICompilationUnit cu) {
}
} catch (JavaModelException ex) {
JavaLanguageServerPlugin.logException(ex);
}
}
return null;
}

Expand Down Expand Up @@ -1460,7 +1460,7 @@ private static void addValue(StringBuilder buf, Object value, boolean addLinks)
if (type == null || !addLinks) {
buf.append(typeBinding.getName());
} else {
String uri = JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, type);
String uri = CoreJavaElementLinks.createURI(CoreJavaElementLinks.JAVADOC_SCHEME, type);
String name = type.getElementName();
addLink(buf, uri, name);
}
Expand All @@ -1471,7 +1471,7 @@ private static void addValue(StringBuilder buf, Object value, boolean addLinks)
if (variable == null || !addLinks) {
buf.append(variableBinding.getName());
} else {
String uri = JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, variable);
String uri = CoreJavaElementLinks.createURI(CoreJavaElementLinks.JAVADOC_SCHEME, variable);
String name = variable.getElementName();
addLink(buf, uri, name);
}
Expand Down Expand Up @@ -1501,7 +1501,7 @@ private static void addValue(StringBuilder buf, Object value, boolean addLinks)
}

private static StringBuilder addLink(StringBuilder buf, String uri, String label) {
return buf.append(JavaElementLinks.createLink(uri, label));
return buf.append(CoreJavaElementLinks.createLink(uri, label));
}

private static void addAnnotation(StringBuilder buf, IAnnotationBinding annotation, boolean addLinks) throws URISyntaxException {
Expand All @@ -1510,7 +1510,7 @@ private static void addAnnotation(StringBuilder buf, IAnnotationBinding annotati
if (javaElement == null || !addLinks) {
buf.append(annotation.getName());
} else {
String uri = JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, javaElement);
String uri = CoreJavaElementLinks.createURI(CoreJavaElementLinks.JAVADOC_SCHEME, javaElement);
addLink(buf, uri, annotation.getName());
}

Expand All @@ -1523,7 +1523,7 @@ private static void addAnnotation(StringBuilder buf, IAnnotationBinding annotati
}
IMemberValuePairBinding mvPair = mvPairs[j];
if (addLinks) {
String memberURI = JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, mvPair.getMethodBinding().getJavaElement());
String memberURI = CoreJavaElementLinks.createURI(CoreJavaElementLinks.JAVADOC_SCHEME, mvPair.getMethodBinding().getJavaElement());
addLink(buf, memberURI, mvPair.getName());
} else {
buf.append(mvPair.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpUtils;
import org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess;
import org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2;
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
import org.eclipse.jdt.ls.core.internal.preferences.Preferences;
import org.eclipse.lsp4j.ParameterInformation;
Expand Down Expand Up @@ -231,7 +231,7 @@ public String computeJavaDoc(CompletionProposal proposal) {
String javadoc = null;
try {
javadoc = SimpleTimeLimiter.create(JavaLanguageServerPlugin.getExecutorService()).callWithTimeout(() -> {
Reader reader = JavadocContentAccess.getPlainTextContentReader(method);
Reader reader = JavadocContentAccess2.getPlainTextContentReader(method);
return reader == null ? null : CharStreams.toString(reader);
}, 500, TimeUnit.MILLISECONDS);
} catch (UncheckedTimeoutException tooSlow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.eclipse.jdt.ls.core.internal.corext.template.java.JavaPostfixContext;
import org.eclipse.jdt.ls.core.internal.corext.template.java.PostfixCompletionProposal;
import org.eclipse.jdt.ls.core.internal.corext.template.java.PostfixTemplateEngine;
import org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess;
import org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2;
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
import org.eclipse.jface.text.Region;
Expand Down Expand Up @@ -265,7 +264,7 @@ public CompletionItem resolve(CompletionItem param, IProgressMonitor monitor) {
if (manager.getClientPreferences().isSupportsCompletionDocumentationMarkdown()) {
reader = JavadocContentAccess2.getMarkdownContentReader(curMember);
} else {
reader = JavadocContentAccess.getPlainTextContentReader(curMember);
reader = JavadocContentAccess2.getPlainTextContentReader(curMember);
}
return reader == null? null:CharStreams.toString(reader);
}, 500, TimeUnit.MILLISECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
import java.io.Reader;
import java.io.StringReader;

import org.eclipse.jdt.core.manipulation.internal.javadoc.CoreJavaDoc2HTMLTextReader;

/**
* Converts JavaDoc tags into an output format.
*
* @author Fred Bricon
*/
abstract class AbstractJavaDocConverter {

private JavaDoc2HTMLTextReader reader;
private CoreJavaDoc2HTMLTextReader reader;

private boolean read;

private String result;

public AbstractJavaDocConverter(Reader reader) {
Expand All @@ -38,10 +39,10 @@ public AbstractJavaDocConverter(String javadoc) {
}

private void setJavaDoc2HTMLTextReader(Reader reader) {
if (reader == null || reader instanceof JavaDoc2HTMLTextReader) {
this.reader = (JavaDoc2HTMLTextReader) reader;
if (reader == null || reader instanceof CoreJavaDoc2HTMLTextReader) {
this.reader = (CoreJavaDoc2HTMLTextReader) reader;
} else {
this.reader = new JavaDoc2HTMLTextReader(reader);
this.reader = new CoreJavaDoc2HTMLTextReader(reader);
}
}

Expand Down
Loading

0 comments on commit 64af2b8

Please sign in to comment.