Skip to content

Commit

Permalink
Merge pull request #1400 from eclipse-jdt/master
Browse files Browse the repository at this point in the history
Merge master to BETA_JAVA23
  • Loading branch information
noopur2507 committed May 10, 2024
2 parents 7e1e78f + af7a99c commit 0b7f512
Show file tree
Hide file tree
Showing 77 changed files with 2,276 additions and 552 deletions.
48 changes: 0 additions & 48 deletions org.eclipse.jdt.core.manipulation/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -23,60 +23,12 @@
<message_argument value="getAST()"/>
</message_arguments>
</filter>
<filter comment="Java preview feature API" id="640712815">
<message_arguments>
<message_argument value="GuardedPattern"/>
<message_argument value="ASTFlattener"/>
<message_argument value="getExpression()"/>
</message_arguments>
</filter>
<filter comment="Java preview feature API" id="640712815">
<message_arguments>
<message_argument value="GuardedPattern"/>
<message_argument value="ASTFlattener"/>
<message_argument value="getPattern()"/>
</message_arguments>
</filter>
<filter id="640712815">
<message_arguments>
<message_argument value="RecordPattern"/>
<message_argument value="ASTFlattener"/>
<message_argument value="patterns()"/>
</message_arguments>
</filter>
<filter comment="Java preview feature API" id="640712815">
<message_arguments>
<message_argument value="TypePattern"/>
<message_argument value="ASTFlattener"/>
<message_argument value="getPatternVariable()"/>
</message_arguments>
</filter>
</resource>
<resource path="core extension/org/eclipse/jdt/internal/corext/fix/OneIfRatherThanDuplicateBlocksThatFallThroughFixCore.java" type="org.eclipse.jdt.internal.corext.fix.OneIfRatherThanDuplicateBlocksThatFallThroughFixCore$OneIfRatherThanDuplicateBlocksThatFallThroughFinder$SuccessiveIfVisitor$PatternNameVisitor">
<filter comment="Allow TypePattern.patternVariables() call" id="640712815">
<message_arguments>
<message_argument value="TypePattern"/>
<message_argument value="PatternNameVisitor"/>
<message_argument value="patternVariables()"/>
</message_arguments>
</filter>
</resource>
<resource path="core extension/org/eclipse/jdt/internal/corext/fix/PatternMatchingForInstanceofFixCore.java" type="org.eclipse.jdt.internal.corext.fix.PatternMatchingForInstanceofFixCore$PatternMatchingForInstanceofFixOperation">
<filter comment="Need to set pattern of TypePatter" id="640712815">
<message_arguments>
<message_argument value="TypePattern"/>
<message_argument value="PatternMatchingForInstanceofFixOperation"/>
<message_argument value="setPatternVariable(SingleVariableDeclaration)"/>
</message_arguments>
</filter>
</resource>
<resource path="refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryCatchAnalyzer.java" type="org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchAnalyzer">
<filter id="640712815">
<message_arguments>
<message_argument value="TypePattern"/>
<message_argument value="SurroundWithTryCatchAnalyzer"/>
<message_argument value="getPatternVariable()"/>
</message_arguments>
</filter>
</resource>
</component>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2023 IBM Corporation and others.
* Copyright (c) 2008, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -74,17 +74,17 @@
* Helper to get the content of a Javadoc comment as HTML.
*/
public class CoreJavadocAccessImpl implements IJavadocAccess {
protected static final String BLOCK_TAG_START= "<ul>"; //$NON-NLS-1$
protected static final String BLOCK_TAG_START= "<dl>"; //$NON-NLS-1$

protected static final String BLOCK_TAG_END= "</ul>"; //$NON-NLS-1$
protected static final String BLOCK_TAG_END= "</dl>"; //$NON-NLS-1$

protected static final String BlOCK_TAG_TITLE_START= "<dt>"; //$NON-NLS-1$

protected static final String BlOCK_TAG_TITLE_END= "</dt>"; //$NON-NLS-1$

protected static final String BlOCK_TAG_ENTRY_START= "<li>"; //$NON-NLS-1$
protected static final String BlOCK_TAG_ENTRY_START= "<dd>"; //$NON-NLS-1$

protected static final String BlOCK_TAG_ENTRY_END= "</li>"; //$NON-NLS-1$
protected static final String BlOCK_TAG_ENTRY_END= "</dd>"; //$NON-NLS-1$

protected static final String PARAM_NAME_START= "<b>"; //$NON-NLS-1$

Expand Down Expand Up @@ -125,6 +125,8 @@ public class CoreJavadocAccessImpl implements IJavadocAccess {

protected int fPreCounter;

protected int fInPreCodeCounter= -1;

public CoreJavadocAccessImpl(IJavaElement element, Javadoc javadoc, String source, JavadocLookup lookup) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof IMethod || element instanceof ILocalVariable || element instanceof ITypeParameter);
Expand Down Expand Up @@ -380,7 +382,7 @@ else if (fMethod != null) {
provides.size() > 0 || hidden.size() > 0 || rest.size() > 0
|| (fBuf.length() > 0 && (parameterDescriptions.length > 0 || exceptionDescriptions.length > 0))) {
handleSuperMethodReferences();
fBuf.append(BLOCK_TAG_START);
fBuf.append(getBlockTagStart());
handleParameterTags(typeParameters, typeParameterNames, typeParameterDescriptions, true);
handleParameterTags(parameters, parameterNames, parameterDescriptions, false);
handleReturnTag(returnTag, returnDescription);
Expand All @@ -398,7 +400,7 @@ else if (fMethod != null) {
handleBlockTagsHidden();
}
handleBlockTags(rest);
fBuf.append(BLOCK_TAG_END);
fBuf.append(getBlockTagEnd());

} else if (fBuf.length() > 0) {
handleSuperMethodReferences();
Expand All @@ -420,11 +422,11 @@ protected List<TagElement> findTags(String tagName, List<TagElement> found, List
}

protected void handleBlockTagsHidden() {
String replaceAll= fBuf.toString().replaceAll(BLOCK_TAG_START, "<dl hidden>"); //$NON-NLS-1$
replaceAll= replaceAll.replaceAll(BlOCK_TAG_TITLE_START, "<dt hidden>"); //$NON-NLS-1$
replaceAll= replaceAll.replaceAll(BlOCK_TAG_ENTRY_START, "<dd hidden>"); //$NON-NLS-1$
String replaceAll= fBuf.toString().replaceAll(getBlockTagStart(), "<dl hidden>"); //$NON-NLS-1$
replaceAll= replaceAll.replaceAll(getBlockTagTitleStart(), "<dt hidden>"); //$NON-NLS-1$
replaceAll= replaceAll.replaceAll(getBlockTagEntryStart(), "<dd hidden>"); //$NON-NLS-1$
// For tags like deprecated
replaceAll= replaceAll.replaceAll(PARAM_NAME_START, "<b hidden>"); //$NON-NLS-1$
replaceAll= replaceAll.replaceAll(getParamNameStart(), "<b hidden>"); //$NON-NLS-1$
fBuf.setLength(0);
fBuf.append(replaceAll);
}
Expand Down Expand Up @@ -800,15 +802,23 @@ protected String handlePreCounter(TagElement tagElement, String text) {
++fPreCounter;
} else if (tagElement == null && text.equals("</pre>")) { //$NON-NLS-1$
--fPreCounter;
if (fPreCounter == fInPreCodeCounter) {
fInPreCodeCounter= -1;
}
} else if (tagElement == null && fPreCounter > 0 && text.matches("}\\s*</pre>")) { //$NON-NLS-1$
// this is a temporary workaround for https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/316
// as the parser for @code is treating the first } it finds as the end of the code
// sequence but this is not the case for a <pre>{@code sequence which goes over
// multiple lines and may contain }'s that are part of the code
--fPreCounter;
text= "</code></pre>"; //$NON-NLS-1$
int lastCodeEnd= fBuf.lastIndexOf("</code>"); //$NON-NLS-1$
fBuf.replace(lastCodeEnd, lastCodeEnd + 7, ""); //$NON-NLS-1$
if (fPreCounter == fInPreCodeCounter) {
text= "</code></pre>"; //$NON-NLS-1$
int lastCodeEnd= fBuf.lastIndexOf("</code>"); //$NON-NLS-1$
if (lastCodeEnd >= 0) {
fBuf.replace(lastCodeEnd, lastCodeEnd + 7, ""); //$NON-NLS-1$
}
fInPreCodeCounter= -1;
}
}
return text;
}
Expand Down Expand Up @@ -926,8 +936,12 @@ protected void handleInlineTagElement(TagElement node) {

if (isLiteral || isCode || isSummary || isIndex)
fLiteralContent++;
if (isCode || (isLink && addCodeTagOnLink()))
if (isCode || (isLink && addCodeTagOnLink())) {
if (isCode && fPreCounter > 0 && fBuf.lastIndexOf("<pre>") == fBuf.length() - 5) { //$NON-NLS-1$
fInPreCodeCounter= fPreCounter - 1;
}
fBuf.append("<code>"); //$NON-NLS-1$
}
if (isReturn)
fBuf.append(JavaDocMessages.JavadocContentAccess2_returns_pre);

Expand Down Expand Up @@ -1199,13 +1213,13 @@ protected void handleBlockTags(String title, List<TagElement> tags) {
}

protected void handleSingleTag(TagElement tag) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
if (TagElement.TAG_SEE.equals(tag.getTagName())) {
handleSeeTag(tag);
} else {
handleContentElements(tag.fragments());
}
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

protected void handleReturnTag(TagElement tag, CharSequence returnDescription) {
Expand All @@ -1217,12 +1231,12 @@ protected void handleReturnTag(TagElement tag, CharSequence returnDescription) {
}

protected void handleReturnTagBody(TagElement tag, CharSequence returnDescription) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
if (tag != null)
handleContentElements(tag.fragments());
else
fBuf.append(returnDescription);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

protected void handleBlockTags(List<TagElement> tags) {
Expand All @@ -1233,15 +1247,15 @@ protected void handleBlockTags(List<TagElement> tags) {
}

protected void handleBlockTagBody(TagElement tag) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
handleContentElements(tag.fragments());
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

protected void handleBlockTagTitle(String title) {
fBuf.append(BlOCK_TAG_TITLE_START);
fBuf.append(getBlockTagTitleStart());
fBuf.append(title);
fBuf.append(BlOCK_TAG_TITLE_END);
fBuf.append(getBlockTagTitleEnd());
}


Expand All @@ -1259,9 +1273,9 @@ protected void handleExceptionTags(List<TagElement> tags, List<String> exception

protected void handleExceptionTagsBody(List<TagElement> tags, List<String> exceptionNames, CharSequence[] exceptionDescriptions) {
for (TagElement tag : tags) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
handleThrowsTag(tag);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

for (int i= 0; i < exceptionDescriptions.length; i++) {
Expand All @@ -1274,13 +1288,13 @@ protected void handleExceptionTagsBody(List<TagElement> tags, List<String> excep
}

protected void handleSingleException(String name, CharSequence description) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
handleLink(Collections.singletonList(fJavadoc.getAST().newSimpleName(name)));
if (description != null) {
fBuf.append(JavaElementLabelsCore.CONCAT_STRING);
fBuf.append(description);
}
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

protected void handleThrowsTag(TagElement tag) {
Expand All @@ -1296,9 +1310,9 @@ protected void handleThrowsTag(TagElement tag) {
}

protected void handleSingleParameterTag(TagElement tag) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
handleParamTag(tag);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

protected void handleParameterTags(List<TagElement> tags, List<String> parameterNames, CharSequence[] parameterDescriptions, boolean isTypeParameters) {
Expand All @@ -1321,19 +1335,19 @@ protected void handleParameterTags(List<TagElement> tags, List<String> parameter
}

protected void handleSingleParameterDescription(String name, CharSequence description, boolean isTypeParameters) {
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(PARAM_NAME_START);
fBuf.append(getBlockTagEntryStart());
fBuf.append(getParamNameStart());
if (isTypeParameters) {
fBuf.append("&lt;"); //$NON-NLS-1$
}
fBuf.append(name);
if (isTypeParameters) {
fBuf.append("&gt;"); //$NON-NLS-1$
}
fBuf.append(PARAM_NAME_END);
fBuf.append(getParamNameEnd());
if (description != null)
fBuf.append(description);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}

protected void handleParamTag(TagElement tag) {
Expand All @@ -1342,7 +1356,7 @@ protected void handleParamTag(TagElement tag) {
int size= fragments.size();
if (size > 0) {
Object first= fragments.get(0);
fBuf.append(PARAM_NAME_START);
fBuf.append(getParamNameStart());
if (first instanceof SimpleName) {
String name= ((SimpleName) first).getIdentifier();
fBuf.append(name);
Expand Down Expand Up @@ -1370,7 +1384,7 @@ protected void handleParamTag(TagElement tag) {
}
}
}
fBuf.append(PARAM_NAME_END);
fBuf.append(getParamNameEnd());

handleContentElements(fragments.subList(i, fragments.size()));
}
Expand All @@ -1382,7 +1396,7 @@ protected void handleSummary(List<? extends ASTNode> fragments) {
Object first= fragments.get(0);
if (first instanceof TextElement) {
TextElement memberRef= (TextElement) first;
fBuf.append(BlOCK_TAG_TITLE_START + "Summary: " + memberRef.getText() + BlOCK_TAG_TITLE_END); //$NON-NLS-1$
fBuf.append(getBlockTagTitleStart() + "Summary: " + memberRef.getText() + getBlockTagTitleEnd()); //$NON-NLS-1$
return;
}
}
Expand All @@ -1403,9 +1417,9 @@ protected void handleSnippet(TagElement node) {
} else {
fBuf.append("<code>");//$NON-NLS-1$
}
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(getBlockTagEntryStart());
fSnippetStringEvaluator.AddTagElementString(node, fBuf);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(getBlockTagEntryEnd());
}
} else {
handleInvalidSnippet(node);
Expand Down Expand Up @@ -1525,4 +1539,28 @@ protected boolean containsOnlyNull(List<String> parameterNames) {
return true;
}

protected String getBlockTagStart() {
return BLOCK_TAG_START;
}
protected String getBlockTagEnd() {
return BLOCK_TAG_END;
}
protected String getBlockTagTitleStart() {
return BlOCK_TAG_TITLE_START;
}
protected String getBlockTagTitleEnd() {
return BlOCK_TAG_TITLE_END;
}
protected String getBlockTagEntryStart() {
return BlOCK_TAG_ENTRY_START;
}
protected String getBlockTagEntryEnd() {
return BlOCK_TAG_ENTRY_END;
}
protected String getParamNameStart() {
return PARAM_NAME_START;
}
protected String getParamNameEnd() {
return PARAM_NAME_END;
}
}

0 comments on commit 0b7f512

Please sign in to comment.