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 b6d57f2  Improve ImplementAbstractMethodsHintError
     new 30b1d7c  Merge pull request #3734 from 
junichi11/php-improve-implement-abstract-methods-hint-error
b6d57f2 is described below

commit b6d57f2e23815bfb415a68a9f9547d9948146af3
Author: Junichi Yamamoto <junich...@apache.org>
AuthorDate: Wed Mar 9 09:13:25 2022 +0900

    Improve ImplementAbstractMethodsHintError
    
    - Sort method elements to get the same result
---
 .../verification/ImplementAbstractMethodsHintError.java       | 11 ++++++++++-
 ...urnTypeImplementMethod01.php.testStaticReturnType_01.hints |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git 
a/php/php.editor/src/org/netbeans/modules/php/editor/verification/ImplementAbstractMethodsHintError.java
 
b/php/php.editor/src/org/netbeans/modules/php/editor/verification/ImplementAbstractMethodsHintError.java
index e9b3fc9..fbef93b 100644
--- 
a/php/php.editor/src/org/netbeans/modules/php/editor/verification/ImplementAbstractMethodsHintError.java
+++ 
b/php/php.editor/src/org/netbeans/modules/php/editor/verification/ImplementAbstractMethodsHintError.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
 import java.util.logging.Level;
@@ -148,7 +149,15 @@ public class ImplementAbstractMethodsHintError extends 
HintErrorRule {
                 
allValidMethods.addAll(toNames(getValidInheritedMethods(getInheritedMethods(classScope,
 index))));
                 
allValidMethods.addAll(toNames(index.getDeclaredMethods(classScope)));
                 ElementFilter declaredMethods = 
ElementFilter.forExcludedNames(allValidMethods, PhpElementKind.METHOD);
-                Set<MethodElement> accessibleMethods = 
declaredMethods.filter(index.getAccessibleMethods(classScope, classScope));
+                List<MethodElement> accessibleMethods = new 
ArrayList<>(declaredMethods.filter(index.getAccessibleMethods(classScope, 
classScope)));
+                // sort to get the same result
+                accessibleMethods.sort((MethodElement m1, MethodElement m2) -> 
{
+                    int result = 
m1.getFilenameUrl().compareTo(m2.getFilenameUrl());
+                    if (result == 0) {
+                        return Integer.compare(m1.getOffset(), m2.getOffset());
+                    }
+                    return result;
+                });
                 Set<String> methodSkeletons = new LinkedHashSet<>();
                 MethodElement lastMethodElement = null;
                 FileObject lastFileObject = null;
diff --git 
a/php/php.editor/test/unit/data/testfiles/verification/ImplementAbstractMethodsHintError/testStaticReturnTypeImplementMethod01.php.testStaticReturnType_01.hints
 
b/php/php.editor/test/unit/data/testfiles/verification/ImplementAbstractMethodsHintError/testStaticReturnTypeImplementMethod01.php.testStaticReturnType_01.hints
index 70580a1..0209abc 100644
--- 
a/php/php.editor/test/unit/data/testfiles/verification/ImplementAbstractMethodsHintError/testStaticReturnTypeImplementMethod01.php.testStaticReturnType_01.hints
+++ 
b/php/php.editor/test/unit/data/testfiles/verification/ImplementAbstractMethodsHintError/testStaticReturnTypeImplementMethod01.php.testStaticReturnType_01.hints
@@ -1,5 +1,5 @@
 class TestClass implements TestInterface {
       ---------
-HINT:\TestClass is not abstract and does not override abstract method  
testSimple() in \TestInterface
+HINT:\TestClass is not abstract and does not override abstract method  
testUnionType() in \TestInterface
 FIX:Implement All Abstract Methods
 FIX:Declare Abstract Class

---------------------------------------------------------------------
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

Reply via email to