Skip to content

Commit

Permalink
Merge pull request #7377 from apache/delivery
Browse files Browse the repository at this point in the history
Sync delivery to release220 for 22-rc4
  • Loading branch information
ebarboni authored May 16, 2024
2 parents 9f0aa24 + 26b10a0 commit 0d0bfcf
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 63 deletions.
4 changes: 2 additions & 2 deletions extide/gradle/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

file.reference.netbeans-gradle-tooling.jar=release/modules/gradle/netbeans-gradle-tooling.jar
is.autoload=true
javac.source=17
javac.target=17
javac.source=1.8
javac.target=1.8
javac.compilerargs=-Xlint -Xlint:-serial
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void read(WizardDescriptor settings) {

if (settings.getProperty(PROP_JAVA_VERSIONS) != null) {
List<Integer> javaVersions = (List<Integer>) settings.getProperty(PROP_JAVA_VERSIONS);
DefaultComboBoxModel<Integer> versionModel = new DefaultComboBoxModel<>(javaVersions.toArray(Integer[]::new));
DefaultComboBoxModel<Integer> versionModel = new DefaultComboBoxModel<>(javaVersions.toArray(new Integer[0]));
cbJavaVersion.setModel(versionModel);

if (settings.getProperty(PROP_JAVA_VERSION) != null) {
Expand All @@ -241,7 +241,7 @@ void read(WizardDescriptor settings) {

if (settings.getProperty(PROP_TEST_FRAMEWORKS) != null) {
List<TestFramework> testframeworks = (List<TestFramework>) settings.getProperty(PROP_TEST_FRAMEWORKS);
DefaultComboBoxModel<TestFramework> frameworkModel = new DefaultComboBoxModel<>(testframeworks.toArray(TestFramework[]::new));
DefaultComboBoxModel<TestFramework> frameworkModel = new DefaultComboBoxModel<>(testframeworks.toArray(new TestFramework[0]));
cbTestFramework.setModel(frameworkModel);
if (settings.getProperty(PROP_TEST_FRAMEWORK) != null) {
cbTestFramework.setSelectedItem(settings.getProperty(PROP_TEST_FRAMEWORK));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -56,18 +59,18 @@ public class GradleProcessorFactory implements OutputProcessorFactory {

@Override
public Set<? extends OutputProcessor> createOutputProcessors(RunConfig cfg) {
return Set.of(
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
GRADLE_PROCESSOR,
JAVAC_PROCESSOR,
GROOVYC_PROCESSOR,
new WarningModeAllProcessor(cfg)
);
)));
}

private static final Pattern GRADLE_ERROR = Pattern.compile("(Build file|Script) '(.*)\\.gradle' line: ([0-9]+)");

public static final OutputProcessor GRADLE_PROCESSOR = new OutputProcessor() {

private static final Pattern GRADLE_ERROR = Pattern.compile("(Build file|Script) '(.*)\\.gradle' line: ([0-9]+)");

@Override
public boolean processLine(OutputDisplayer out, String line) {
Expand All @@ -90,9 +93,9 @@ public boolean processLine(OutputDisplayer out, String line) {
}
};

public static final OutputProcessor JAVAC_PROCESSOR = new OutputProcessor() {
private static final Pattern JAVA_ERROR = Pattern.compile("(.*)\\.java\\:([0-9]+)\\: (error|warning)\\:(.*)");

private static final Pattern JAVA_ERROR = Pattern.compile("(.*)\\.java\\:([0-9]+)\\: (error|warning)\\:(.*)");
public static final OutputProcessor JAVAC_PROCESSOR = new OutputProcessor() {

@Override
public boolean processLine(OutputDisplayer out, String line) {
Expand All @@ -118,10 +121,10 @@ public boolean processLine(OutputDisplayer out, String line) {
}
};

public static final OutputProcessor GROOVYC_PROCESSOR = new OutputProcessor() {
private static final Pattern GROOVY_ERROR = Pattern.compile("(.*)\\.groovy\\: ([0-9]+)\\: (.+)");
private static final Pattern COLUMN_INFO = Pattern.compile(" @ line ([0-9]+), column ([0-9]+)\\.$");

private static final Pattern GROOVY_ERROR = Pattern.compile("(.*)\\.groovy\\: ([0-9]+)\\: (.+)");
private static final Pattern COLUMN_INFO = Pattern.compile(" @ line ([0-9]+), column ([0-9]+)\\.$");
public static final OutputProcessor GROOVYC_PROCESSOR = new OutputProcessor() {

@Override
public boolean processLine(OutputDisplayer out, String line) {
Expand Down Expand Up @@ -156,9 +159,9 @@ public boolean processLine(OutputDisplayer out, String line) {

};

public static final OutputProcessor URL_PROCESSOR = new OutputProcessor() {
private static final Pattern URL_PATTERN = Pattern.compile("(((https?|ftp|file)://|file:/)[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|])");

private static final Pattern URL_PATTERN = Pattern.compile("(((https?|ftp|file)://|file:/)[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|])");
public static final OutputProcessor URL_PROCESSOR = new OutputProcessor() {

@Override
public boolean processLine(OutputDisplayer out, String line) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
package org.netbeans.modules.gradle.spi.newproject;

import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.netbeans.modules.gradle.newproject.GradleInitPanel;
import org.netbeans.spi.project.ui.support.CommonProjectActions;
import org.openide.WizardDescriptor;
Expand Down Expand Up @@ -49,10 +51,11 @@ public enum GradleDSL {

@Override
public String toString() {
return switch(this) {
case GROOVY -> Bundle.LBL_DSL_GROOVY();
case KOTLIN -> Bundle.LBL_DSL_KOTLIN();
};
switch(this) {
case GROOVY: return Bundle.LBL_DSL_GROOVY();
case KOTLIN: return Bundle.LBL_DSL_KOTLIN();
default: throw new IllegalStateException("update switch");
}
}
}

Expand Down Expand Up @@ -88,16 +91,17 @@ public String getId() {

@Override
public String toString() {
return switch(this) {
case CPP_TEST -> Bundle.LBL_TFW_CPP_TEST();
case JUNIT -> Bundle.LBL_TFW_JUNIT();
case JUNIT_5 -> Bundle.LBL_TFW_JUNIT_5();
case KOTLIN_TEST -> Bundle.LBL_TFW_KOTLIN_TEST();
case SCALA_TEST -> Bundle.LBL_TFW_SCALA_TEST();
case SPOCK -> Bundle.LBL_TFW_SPOCK();
case TESTNG -> Bundle.LBL_TFW_TESTNG();
case XCTEST -> Bundle.LBL_TFW_XCTEST();
};
switch(this) {
case CPP_TEST: return Bundle.LBL_TFW_CPP_TEST();
case JUNIT: return Bundle.LBL_TFW_JUNIT();
case JUNIT_5: return Bundle.LBL_TFW_JUNIT_5();
case KOTLIN_TEST: return Bundle.LBL_TFW_KOTLIN_TEST();
case SCALA_TEST: return Bundle.LBL_TFW_SCALA_TEST();
case SPOCK: return Bundle.LBL_TFW_SPOCK();
case TESTNG: return Bundle.LBL_TFW_TESTNG();
case XCTEST: return Bundle.LBL_TFW_XCTEST();
default: throw new IllegalStateException("update switch");
}
}
}

Expand All @@ -108,7 +112,7 @@ public String toString() {
private TestFramework preferredTestFramework;
private List<Integer> javaVersions;
private List<TestFramework> testFrameworks;
private List<String> important = List.of();
private List<String> important = Collections.emptyList();

private GradleInitWizard(String type, String title) {
this.type = type;
Expand Down Expand Up @@ -211,14 +215,14 @@ protected void collectOperations(TemplateOperation ops, Map<String, Object> para
List<String> open = important.stream()
.map((s) -> packageBase != null ? s.replace("${package}", packageBase.replace('.', '/')) : s) //NOI18N
.map((s) -> s.replace("${projectName}", name)) //NOI18N
.toList();
.collect(Collectors.toList());
ops.addProjectPreload(root, open);
}


@Override
protected List<? extends WizardDescriptor.Panel<WizardDescriptor>> createPanels() {
return List.of(new GradleInitPanel());
return Collections.singletonList(new GradleInitPanel());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
Expand Down Expand Up @@ -353,8 +354,8 @@ public Set<FileObject> execute() {
args.add("--use-defaults");

try (
var out = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false));
var err = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false))
OutputStream out = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false));
OutputStream err = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false))
) {
BuildLauncher gradleInit = pconn.newBuild().forTasks(args.toArray(new String[0]));
if (GradleSettings.getDefault().isOffline()) {
Expand Down Expand Up @@ -488,7 +489,7 @@ private static final class PreloadProject extends BaseOperationStep {
final List<String> importantFiles;

public PreloadProject(File dir) {
this(dir, List.of());
this(dir, Collections.emptyList());
}

public PreloadProject(File dir, List<String> importantFiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@ActionRegistration(displayName = "#CTL_Close", lazy = true) //NOI18N
@ActionReferences({
@ActionReference(path = ActionFactory.ACTIONS_PATH, name = "CloseAction"), //NOI18N
@ActionReference(path = "Shortcuts", name = "CS-W")
})
public final class CloseAction extends TerminalAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,20 @@ public Void visitIdentifier(IdentifierTree tree, Map<String, Object> p) {
}
}

if (type != null && type.getKind() == TypeKind.PACKAGE) {
if (type.getKind() == TypeKind.PACKAGE) {
TreePath parent = getCurrentPath().getParentPath();
Element fullPackage = el;
while (parent != null) {
Element parentElement = info.getTrees().getElement(parent);
if (parentElement != null && parentElement.getKind() == ElementKind.PACKAGE) {
fullPackage = parentElement;
parent = parent.getParentPath();
} else {
break;
}
}
//does the package really exists?
String s = ((PackageElement) el).getQualifiedName().toString();
String s = ((PackageElement) fullPackage).getQualifiedName().toString();
Element thisPack = info.getTrees().getElement(new TreePath(info.getCompilationUnit()));
ModuleElement module = thisPack != null ? info.getElements().getModuleOf(thisPack) : null;
PackageElement pack = module != null ? info.getElements().getPackageElement(module, s) : info.getElements().getPackageElement(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -308,6 +306,26 @@ public void testRecordImport() throws Exception {
"");
}

// https://github.com/apache/netbeans/issues/7073
public void testDontImportRootPackageMatchingMember() throws Exception {
doTest("test/Test",
"11",
Arrays.asList(
new FileData("test/Test.java",
"package test;\n" +
"import java.util.List;\n" +
"public class Test {\n" +
" public static class SomeClass {\n" +
" public static Object java(java.util.Map<String, String> value) {\n" +
" return value;\n" +
" }\n" +
" }\n" +
"}")
),
"",
"");
}

private void prepareTest(String capitalizedName, String sourceLevel, Iterable<FileData> files) throws Exception {
FileObject workFO = FileUtil.toFileObject(getWorkDir());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,14 @@ private PathFinder(int pos, SourcePositions sourcePositions) {

public Void scan(Tree tree, Void p) {
if (tree != null) {
long startPos = sourcePositions.getStartPosition(getCurrentPath().getCompilationUnit(), tree);
long endPos = sourcePositions.getEndPosition(getCurrentPath().getCompilationUnit(), tree);
if (endPos == (-1)) {
switch (tree.getKind()) {
case ASSIGNMENT:
if (getCurrentPath().getLeaf().getKind() == Kind.ANNOTATION) {
ExpressionTree value = ((AssignmentTree) tree).getExpression();
startPos = sourcePositions.getStartPosition(getCurrentPath().getCompilationUnit(), value);
endPos = sourcePositions.getEndPosition(getCurrentPath().getCompilationUnit(), value);
}
break;
Expand All @@ -376,7 +378,7 @@ public Void scan(Tree tree, Void p) {
break;
}
}
if (sourcePositions.getStartPosition(getCurrentPath().getCompilationUnit(), tree) < pos && endPos >= pos) {
if (startPos < pos && endPos >= pos) {
if (tree.getKind() == Tree.Kind.ERRONEOUS) {
tree.accept(this, p);
throw new Result(getCurrentPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,15 @@ public void testAnnotationSyntheticValue3() throws Exception {
assertEquals(Kind.MEMBER_SELECT, tp.getLeaf().getKind());
assertEquals("Test.VALUE", tp.getLeaf().toString());
}

public void testAnnotationSyntheticValue4() throws Exception {
prepareTest("Test", "package test; @Meta(String.class) public class Test { } @interface Meta { public Class value(); }");

TreePath tp = info.getTreeUtilities().pathFor(24);

assertEquals(Kind.IDENTIFIER, tp.getLeaf().getKind());
assertEquals("String", tp.getLeaf().toString());
}

public void testAutoMapComments1() throws Exception {
prepareTest("Test", "package test;\n" +
Expand Down
4 changes: 2 additions & 2 deletions java/libs.javacapi/external/binaries-list
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
8F51DAC670C68C5F54EA1F6C114CCDB39A59CF50 com.dukescript.nbjavac:nb-javac:jdk-22+33:api
BEBF599062B88260B9F75C0EE3DD33D2870B39E3 com.dukescript.nbjavac:nb-javac:jdk-22+33
07266A99C001F11616B36F5128EB78D2242F3096 com.dukescript.nbjavac:nb-javac:jdk-22.0.1+8:api
D8B9FE09D677A6D589BA3C1E5AD636AF7F47AEE2 com.dukescript.nbjavac:nb-javac:jdk-22.0.1+8
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Name: Javac Compiler Implementation
Description: Javac Compiler Implementation
Version: jdk-22+33
Files: nb-javac-jdk-22+33-api.jar nb-javac-jdk-22+33.jar
Version: jdk-22.0.1+8
Files: nb-javac-jdk-22.0.1+8-api.jar nb-javac-jdk-22.0.1+8.jar
License: GPL-2-CP
Origin: OpenJDK (https://github.com/openjdk/jdk22)
Source: https://github.com/openjdk/jdk22
Origin: OpenJDK (https://github.com/openjdk/jdk22u)
Source: https://github.com/openjdk/jdk22u
Type: optional,reviewed
Comment: The binary has been reviewed to be under the Classpath Exception as a whole. Optional at runtime, but used by default.

Expand Down
1 change: 0 additions & 1 deletion java/libs.javacapi/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ build.compiler.debug=false
build.compiler.deprecation=false
is.autoload=true
javadoc.title=Javac API
nbm.homepage=http://jackpot.netbeans.org/
nbm.module.author=Petr Hrebejk
spec.version.base=8.48.0
javadoc.arch=${basedir}/arch.xml
Expand Down
4 changes: 2 additions & 2 deletions java/libs.javacapi/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
</public-packages>
<class-path-extension>
<runtime-relative-path />
<binary-origin>external/nb-javac-jdk-22+33-api.jar</binary-origin>
<binary-origin>external/nb-javac-jdk-22.0.1+8-api.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path />
<binary-origin>external/nb-javac-jdk-22+33.jar</binary-origin>
<binary-origin>external/nb-javac-jdk-22.0.1+8.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
Expand Down
4 changes: 2 additions & 2 deletions java/libs.nbjavacapi/external/binaries-list
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
8F51DAC670C68C5F54EA1F6C114CCDB39A59CF50 com.dukescript.nbjavac:nb-javac:jdk-22+33:api
BEBF599062B88260B9F75C0EE3DD33D2870B39E3 com.dukescript.nbjavac:nb-javac:jdk-22+33
07266A99C001F11616B36F5128EB78D2242F3096 com.dukescript.nbjavac:nb-javac:jdk-22.0.1+8:api
D8B9FE09D677A6D589BA3C1E5AD636AF7F47AEE2 com.dukescript.nbjavac:nb-javac:jdk-22.0.1+8
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Name: Javac Compiler Implementation
Description: Javac Compiler Implementation
Version: jdk-22+33
Files: nb-javac-jdk-22+33-api.jar nb-javac-jdk-22+33.jar
Version: jdk-22.0.1+8
Files: nb-javac-jdk-22.0.1+8-api.jar nb-javac-jdk-22.0.1+8.jar
License: GPL-2-CP
Origin: OpenJDK (https://github.com/openjdk/jdk22)
Source: https://github.com/openjdk/jdk22
Origin: OpenJDK (https://github.com/openjdk/jdk22u)
Source: https://github.com/openjdk/jdk22u
Type: optional,reviewed
Comment: The binary has been reviewed to be under the Classpath Exception as a whole. Optional at runtime, but used by default.

Expand Down
Loading

0 comments on commit 0d0bfcf

Please sign in to comment.