Issue #5 new

using "strange" rule, funny results and exceptions

Ernie Rael
created an issue

While experimenting, in FindPatternOccurances I tried the pattern $method($1$) :: matchesAny($method,"java.lang.Math.min") ;; on a small test file. It found TWO matches, but Math.min was only used in one. It found both functions in the test file see below. I wasn't sure this would work, but I wasn't expecting this.

Excerpt from test file int min = Math.min(j, k);

    ....

        foo(j);

I tried it again, but forget to select "Scope: selected folder". After several seconds I got the exception below. The FindPat dialog displayed a warning, so I could proceed. I proceeded and saw 3385 occurences in the various jackpot modules, (jackpot was open in addition to my one little test project). Ran it again and there was 1603, then 6621.

==== example found 3385 java.lang.IndexOutOfBoundsException: Illegal OffsetKind[offset=-1] in org.netbeans.modules.editor.NbEditorDocument@86ff0, mimeType = 'text/x-java', kitClass = null, length = 637, file=org.netbeans.modules.java.JavaDataObject@2f1622[MasterFileObject[C:\Documents and Settings\erra\My Documents\NetBeansProjects\JavaApplication2\src\javaapplication2\Main.java@5d174f:bbd83d,valid=true]] used by org.netbeans.modules.java.JavaDataObject$JavaEditorSupport@10d1e0b. at org.openide.text.PositionRef$Manager$OffsetKind.<init>(PositionRef.java:657) at org.openide.text.PositionRef.<init>(PositionRef.java:84) at org.openide.text.CloneableEditorSupport.createPositionRef(CloneableEditorSupport.java:1527) at org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringPlugin.createRefactoringElementImplementation(FindDuplicatesRefactoringPlugin.java:195) at org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringPlugin.performSearchForPattern(FindDuplicatesRefactoringPlugin.java:146) at org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringPlugin.prepare(FindDuplicatesRefactoringPlugin.java:110) at org.netbeans.modules.refactoring.api.AbstractRefactoring.pluginsPrepare2(AbstractRefactoring.java:419) at org.netbeans.modules.refactoring.api.AbstractRefactoring.pluginsPrepare(AbstractRefactoring.java:403) at org.netbeans.modules.refactoring.api.AbstractRefactoring.prepare(AbstractRefactoring.java:214) at org.netbeans.modules.refactoring.spi.impl.ParametersPanel$Prepare.run(ParametersPanel.java:804) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1369) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1907)

==== another example found 6621 java.lang.IndexOutOfBoundsException: Illegal OffsetKind[offset=-1] in org.netbeans.modules.editor.NbEditorDocument@1fa269b, mimeType = 'text/x-java', kitClass = null, length = 41218, file=org.netbeans.modules.java.JavaDataObject@1154718[MasterFileObject[C:\a\src_reference\jackpot30\api\src\org\netbeans\modules\jackpot30\impl\Utilities.java@1136019:cff49f,valid=true]] used by org.netbeans.modules.java.JavaDataObject$JavaEditorSupport@13ef605. at org.openide.text.PositionRef$Manager$OffsetKind.<init>(PositionRef.java:657) at org.openide.text.PositionRef.<init>(PositionRef.java:84) at org.openide.text.CloneableEditorSupport.createPositionRef(CloneableEditorSupport.java:1527) at org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringPlugin.createRefactoringElementImplementation(FindDuplicatesRefactoringPlugin.java:195) at org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringPlugin.performSearchForPattern(FindDuplicatesRefactoringPlugin.java:146) at org.netbeans.modules.jackpot30.impl.refactoring.FindDuplicatesRefactoringPlugin.prepare(FindDuplicatesRefactoringPlugin.java:110) at org.netbeans.modules.refactoring.api.AbstractRefactoring.pluginsPrepare2(AbstractRefactoring.java:419) at org.netbeans.modules.refactoring.api.AbstractRefactoring.pluginsPrepare(AbstractRefactoring.java:403) at org.netbeans.modules.refactoring.api.AbstractRefactoring.prepare(AbstractRefactoring.java:214) at org.netbeans.modules.refactoring.spi.impl.ParametersPanel$Prepare.run(ParametersPanel.java:804) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1369) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1907)

changeset: 345:c9e249e49247 tag: qparent user: Jan Lahoda jlahoda@netbeans.org date: Thu Mar 25 23:03:04 2010 +0100 summary: Making the refactoring bridge eager.

Comments (1)

  1. Ernie Rael reporter

    (guess I should look at the preview window..., the stacktraces look readable, but let me know)

    (and I just noticed you can edit, a new system to learn...)

    While experimenting, in FindPatternOccurances I tried the pattern

        $method($1$) :: matchesAny($method,"java.lang.Math.min")
        ;;
    

    on a small test file. It found TWO matches, but Math.min was only used in one. It found both functions in the test file see below. I wasn't sure this would work, but I wasn't expecting this.

    Excerpt from test file

            int min = Math.min(j, k);
    
            ....
    
                foo(j);
    
  2. Log in to comment