Skip to content

Commit

Permalink
Merge branch 'eclipse-jdt:master' into feature/foldingStrucktur
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-suliga committed Sep 25, 2024
2 parents de3ef6b + 66053c1 commit 08cd1d9
Show file tree
Hide file tree
Showing 77 changed files with 2,669 additions and 238 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pipeline {
timestamps()
}
agent {
label "centos-latest"
label "ubuntu-latest"
}
tools {
maven 'apache-maven-latest'
Expand All @@ -19,7 +19,7 @@ pipeline {
sh """
mvn -U -e -DskipTests=false -Dmaven.repo.local=$WORKSPACE/.m2/repository \
clean verify --batch-mode --fail-at-end \
-Pbree-libs -Papi-check -Pjavadoc \
-Pbree-libs -Papi-check -Pjavadoc -Pbuild-individual-bundles \
-Dmaven.test.failure.ignore=true \
-Dcompare-version-with-baselines.skip=false
"""
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.astview.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.jdt.astview.feature"
label="Java AST View"
version="1.2.300.qualifier"
version="1.2.350.qualifier"
provider-name="Eclipse.org"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.astview/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.astview
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.astview; singleton:=true
Bundle-Version: 1.6.200.qualifier
Bundle-Version: 1.6.250.qualifier
Bundle-Activator: org.eclipse.jdt.astview.ASTViewPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
public class ASTView extends ViewPart implements IShowInSource, IShowInTargetList {

static final int JLS_LATEST= AST.getJLSLatest();
private static final int JLS23= ASTHelper.JLS23;
private static final int JLS22= ASTHelper.JLS22;
private static final int JLS21= ASTHelper.JLS21;
private static final int JLS20= ASTHelper.JLS20;
Expand Down Expand Up @@ -522,6 +523,7 @@ public ASTView() {
case JLS20:
case JLS21:
case JLS22:
case JLS23:
fCurrentASTLevel= level;
}
} catch (NumberFormatException e) {
Expand Down Expand Up @@ -1150,6 +1152,7 @@ public void run() {
new ASTLevelToggle("AST Level 2&0 (20)", JLS20), //$NON-NLS-1$
new ASTLevelToggle("AST Level 2&1 (21)", JLS21), //$NON-NLS-1$
new ASTLevelToggle("AST Level 2&2 (22)", JLS22), //$NON-NLS-1$
new ASTLevelToggle("AST Level 2&3 (23)", JLS23), //$NON-NLS-1$
};

fAddToTrayAction= new Action() {
Expand Down
8 changes: 8 additions & 0 deletions org.eclipse.jdt.core.manipulation/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@
</message_arguments>
</filter>
</resource>
<resource path="proposals/org/eclipse/jdt/ui/text/IJavaPartitions.java" type="org.eclipse.jdt.ui.text.IJavaPartitions">
<filter id="403767336">
<message_arguments>
<message_argument value="org.eclipse.jdt.ui.text.IJavaPartitions"/>
<message_argument value="JAVA_MARKDOWN_COMMENT"/>
</message_arguments>
</filter>
</resource>
</component>
4 changes: 3 additions & 1 deletion org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.31.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="3.23.0",
org.eclipse.core.filesystem;bundle-version="1.10.0",
org.eclipse.core.filebuffers;bundle-version="3.8.0",
org.eclipse.search.core;bundle-version="3.16.0"
org.eclipse.search.core;bundle-version="3.16.0",
org.commonmark;bundle-version="0.22.0",
org.commonmark-gfm-tables;bundle-version="0.22.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.jdt.core.manipulation,
org.eclipse.jdt.core.refactoring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ protected String readHTMLContent(IPackageFragment packageFragment) throws CoreEx
return packageFragment.getAttachedJavadoc(null);

}

return null;
return ""; //$NON-NLS-1$
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*******************************************************************************
* Copyright (c) 2024 GK Software SE and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Stephan Herrmann - Initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.core.manipulation.internal.javadoc;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.commonmark.Extension;
import org.commonmark.ext.gfm.tables.TablesExtension;
import org.commonmark.node.Document;
import org.commonmark.node.Node;
import org.commonmark.node.Paragraph;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;

import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Javadoc;
import org.eclipse.jdt.core.dom.TagElement;
import org.eclipse.jdt.core.dom.TextElement;

public class CoreMarkdownAccessImpl extends CoreJavadocAccessImpl {

private Parser fParser;
private HtmlRenderer fRenderer;
private int fBlockDepth= 0;

public CoreMarkdownAccessImpl(IJavaElement element, Javadoc javadoc, String source) {
super(element, javadoc, source);
init();
}
public CoreMarkdownAccessImpl(IJavaElement element, Javadoc javadoc, String source, JavadocLookup lookup) {
super(element, javadoc, source, lookup);
init();
}

private void init() {
List<Extension> extensions= List.of(TablesExtension.create());
fParser= Parser.builder().extensions(extensions).build();
fRenderer= HtmlRenderer.builder().extensions(extensions).build();
}

@Override
protected String removeDocLineIntros(String textWithSlashes) {
String lineBreakGroup= "(\\r\\n?|\\n)"; //$NON-NLS-1$
String noBreakSpace= "[^\r\n&&\\s]"; //$NON-NLS-1$
// in the markdown case relevant leading whitespace is contained in TextElements, no need to preserve blanks *between* elements
return textWithSlashes.replaceAll(lineBreakGroup + noBreakSpace + "*///" + noBreakSpace + '*', "$1"); //$NON-NLS-1$ //$NON-NLS-2$
}

@Override
protected void handleLink(List<? extends ASTNode> fragments) {
if (fragments.size() == 2 && fragments.get(0) instanceof TextElement) {
// super method expects the reference as first fragment, optional label as second fragment
fragments= Arrays.asList(fragments.get(1), fragments.get(0));
}
super.handleLink(fragments);
}

@Override
protected String getBlockTagStart() {
this.fBlockDepth++;
return "\n"+super.getBlockTagStart(); //$NON-NLS-1$
}

@Override
protected String getBlockTagEnd() {
if (this.fBlockDepth > 0)
this.fBlockDepth--;
return super.getBlockTagEnd();
}

@Override
protected void handleContentElements(List<? extends ASTNode> nodes, boolean skipLeadingWhitespace, TagElement tagElement) {
int start= fBuf.length();
super.handleContentElements(nodes, skipLeadingWhitespace, tagElement);
if (this.fBlockDepth > 0) {
// inside an HTML block the markdown content must be rendered now
String generated= fBuf.substring(start); // extract new part of fBuf
Node node= fParser.parse(generated);
if (node.getFirstChild() instanceof Paragraph para && para.getNext() == null) {
// inside block replace single paragraph with its children
node= eliminateContainerNode(para);
}
String rendered= fRenderer.render(node);
fBuf.replace(start, fBuf.length(), rendered); // replace new part with its rendered version
}
}

/** Return a new Document containing all children of the given container node. */
protected Node eliminateContainerNode(Node container) {
List<Node> children= new ArrayList<>();
for (Node child= container.getFirstChild(); child != null; child= child.getNext()) {
children.add(child);
}
Document doc= new Document();
for (Node child2 : children) {
doc.appendChild(child2);
}
return doc;
}

@Override
public String toHTML() {
String content= super.toHTML();
Node document= fParser.parse(content);
return fRenderer.render(document);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* Copyright (c) 2023, 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 @@ -33,6 +33,12 @@ public class JavadocLookup {
public static final IJavadocContentFactory DEFAULT_FACTORY= new IJavadocContentFactory() {
@Override
public IJavadocAccess createJavadocAccess(IJavaElement element, Javadoc javadoc, String source, JavadocLookup lookup) {
if (source.startsWith("///")) { //$NON-NLS-1$
if (lookup == null)
return new CoreMarkdownAccessImpl(element, javadoc, source);
else
return new CoreMarkdownAccessImpl(element, javadoc, source, lookup);
}
if (lookup == null)
return new CoreJavadocAccessImpl(element, javadoc, source);
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2024 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.fix;

import org.eclipse.jface.text.BadLocationException;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;

import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
import org.eclipse.jdt.internal.corext.refactoring.nls.NLSScanner;

public class CleanUpNLSUtils {

public static NLSLine scanCurrentLine(ICompilationUnit cu, ASTNode exp) {
CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
int startLine= cUnit.getLineNumber(exp.getStartPosition());
int lineStart= cUnit.getPosition(startLine, 0);
int endOfLine= cUnit.getPosition(startLine + 1, 0);
NLSLine[] lines;
try {
lines= NLSScanner.scan(cu.getBuffer().getText(lineStart, endOfLine - lineStart));
if (lines.length > 0) {
return lines[0];
}
} catch (IndexOutOfBoundsException | JavaModelException | InvalidInputException | BadLocationException e) {
e.printStackTrace();
// fall-through
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2023 IBM Corporation and others.
* Copyright (c) 2000, 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 @@ -73,6 +73,7 @@ private MultiFixMessages() {
public static String CodeStyleCleanUp_PullUpAssignment_description;
public static String CodeStyleCleanUp_ElseIf_description;
public static String CodeStyleCleanUp_ReduceIndentation_description;
public static String CodeStyleCleanUp_SimplifyBooleanIfElse_description;
public static String CodeStyleCleanUp_Instanceof_description;
public static String CodeStyleCleanUp_numberSuffix_description;
public static String CodeStyleCleanUp_QualifyNonStaticMethod_description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2005, 2023 IBM Corporation and others.
# Copyright (c) 2005, 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 @@ -37,6 +37,7 @@ CodeStyleCleanUp_ExtractIncrement_description=Extract increment/decrement from s
CodeStyleCleanUp_PullUpAssignment_description=Pull up assignment
CodeStyleCleanUp_ElseIf_description=Combine nested 'if' statement in 'else' block to 'else if'
CodeStyleCleanUp_ReduceIndentation_description=Reduce indentation
CodeStyleCleanUp_SimplifyBooleanIfElse_description=Simplify boolean if/else to a single return if possible
CodeStyleCleanUp_Instanceof_description=Use instanceof keyword instead of Class.isInstance()
CodeStyleCleanUp_numberSuffix_description=Use uppercase for long literal suffix
CodeFormatFix_RemoveTrailingWhitespace_changeDescription=Remove trailing whitespace
Expand Down
Loading

0 comments on commit 08cd1d9

Please sign in to comment.