[netbeans] branch master updated: `SourceUtils.findMatchingChild` should never return a folder
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 5d45c28aac `SourceUtils.findMatchingChild` should never return a folder new aae13e97d6 Merge pull request #5739 from jglick/SourceUtils.findMatchingChild 5d45c28aac is described below commit 5d45c28aac066f568bcbb1dc5e0e800c47f9e601 Author: Jesse Glick AuthorDate: Wed Mar 29 11:30:34 2023 -0400 `SourceUtils.findMatchingChild` should never return a folder --- .../src/org/netbeans/api/java/source/SourceUtils.java| 12 .../src/org/netbeans/api/java/source/SourceUtilsTest.java| 9 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/java/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java b/java/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java index e58a6a257c..dfb02790c6 100644 --- a/java/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java +++ b/java/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java @@ -628,7 +628,9 @@ public class SourceUtils { private static FileObject findMatchingChild(String sourceFileName, Collection folders, boolean caseSensitive) { final Match matchSet = caseSensitive ? new CaseSensitiveMatch(sourceFileName) : new CaseInsensitiveMatch(sourceFileName); for (FileObject folder : folders) { -for (FileObject child : folder.getChildren()) { +FileObject[] children = folder.getChildren(); +Arrays.sort(children, Comparator.comparing(FileObject::getNameExt)); // for determinism +for (FileObject child : children) { if (matchSet.apply(child)) { return child; } @@ -684,6 +686,9 @@ public class SourceUtils { } final boolean apply(final FileObject fo) { +if (fo.isFolder()) { +return false; +} if (fo.getNameExt().equals(name)) { return true; } @@ -1127,9 +1132,8 @@ public class SourceUtils { } /** - * Returns candidate filenames given a classname. The return value is either - * a String (top-level class, no $) or Listas the JLS permits $ in - * class names. + * Returns candidate filenames given a classname. + * @return a single name (top-level class, no $) or multiple as the JLS permits $ in class names. */ private static List getSourceFileNames(String classFileName) { int index = classFileName.lastIndexOf('$'); diff --git a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTest.java b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTest.java index 0a12ba30d8..90da3063a1 100644 --- a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTest.java +++ b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTest.java @@ -321,6 +321,7 @@ public class SourceUtilsTest extends ClassIndexTestCase { FileObject srcInDefPkg = src.createData("Foo","java"); assertNotNull(srcInDefPkg); FileObject sourceFile = src.createFolder("org").createFolder("me").createData("Test", "java"); +src.getFileObject("org/me").createFolder("Test"); // https://github.com/apache/netbeans/issues/5738 assertNotNull(sourceFile); ClasspathInfo cpInfo = ClasspathInfo.create(ClassPathSupport.createClassPath(new FileObject[0]), ClassPathSupport.createClassPath(new FileObject[0]), ClassPathSupport.createClassPath(new FileObject[]{src})); @@ -337,16 +338,16 @@ public class SourceUtilsTest extends ClassIndexTestCase { ElementHandle handle = ElementHandle.createTypeElementHandle(ElementKind.CLASS, "org.me.Test"); assertNotNull (handle); FileObject result = SourceUtils.getFile(handle, cpInfo); -assertNotNull(result); +assertEquals(sourceFile, result); handle = ElementHandle.createTypeElementHandle(ElementKind.CLASS, "org.me.Test$Inner"); result = SourceUtils.getFile(handle,cpInfo); -assertNotNull(result); +assertEquals(sourceFile, result); handle = ElementHandle.createPackageElementHandle("org.me"); result = SourceUtils.getFile(handle,cpInfo); -assertNotNull(result); +assertEquals(sourceFile.getParent(), result); handle = ElementHandle.createTypeElementHandle(ElementKind.CLASS, "Foo"); result = SourceUtils.getFile(handle,cpInfo); -assertNotNull(result); +assertEquals(srcInDefPkg, result); } public void testGetMainClasses() throws Exception { - To unsubscribe, e-mail: commits-unsubscr...@net
[jira] [Comment Edited] (NETBEANS-1538) NetBeans installer Not locating Java properly
[ https://issues.apache.org/jira/browse/NETBEANS-1538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17709774#comment-17709774 ] Joey Barnes edited comment on NETBEANS-1538 at 4/8/23 7:11 PM: --- h2. Great article and here is a round up: [*Free Premium OnlyFans Accounts*|https://freeonlyfansaccounts.z21.web.core.windows.net/] [*Free V-Bucks Codes for Fortnite*|https://freevbucks.z19.web.core.windows.net/home.html] [*hp laserjet pro mfp m29w manual*|https://123hpcomprintscan.com/hp-laserjet-pro-setup/] [*Doggo Lifestyle*|https://doggolifestyle.com/] [*Best stud finder app*|https://studfinder.z13.web.core.windows.net/] _+[Free V-Bucks| https://freevbucks.pagesperso-orange.fr/]+_ was (Author: JIRAUSER289124): h2. Great article and here is a round up: [*Free Premium OnlyFans Accounts*|https://freeonlyfansaccounts.z21.web.core.windows.net/] [*Free V-Bucks Codes for Fortnite*|https://freevbucks.z19.web.core.windows.net/home.html] [*hp laserjet pro mfp m29w manual*|https://123hpcomprintscan.com/hp-laserjet-pro-setup/] [*Doggo Lifestyle*|https://doggolifestyle.com/] [*Best stud finder app*|https://studfinder.z13.web.core.windows.net/] > NetBeans installer Not locating Java properly > - > > Key: NETBEANS-1538 > URL: https://issues.apache.org/jira/browse/NETBEANS-1538 > Project: NetBeans > Issue Type: Bug >Reporter: martha >Priority: Trivial > Fix For: 10.0 > > Attachments: pas.pdf > > > I'm trying to install the NetBeans "all" package, and, I'm pretty sure I > already have Java SE Development Kit installed, however, it's not locating it > properly, it comes with an error. > {{Java SE Development Kit (JDK) was not found on this > computer[!https://issues.apache.org/jira/images/icons/emoticons/sad.png!|https://www.essayhave.com/essay-writing-service.html]}} > So I ran the CMD and typed: > {{netbeans-7.1.3-windows.exe --javahome "C:\Program Files\Java\jdk1.7.0_25"}} > As I checked, I was in the right directory (E:\Mark\Downloads) where the > setup file of netbeans is supposed to be. After pressing ENTER, it did locate > JDK, however it would not locate JRE and came up with this error. > {{Java Runtime Environment (JRE) was not found There is no JRE at the > specified location C:\Program Files\Java\jdk1.7.0_25}} > So I tried installing the JDK+NetBeans Bundle by Oracle [x86 (32-bit) for > Windows (I'm running a 32-bit Windows XP SP3 so it should have worked)] but > it says that it's not compatible with my current platform. I also tried > --jdkhome but it didn't seem to work at all. Please, this has been going on > for two days. -- This message was sent by Atlassian Jira (v8.20.10#820010) - 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
[jira] [Comment Edited] (NETBEANS-1538) NetBeans installer Not locating Java properly
[ https://issues.apache.org/jira/browse/NETBEANS-1538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17709774#comment-17709774 ] Joey Barnes edited comment on NETBEANS-1538 at 4/8/23 8:41 PM: --- h2. Great article and here is a round up: [*Free Premium OnlyFans Accounts*|https://freeonlyfansaccounts.z21.web.core.windows.net/] [*Free V-Bucks Codes for Fortnite*|https://freevbucks.z19.web.core.windows.net/home.html] [*hp laserjet pro mfp m29w manual*|https://123hpcomprintscan.com/hp-laserjet-pro-setup/] [*Doggo Lifestyle*|https://doggolifestyle.com/] [small sandblaster| https://sandblaster.z13.web.core.windows.net/] [*Best stud finder app*|https://studfinder.z13.web.core.windows.net/] _+[Free V-Bucks| https://freevbucks.pagesperso-orange.fr/]+_ was (Author: JIRAUSER289124): h2. Great article and here is a round up: [*Free Premium OnlyFans Accounts*|https://freeonlyfansaccounts.z21.web.core.windows.net/] [*Free V-Bucks Codes for Fortnite*|https://freevbucks.z19.web.core.windows.net/home.html] [*hp laserjet pro mfp m29w manual*|https://123hpcomprintscan.com/hp-laserjet-pro-setup/] [*Doggo Lifestyle*|https://doggolifestyle.com/] [*Best stud finder app*|https://studfinder.z13.web.core.windows.net/] _+[Free V-Bucks| https://freevbucks.pagesperso-orange.fr/]+_ > NetBeans installer Not locating Java properly > - > > Key: NETBEANS-1538 > URL: https://issues.apache.org/jira/browse/NETBEANS-1538 > Project: NetBeans > Issue Type: Bug >Reporter: martha >Priority: Trivial > Fix For: 10.0 > > Attachments: pas.pdf > > > I'm trying to install the NetBeans "all" package, and, I'm pretty sure I > already have Java SE Development Kit installed, however, it's not locating it > properly, it comes with an error. > {{Java SE Development Kit (JDK) was not found on this > computer[!https://issues.apache.org/jira/images/icons/emoticons/sad.png!|https://www.essayhave.com/essay-writing-service.html]}} > So I ran the CMD and typed: > {{netbeans-7.1.3-windows.exe --javahome "C:\Program Files\Java\jdk1.7.0_25"}} > As I checked, I was in the right directory (E:\Mark\Downloads) where the > setup file of netbeans is supposed to be. After pressing ENTER, it did locate > JDK, however it would not locate JRE and came up with this error. > {{Java Runtime Environment (JRE) was not found There is no JRE at the > specified location C:\Program Files\Java\jdk1.7.0_25}} > So I tried installing the JDK+NetBeans Bundle by Oracle [x86 (32-bit) for > Windows (I'm running a 32-bit Windows XP SP3 so it should have worked)] but > it says that it's not compatible with my current platform. I also tried > --jdkhome but it didn't seem to work at all. Please, this has been going on > for two days. -- This message was sent by Atlassian Jira (v8.20.10#820010) - 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: Fix the problem that "Fix Imports" don't work when there are types that have the same suffix #5330
This is an automated email from the ASF dual-hosted git repository. tmysik 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 2a0a61f05c Fix the problem that "Fix Imports" don't work when there are types that have the same suffix #5330 new 2dcd67ce60 Merge pull request #5801 from junichi11/php-gh-5330-fix-imports 2a0a61f05c is described below commit 2a0a61f05c930ce9d566d6b1e62145ed0f095caf Author: Junichi Yamamoto AuthorDate: Sat Apr 8 02:51:38 2023 +0900 Fix the problem that "Fix Imports" don't work when there are types that have the same suffix #5330 - https://github.com/apache/netbeans/issues/5330 Example: ```php namespace Test\SameName; class SameNamePart{}; class OtherSameNamePart{}; namespace Test; use Test\SameName\OtherSameNamePart; class Example { public function __construct( private OtherSameNamePart $otherSameName, private SameNamePart $sameName, ) {} } ``` Before: `use Test\SameName\SameNamePart;` is **not** inserted After: `use Test\SameName\SameNamePart;` is inserted --- .../php/editor/actions/UsedNamesCollector.java | 7 - .../actions/testGH5330/01/testGH5330_01.php| 35 + .../testGH5330/01/testGH5330_01.php.fixUses| 36 ++ .../testfiles/actions/testGH5330/testGH5330_01.php | 35 + .../testGH5330/testGH5330_01.php.importData| 12 .../php/editor/actions/FixUsesPerformerTest.java | 7 + .../php/editor/actions/ImportDataCreatorTest.java | 4 +++ 7 files changed, 135 insertions(+), 1 deletion(-) diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/actions/UsedNamesCollector.java b/php/php.editor/src/org/netbeans/modules/php/editor/actions/UsedNamesCollector.java index b0a609cb6e..82c23fd84c 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/actions/UsedNamesCollector.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/actions/UsedNamesCollector.java @@ -95,7 +95,12 @@ public class UsedNamesCollector { break; } } else { -if (useElement.getName().endsWith(firstSegmentName)) { +// GH-5330 +// do not check the end string of the declared name +// check whether segment is the same name +// e.g. OtherSameNamePart and SameNamePart are end with "SameNamePart" +QualifiedName declaredName = QualifiedName.create(useElement.getName()); +if (declaredName.getSegments().getLast().equals(firstSegmentName)) { result = true; break; } diff --git a/php/php.editor/test/unit/data/testfiles/actions/testGH5330/01/testGH5330_01.php b/php/php.editor/test/unit/data/testfiles/actions/testGH5330/01/testGH5330_01.php new file mode 100644 index 00..4550476162 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/actions/testGH5330/01/testGH5330_01.php @@ -0,0 +1,35 @@ +http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +namespace Test\SameName; + +class SameNamePart{}; +class OtherSameNamePart{}; + +namespace Test; + +use Test\SameName\OtherSameNamePart; + +class Example { +public function __construct( +private OtherSameNamePart $otherSameName, +private SameNamePart $sameName, +) { +} +} diff --git a/php/php.editor/test/unit/data/testfiles/actions/testGH5330/01/testGH5330_01.php.fixUses b/php/php.editor/test/unit/data/testfiles/actions/testGH5330/01/testGH5330_01.php.fixUses new file mode 100644 index 00..f8f405045b --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/actions/testGH5330/01/testGH5330_01.php.fixUses @@ -0,0 +1,36 @@ +http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +namespace Test\SameName; + +class SameNamePart{}; +class OtherSameNamePart{}; + +namespace Test; + +use Test\SameName\OtherSameNamePart; +use Test\SameName\SameNamePart; + +class Example { +public function __construct( +private OtherSameNamePart $otherSameName, +