[hg] main-silver: #224783:Rename Package Causes Phantom Error

  • From: Tomas Zezula < >
  • To:
  • Subject: [hg] main-silver: #224783:Rename Package Causes Phantom Error
  • Date: Wed, 16 Jan 2013 12:50:19 -0800

changeset c84e5ddff7f9 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/c84e5ddff7f9
description:
        #224783:Rename Package Causes Phantom Error

diffstat:

 
parsing.api/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawler.java
               |  21 ++-
 
parsing.api/test/unit/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawlerTest.java
 |  81 ++++++++++
 2 files changed, 101 insertions(+), 1 deletions(-)

diffs (141 lines):

diff --git 
a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawler.java
 
b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawler.java
--- 
a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawler.java
+++ 
b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawler.java
@@ -125,18 +125,37 @@
                             final Map.Entry<FileObject, StringBuilder> 
relPath = it.next();
                             switch (getFileRelation(currentRelPath, 
relPath.getValue())) {
                                 case FIRST_IN_SECOND:
+                                    final Set<FileObject> cs = 
clusters.get(relPath.getKey());
+                                    for (FileObject csFile : cs) {
+                                        if (csFile.isFolder() && 
FileUtil.isParentOf(csFile, f)) {
                                     continue NEXT_FILE;
+                                        }
+                                    }
+                                    break;
                                 case SECOND_IN_FIRST:
+                                    if (f.equals(relPath.getKey()) || 
FileUtil.isParentOf(f, relPath.getKey())) {
                                     clusters.remove(relPath.getKey());
                                     it.remove();
+                                    }
+                                    break;
+                                case UNRELATED:
                                     break;
                                 case EQUAL:
+                                default:
                                     throw new IllegalStateException();
                             }
                         }
                         cluster = new HashSet<FileObject>();
                         clusters.put(parent, cluster);
                         relPaths.put(parent, currentRelPath);
+                    } else {
+                        for (Iterator<Map.Entry<FileObject,StringBuilder>> 
it = relPaths.entrySet().iterator(); it.hasNext();) {
+                            final Map.Entry<FileObject, StringBuilder> 
relPath = it.next();
+                            if (f.equals(relPath.getKey()) || 
FileUtil.isParentOf(f, relPath.getKey())) {
+                                clusters.remove(relPath.getKey());
+                                it.remove();
+                            }
+                        }
                     }
                     cluster.add(f);
                 }
@@ -374,7 +393,7 @@
             @NonNull final StringBuilder secondPath) {
         final int min = Math.min(firstPath.length(),secondPath.length());
         for (int i=0; i<min; i++) {
-            if (firstPath.charAt(i) != firstPath.charAt(i)) {
+            if (firstPath.charAt(i) != secondPath.charAt(i)) {
                 return PathRelation.UNRELATED;
             }
         }
diff --git 
a/parsing.api/test/unit/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawlerTest.java
 
b/parsing.api/test/unit/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawlerTest.java
--- 
a/parsing.api/test/unit/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawlerTest.java
+++ 
b/parsing.api/test/unit/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawlerTest.java
@@ -351,6 +351,87 @@
         assertCollectedFiles("Wrong files collected", 
crawler.getResources(), new String[] {"org/pckg1/pckg2/file1.txt"});
     }
 
+    public void testDuplicateResults4() throws IOException {
+        File root = new File(getWorkDir(), "src");
+        String [] paths = new String [] {
+                "org/bar/file1.txt",
+                "org/foo/file2.txt",
+        };
+
+        populateFolderStructure(root, paths);
+
+        FileObject rootFO = FileUtil.toFileObject(root);
+        FileObjectCrawler crawler = new FileObjectCrawler(rootFO, new 
FileObject[] {rootFO.getFileObject("org/foo/file2.txt"), 
rootFO.getFileObject("org/bar")}, 
EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, 
CR, SuspendSupport.NOP);
+        assertCollectedFiles("Wrong files collected", 
crawler.getResources(), new String[] 
{"org/bar/file1.txt","org/foo/file2.txt"});
+    }
+
+    public void testDuplicateResults5() throws IOException {
+        File root = new File(getWorkDir(), "src");
+        String [] paths = new String [] {
+                "org/bar/file1.txt",
+                "org/foo/file2.txt",
+        };
+
+        populateFolderStructure(root, paths);
+
+        FileObject rootFO = FileUtil.toFileObject(root);
+        FileObjectCrawler crawler = new FileObjectCrawler(rootFO, new 
FileObject[] {rootFO.getFileObject("org/bar"), 
rootFO.getFileObject("org/foo/file2.txt")}, 
EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, 
CR, SuspendSupport.NOP);
+        assertCollectedFiles("Wrong files collected", 
crawler.getResources(), new String[] 
{"org/bar/file1.txt","org/foo/file2.txt"});
+    }
+
+    public void testDuplicateResults6() throws IOException {
+        File root = new File(getWorkDir(), "src");
+        String [] paths = new String [] {
+                "org/me/prj/foo/file2.txt",
+                "org/me/prj/bar/file3.txt",
+        };
+
+        populateFolderStructure(root, paths);
+
+        FileObject rootFO = FileUtil.toFileObject(root);
+        FileObjectCrawler crawler = new FileObjectCrawler(rootFO, new 
FileObject[] {rootFO.getFileObject("org/me/prj/bar/file3.txt"), 
rootFO.getFileObject("org/me/prj/foo"), 
rootFO.getFileObject("org/me/prj/bar")}, 
EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, 
CR, SuspendSupport.NOP);
+        assertCollectedFiles("Wrong files collected", 
crawler.getResources(), new String[] 
{"org/me/prj/foo/file2.txt","org/me/prj/bar/file3.txt"});
+    }
+
+    public void testDuplicateResults7() throws IOException {
+        File root = new File(getWorkDir(), "src");
+        String [] paths = new String [] {
+                "org/me/prj/foo/file2.txt",
+                "org/me/prj/bar/file3.txt",
+        };
+
+        populateFolderStructure(root, paths);
+
+        FileObject rootFO = FileUtil.toFileObject(root);
+        FileObjectCrawler crawler = new FileObjectCrawler(rootFO, new 
FileObject[] {rootFO.getFileObject("org/me/prj/bar/file3.txt"), 
rootFO.getFileObject("org/me/prj/foo/file2.txt"), 
rootFO.getFileObject("org/me")}, 
EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, 
CR, SuspendSupport.NOP);
+        assertCollectedFiles("Wrong files collected", 
crawler.getResources(), new String[] 
{"org/me/prj/foo/file2.txt","org/me/prj/bar/file3.txt"});
+    }
+
+    public void testDuplicateResults8() throws IOException {
+        File root = new File(getWorkDir(), "src");
+        String [] paths = new String [] {
+                "org/me/lib/impl/file1.txt",
+                "org/me/prj/foo/file2.txt",
+                "org/me/prj/bar/file3.txt",
+        };
+
+        populateFolderStructure(root, paths);
+
+        FileObject rootFO = FileUtil.toFileObject(root);
+        FileObjectCrawler crawler = new FileObjectCrawler(
+                rootFO,
+                new FileObject[] {
+                    rootFO.getFileObject("org/me/prj/bar/file3.txt"),
+                    rootFO.getFileObject("org/me/prj/foo/file2.txt"),
+                    rootFO.getFileObject("org/me/lib"),
+                    rootFO.getFileObject("org/me/prj")},
+                
EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE),
+                null,
+                CR,
+                SuspendSupport.NOP);
+        assertCollectedFiles("Wrong files collected", 
crawler.getResources(), new String[] 
{"org/me/lib/impl/file1.txt","org/me/prj/foo/file2.txt","org/me/prj/bar/file3.txt"});
+    }
+
     protected void assertCollectedFiles(String message, 
Collection<Indexable> resources, String... expectedPaths) throws IOException {
         List<String> collectedPaths = new ArrayList<String>();
         for(Indexable ii : resources) {

[hg] main-silver: #224783:Rename Package Causes Phantom Error

Tomas Zezula 01/15/2013

<Possible follow-up(s)>

[hg] main-silver: #224783:Rename Package Causes Phantom Error

Tomas Zezula 01/16/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close