[netbeans] branch jtulach/BuildNetBeansWithNbJavac created (now 81b0bd588c)

2023-03-04 Thread jtulach
This is an automated email from the ASF dual-hosted git repository.

jtulach pushed a change to branch jtulach/BuildNetBeansWithNbJavac
in repository https://gitbox.apache.org/repos/asf/netbeans.git


  at 81b0bd588c Allow building NetBeans with NbJavac compiler

This branch includes the following new commits:

 new 81b0bd588c Allow building NetBeans with NbJavac compiler

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



-
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



[netbeans] 01/01: Allow building NetBeans with NbJavac compiler

2023-03-04 Thread jtulach
This is an automated email from the ASF dual-hosted git repository.

jtulach pushed a commit to branch jtulach/BuildNetBeansWithNbJavac
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit 81b0bd588cbcb1dac7719bfd77a948645d587442
Author: Jaroslav Tulach 
AuthorDate: Sun Mar 5 05:33:01 2023 +0100

Allow building NetBeans with NbJavac compiler
---
 .../antsrc/org/netbeans/nbbuild/CustomJavac.java   | 158 +
 1 file changed, 158 insertions(+)

diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java 
b/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java
index c2f69cbe83..ad39233960 100644
--- a/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java
@@ -20,18 +20,31 @@
 package org.netbeans.nbbuild;
 
 import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import javax.tools.StandardLocation;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.taskdefs.Javac;
+import org.apache.tools.ant.taskdefs.compilers.Javac13;
+import org.apache.tools.ant.types.Commandline;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.selectors.SelectorUtils;
+import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.util.JavaEnvUtils;
 
 /**
@@ -115,6 +128,17 @@ public class CustomJavac extends Javac {
 } else {
 log("Warning: could not create " + generatedClassesDir, 
Project.MSG_WARN);
 }
+try {
+Class mainClazz = 
NbJavacLoader.findMainCompilerClass(getProject());
+if (mainClazz != null) {
+super.add(new NbJavacCompiler(mainClazz));
+}
+} catch (ClassNotFoundException | MalformedURLException | 
URISyntaxException ex) {
+if (ex instanceof BuildException) {
+throw (BuildException) ex;
+}
+throw new BuildException(ex);
+}
 super.compile();
 }
 
@@ -252,4 +276,138 @@ public class CustomJavac extends Javac {
 return false;
 }
 
+private static final class NbJavacLoader extends URLClassLoader {
+private static final String MAIN_COMPILER_CP = "nbjavac.class.path";
+private static final String MAIN_COMPILER_CLASS = 
"com.sun.tools.javac.Main";
+private final Map> priorityLoaded;
+
+private NbJavacLoader(URL[] urls, ClassLoader parent) {
+super(urls, parent);
+this.priorityLoaded = new HashMap<>();
+}
+
+private static synchronized Class findMainCompilerClass(
+Project prj
+) throws MalformedURLException, ClassNotFoundException, 
URISyntaxException {
+String cp = prj.getProperty(MAIN_COMPILER_CP);
+if (cp == null) {
+return null;
+}
+
+Object c = System.getProperties().get(MAIN_COMPILER_CLASS);
+if (!(c instanceof Class)) {
+FileSet fs = new FileSet();
+String nball = prj.getProperty("nb_all");
+if (nball != null) {
+fs.setDir(new File(nball));
+} else {
+fs.setDir(prj.getBaseDir());
+}
+fs.setIncludes(cp);
+List urls = new ArrayList<>();
+final DirectoryScanner scan = fs.getDirectoryScanner(prj);
+File base = scan.getBasedir();
+for (String relative : scan.getIncludedFiles()) {
+File file = new File(base, relative);
+URL url = FileUtils.getFileUtils().getFileURL(file);
+urls.add(url);
+}
+if (urls.isEmpty()) {
+throw new BuildException("Cannot find nb-javac JAR 
libraries in " + base + " and " + cp);
+}
+URLClassLoader loader = new NbJavacLoader(urls.toArray(new 
URL[0]), CustomJavac.class.getClassLoader().getParent());
+final Class newCompilerClass = 
Class.forName(MAIN_COMPILER_CLASS, true, loader);
+assertIsolatedClassLoader(newCompilerClass, loader);
+System.getProperties().put(MAIN_COMPILER_CLASS, 
newCompilerClass);
+c = newCompilerClass;
+}
+return (Class) c;
+}
+
+private static void assertIsolatedClassLoader(Class c, 
URLClassLoader loader) throws Clas

[netbeans] branch master updated (4c7e626b332 -> 0b7adbcd316)

2023-03-04 Thread mbien
This is an automated email from the ASF dual-hosted git repository.

mbien pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


from 4c7e626b332 Merge pull request #5365 from mbien/missing-record-enums
 new f6627614995 Adding support for JDK 20 javac.
 new c8de82fc93c Updating versions, adding test for try-with-resources, 
removing the existing workaround(?) for it.
 new 395ead130d9 Adding forgotten test.
 new 121f6fc838d Merge branch 'master' into jdk20
 new 0b7adbcd316 Merge pull request #5550 from jlahoda/jdk20

The 8174 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../project/NbModuleProjectGenerator.java  |  2 +-
 .../org/netbeans/modules/classfile/ModuleTest.java |  2 +-
 .../java/hints/errors/ChangeMethodReturnType.java  |  6 +-
 .../modules/java/hints/errors/ChangeType.java  | 11 ++-
 .../modules/java/hints/errors/Utilities.java   |  6 +-
 .../hints/infrastructure/ErrorHintsProvider.java   |  3 +-
 .../hints/jdk/ConvertToNestedRecordPattern.java| 76 +++---
 .../jdk/ConvertToSwitchPatternInstanceOf.java  |  9 +--
 .../ErrorHintsProviderTest/testShortErrors8.pass   | 10 ++-
 .../test/unit/data/javahints/TestShortErrors8.java | 14 +++-
 .../java/hints/errors/AddFinalModifierTest.java| 10 +++
 .../modules/java/hints/errors/ChangeTypeTest.java  |  4 +-
 .../infrastructure/ErrorHintsProviderTest.java | 22 +-
 .../hints/jdk/ConvertSwitchToRuleSwitchTest.java   |  6 +-
 .../jdk/ConvertToNestedRecordPatternTest.java  | 90 --
 .../jdk/ConvertToSwitchPatternInstanceOfTest.java  | 16 ++--
 .../java/hints/suggestions/TooStrongCastTest.java  |  5 +-
 .../org/netbeans/api/java/source/TreeMaker.java|  5 +-
 .../modules/java/source/NoJavacHelper.java |  2 +-
 .../modules/java/source/builder/TreeFactory.java   | 58 +++---
 .../modules/java/source/pretty/VeryPretty.java |  5 +-
 .../modules/java/source/save/CasualDiff.java   |  7 +-
 .../modules/java/source/save/Reformatter.java  |  6 +-
 .../source/transform/ImmutableTreeTranslator.java  |  5 +-
 .../java/source/transform/TreeDuplicator.java  |  2 +-
 .../java/source/JavaSourceUtilImplTest.java|  8 +-
 .../modules/java/source/PostFlowAnalysisTest.java  |  8 +-
 .../modules/java/source/save/FormatingTest.java| 50 ++--
 .../lib/nbjavac/services/NBParserFactory.java  |  5 +-
 .../lib/nbjavac/services/NBClassFinderTest.java| 67 +---
 .../lib/nbjavac/services/NBClassWriterTest.java|  2 +-
 java/libs.javacapi/external/binaries-list  |  4 +-
 ...-license.txt => nb-javac-jdk-20+34-license.txt} |  8 +-
 .../nbproject/org-netbeans-libs-javacapi.sig   | 57 +++---
 java/libs.javacapi/nbproject/project.properties|  2 +-
 java/libs.javacapi/nbproject/project.xml   |  4 +-
 java/libs.nbjavacapi/external/binaries-list|  4 +-
 ...-license.txt => nb-javac-jdk-20+34-license.txt} | 12 +--
 java/libs.nbjavacapi/manifest.mf   |  2 +-
 java/libs.nbjavacapi/nbproject/project.properties  |  4 +-
 java/libs.nbjavacapi/nbproject/project.xml |  8 +-
 .../netbeans/modules/nbjavac/api/Bundle.properties |  2 +-
 .../org/netbeans/nbbuild/extlibs/ignored-overlaps  |  4 +-
 43 files changed, 422 insertions(+), 211 deletions(-)
 rename java/libs.javacapi/external/{nb-javac-jdk-19.0.1-ga-license.txt => 
nb-javac-jdk-20+34-license.txt} (99%)
 rename java/libs.nbjavacapi/external/{nb-javac-jdk-19.0.1-ga-license.txt => 
nb-javac-jdk-20+34-license.txt} (98%)


-
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



[netbeans] branch master updated: bulk added some missing record enums.

2023-03-04 Thread mbien
This is an automated email from the ASF dual-hosted git repository.

mbien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
 new b24ef7791d1 bulk added some missing record enums.
 new 4c7e626b332 Merge pull request #5365 from mbien/missing-record-enums
b24ef7791d1 is described below

commit b24ef7791d1b5ae6da464fbf272799e419d2078e
Author: Michael Bien 
AuthorDate: Mon Dec 5 20:45:25 2022 +0100

bulk added some missing record enums.
---
 .../semantic/MarkOccurrencesHighlighterBase.java   |  1 +
 .../editor/java/JavaCodeTemplateProcessor.java |  1 +
 .../org/netbeans/modules/java/hints/bugs/Tiny.java |  5 ++--
 .../java/hints/errors/CreateElementUtilities.java  |  4 
 .../modules/java/hints/errors/Utilities.java   |  1 +
 .../java/hints/introduce/InstanceRefFinder.java|  2 ++
 .../hints/suggestions/ExpectedTypeResolver.java|  2 +-
 .../modules/java/hints/suggestions/Lambda.java |  2 ++
 .../java/navigation/CaretListeningTask.java|  1 +
 .../modules/java/navigation/ElementNode.java   |  1 +
 .../org/netbeans/api/java/source/CodeStyle.java|  1 +
 .../api/java/source/DocTreePathHandle.java | 19 ---
 .../api/java/source/GeneratorUtilities.java|  2 +-
 .../netbeans/api/java/source/TreePathHandle.java   |  2 +-
 .../modules/java/source/indexing/CheckSums.java|  1 +
 .../modules/java/classfile/AttachSourcePanel.java  |  1 +
 .../java/plugins/RenameRefactoringPlugin.java  |  1 +
 .../refactoring/java/ui/MoveMembersPanel.java  |  1 +
 .../modules/refactoring/java/ui/UIUtilities.java   | 15 
 .../refactoring/java/ui/WhereUsedQueryUI.java  |  1 +
 .../modules/openide/util/NbBundleProcessor.java| 28 +-
 21 files changed, 46 insertions(+), 46 deletions(-)

diff --git 
a/java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
 
b/java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
index b4db6fb63ae..5685c18b86f 100644
--- 
a/java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
+++ 
b/java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
@@ -403,6 +403,7 @@ public abstract class MarkOccurrencesHighlighterBase 
extends JavaParserResultTas
 case CLASS:
 case ENUM:
 case INTERFACE:
+case RECORD:
 case TYPE_PARAMETER: //???
 return node.getBoolean(MarkOccurencesSettingsNames.TYPES, 
true);
 case CONSTRUCTOR:
diff --git 
a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
 
b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
index 8ea8627ead6..cbd7f39eff6 100644
--- 
a/java/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
+++ 
b/java/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
@@ -359,6 +359,7 @@ public class JavaCodeTemplateProcessor implements 
CodeTemplateProcessor {
 switch (usedElement.getKind()) {
 case CLASS:
 case INTERFACE:
+case RECORD:
 case ENUM:
 case ANNOTATION_TYPE:
 
toRemove.remove(((TypeElement)usedElement).getQualifiedName().toString());
diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java 
b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
index 149bf3cba75..c3544a5a9f9 100644
--- a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
+++ b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
@@ -39,7 +39,6 @@ import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
 import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
-import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -443,8 +442,8 @@ public class Tiny {
 } 
 // attempt to resolve a simple-qualified identifier; assuming 
the user already has an import in the source
 Element outer = el.getEnclosingElement();
-if (outer != null && (outer.getKind() == ElementKind.CLASS || 
outer.getKind() == ElementKind.INTERFACE ||
-outer.getKind() == ElementKind.ENUM)) {
+if (outer != null && (outer.getKind() == ElementKind.CLASS || 
outer.getKind() == El

[netbeans] branch master updated: Fix #5578 namespaces/use placement in FixUsesPerformer

2023-03-04 Thread junichi11
This is an automated email from the ASF dual-hosted git repository.

junichi11 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
 new fb0636966f Fix #5578 namespaces/use placement in FixUsesPerformer
 new d4944b7d76 Merge pull request #5579 from 
rossluk/php/fix-uses-performer-fix
fb0636966f is described below

commit fb0636966fd4ea4a545c829d3f58cabc8d07b43c
Author: Andrei Rosliuk 
AuthorDate: Tue Feb 28 13:21:01 2023 +0100

Fix #5578 namespaces/use placement in FixUsesPerformer
---
 .../php/editor/actions/FixUsesPerformer.java   | 221 -
 .../data/testfiles/actions/testGH5578/01/B.php |  23 +++
 .../actions/testGH5578/01/testGH5578_01.php|  36 
 .../testGH5578/01/testGH5578_01.php.fixUses|  38 
 .../data/testfiles/actions/testGH5578/02/B.php |  23 +++
 .../actions/testGH5578/02/testGH5578_02.php|  35 
 .../testGH5578/02/testGH5578_02.php.fixUses|  37 
 .../actions/testGH5578/03/testGH5578_03.php|  42 
 .../testGH5578/03/testGH5578_03.php.fixUses|  46 +
 .../actions/testGH5578/04/testGH5578_04.php|  43 
 .../testGH5578/04/testGH5578_04.php.fixUses|  46 +
 .../actions/testGH5578/05/testGH5578_05.php|  44 
 .../testGH5578/05/testGH5578_05.php.fixUses|  46 +
 .../actions/testGH5578/06/testGH5578_06.php|  49 +
 .../testGH5578/06/testGH5578_06.php.fixUses|  51 +
 .../actions/testGH5578/07/testGH5578_07.php|  49 +
 .../testGH5578/07/testGH5578_07.php.fixUses|  51 +
 .../data/testfiles/actions/testGH5578/08/B.php |  23 +++
 .../actions/testGH5578/08/testGH5578_08.php|  41 
 .../testGH5578/08/testGH5578_08.php.fixUses|  43 
 .../php/editor/actions/FixUsesPerformerTest.java   |  50 +
 21 files changed, 941 insertions(+), 96 deletions(-)

diff --git 
a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
 
b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
index 809ccbd85a..b0190da508 100644
--- 
a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
+++ 
b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
@@ -19,6 +19,7 @@
 package org.netbeans.modules.php.editor.actions;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -28,7 +29,6 @@ import java.util.Objects;
 import java.util.stream.Collectors;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.Document;
-import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.editor.document.LineDocumentUtils;
 import org.netbeans.api.lexer.TokenSequence;
 import org.netbeans.editor.BaseDocument;
@@ -46,10 +46,8 @@ import org.netbeans.modules.php.editor.indent.CodeStyle;
 import org.netbeans.modules.php.editor.lexer.LexUtilities;
 import org.netbeans.modules.php.editor.lexer.PHPTokenId;
 import org.netbeans.modules.php.editor.model.GroupUseScope;
-import org.netbeans.modules.php.editor.model.ModelElement;
 import org.netbeans.modules.php.editor.model.ModelUtils;
 import org.netbeans.modules.php.editor.model.NamespaceScope;
-import org.netbeans.modules.php.editor.model.Scope;
 import org.netbeans.modules.php.editor.model.UseScope;
 import org.netbeans.modules.php.editor.parser.PHPParseResult;
 import org.netbeans.modules.php.editor.parser.UnusedUsesCollector;
@@ -89,6 +87,7 @@ public class FixUsesPerformer {
 private final Options options;
 private EditList editList;
 private BaseDocument baseDocument;
+private NamespaceScope namespaceScope;
 
 public FixUsesPerformer(
 final PHPParseResult parserResult,
@@ -108,18 +107,16 @@ public class FixUsesPerformer {
 if (document instanceof BaseDocument) {
 baseDocument = (BaseDocument) document;
 editList = new EditList(baseDocument);
-processExistingUses();
-processSelections();
+namespaceScope = ModelUtils.getNamespaceScope(parserResult, 
importData.caretPosition);
+assert namespaceScope != null;
+processSelections(processExistingUses(importData.caretPosition));
 editList.apply();
 }
 }
 
 @NbBundle.Messages("FixUsesPerformer.noChanges=Fix imports: No Changes")
-private void processSelections() {
+private void processSelections(int startOffset) {
 final List dataItems = 
resolveDuplicateSelections();
-NamespaceScope namespaceScope = 
ModelUtils.getNamespaceScope(parserResult, importData.caretPosition);
-assert namespaceScope != null;
-int startOffset = getOffset(baseDocument, namespaceScope, 
parserResult, importData.caretPosition);