Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Piskarev2017-08-21 16:38:37 +0000
committerVladimir Piskarev2017-08-21 16:38:37 +0000
commitedf63c7f8cb7808fc7601335673703ed1415b717 (patch)
tree9c85c0fb6343f4c7d0446f4dbd65ce6d58a2b0b7
parentee3cb2c7271331d301f42912aa99fcd11cd59dd7 (diff)
downloadorg.eclipse.handly-edf63c7f8cb7808fc7601335673703ed1415b717.tar.gz
org.eclipse.handly-edf63c7f8cb7808fc7601335673703ed1415b717.tar.xz
org.eclipse.handly-edf63c7f8cb7808fc7601335673703ed1415b717.zip
Bug 520897 - Revise F_FINE_GRAINED usage
https://bugs.eclipse.org/bugs/show_bug.cgi?id=520897#c5
-rw-r--r--org.eclipse.handly.examples.basic.ui.tests/src/org/eclipse/handly/internal/examples/basic/ui/model/FooWorkingCopyNotificationTest.java19
-rw-r--r--org.eclipse.handly.examples.javamodel.tests/src/org/eclipse/handly/internal/examples/javamodel/WorkingCopyNotificationTest.java13
-rw-r--r--org.eclipse.handly/src/org/eclipse/handly/model/impl/SourceElementBody.java19
3 files changed, 37 insertions, 14 deletions
diff --git a/org.eclipse.handly.examples.basic.ui.tests/src/org/eclipse/handly/internal/examples/basic/ui/model/FooWorkingCopyNotificationTest.java b/org.eclipse.handly.examples.basic.ui.tests/src/org/eclipse/handly/internal/examples/basic/ui/model/FooWorkingCopyNotificationTest.java
index 25f66768..c087826b 100644
--- a/org.eclipse.handly.examples.basic.ui.tests/src/org/eclipse/handly/internal/examples/basic/ui/model/FooWorkingCopyNotificationTest.java
+++ b/org.eclipse.handly.examples.basic.ui.tests/src/org/eclipse/handly/internal/examples/basic/ui/model/FooWorkingCopyNotificationTest.java
@@ -117,9 +117,9 @@ public class FooWorkingCopyNotificationTest
assertFalse(def.exists());
- assertDelta(newDeltaBuilder(workingCopy).added(
- workingCopy.getDef("g", 0)).removed(def).getDelta(),
- listener.delta);
+ assertDelta(newDeltaBuilder(workingCopy).changed(workingCopy,
+ F_CONTENT | F_FINE_GRAINED).added(workingCopy.getDef("g",
+ 0)).removed(def).getDelta(), listener.delta);
}
});
}
@@ -157,8 +157,9 @@ public class FooWorkingCopyNotificationTest
workingCopy.reconcile(null);
- assertDelta(newDeltaBuilder(workingCopy).removed(
- varY).getDelta(), listener.delta);
+ assertDelta(newDeltaBuilder(workingCopy).changed(workingCopy,
+ F_CONTENT | F_FINE_GRAINED).removed(varY).getDelta(),
+ listener.delta);
listener.delta = null;
@@ -177,7 +178,8 @@ public class FooWorkingCopyNotificationTest
workingCopy.reconcile(null);
- assertDelta(newDeltaBuilder(workingCopy).added(varY).getDelta(),
+ assertDelta(newDeltaBuilder(workingCopy).changed(workingCopy,
+ F_CONTENT | F_FINE_GRAINED).added(varY).getDelta(),
listener.delta);
}
});
@@ -212,8 +214,9 @@ public class FooWorkingCopyNotificationTest
workingCopy.reconcile(null);
- assertDelta(newDeltaBuilder(workingCopy).changed(def, F_CONTENT
- | F_FINE_GRAINED).getDelta(), listener.delta); // 'parameterNames' property changed
+ assertDelta(newDeltaBuilder(workingCopy).changed(workingCopy,
+ F_CONTENT | F_FINE_GRAINED).changed(def, F_CONTENT
+ | F_FINE_GRAINED).getDelta(), listener.delta); // 'parameterNames' property changed
}
});
}
diff --git a/org.eclipse.handly.examples.javamodel.tests/src/org/eclipse/handly/internal/examples/javamodel/WorkingCopyNotificationTest.java b/org.eclipse.handly.examples.javamodel.tests/src/org/eclipse/handly/internal/examples/javamodel/WorkingCopyNotificationTest.java
index 83f06c11..2fa0eff8 100644
--- a/org.eclipse.handly.examples.javamodel.tests/src/org/eclipse/handly/internal/examples/javamodel/WorkingCopyNotificationTest.java
+++ b/org.eclipse.handly.examples.javamodel.tests/src/org/eclipse/handly/internal/examples/javamodel/WorkingCopyNotificationTest.java
@@ -123,7 +123,7 @@ public class WorkingCopyNotificationTest
//@formatter:off
listener.assertDelta(
- "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" +
+ "[Working copy] X.java[*]: {CHILDREN | CONTENT | FINE GRAINED}\n" +
" Y[+]: {}\n" +
" X[-]: {}"
);
@@ -156,7 +156,7 @@ public class WorkingCopyNotificationTest
//@formatter:off
listener.assertDelta(
- "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" +
+ "[Working copy] X.java[*]: {CHILDREN | CONTENT | FINE GRAINED}\n" +
" X[*]: {CHILDREN | FINE GRAINED}\n" +
" x[-]: {}"
);
@@ -178,7 +178,7 @@ public class WorkingCopyNotificationTest
//@formatter:off
listener.assertDelta(
- "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" +
+ "[Working copy] X.java[*]: {CHILDREN | CONTENT | FINE GRAINED}\n" +
" X[*]: {CHILDREN | FINE GRAINED}\n" +
" y[+]: {}"
);
@@ -212,7 +212,7 @@ public class WorkingCopyNotificationTest
//@formatter:off
listener.assertDelta(
- "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" +
+ "[Working copy] X.java[*]: {CHILDREN | CONTENT | FINE GRAINED}\n" +
" X[*]: {CHILDREN | FINE GRAINED}\n" +
" f()[+]: {}\n" +
" f(int)[-]: {}"
@@ -247,7 +247,7 @@ public class WorkingCopyNotificationTest
//@formatter:off
listener.assertDelta(
- "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" +
+ "[Working copy] X.java[*]: {CHILDREN | CONTENT | FINE GRAINED}\n" +
" X[*]: {CHILDREN | FINE GRAINED}\n" +
" f(int)[*]: {CONTENT | FINE GRAINED}"
);
@@ -275,7 +275,8 @@ public class WorkingCopyNotificationTest
workingCopy.reconcile(ICompilationUnit.NO_AST, 0, monitor);
- assertNull(listener.delta); // only changes to the structure of the working copy are reported
+ listener.assertDelta(
+ "[Working copy] X.java[*]: {CONTENT | FINE GRAINED}");
}
});
}
diff --git a/org.eclipse.handly/src/org/eclipse/handly/model/impl/SourceElementBody.java b/org.eclipse.handly/src/org/eclipse/handly/model/impl/SourceElementBody.java
index ca43b751..031844b0 100644
--- a/org.eclipse.handly/src/org/eclipse/handly/model/impl/SourceElementBody.java
+++ b/org.eclipse.handly/src/org/eclipse/handly/model/impl/SourceElementBody.java
@@ -16,11 +16,13 @@ import static org.eclipse.handly.model.IElementDeltaConstants.F_FINE_GRAINED;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import org.eclipse.handly.model.IElement;
import org.eclipse.handly.model.ISourceConstruct;
import org.eclipse.handly.model.ISourceElementInfo;
+import org.eclipse.handly.model.ISourceFile;
import org.eclipse.handly.snapshot.ISnapshot;
import org.eclipse.handly.util.Property;
import org.eclipse.handly.util.TextRange;
@@ -142,6 +144,23 @@ public class SourceElementBody
public void findContentChange(Body oldBody, IElement element,
IElementDeltaBuilder builder)
{
+ if (element instanceof ISourceFile)
+ {
+ if (!Objects.equals(getFullRange(),
+ ((SourceElementBody)oldBody).getFullRange()))
+ {
+ builder.changed(element, F_CONTENT | F_FINE_GRAINED);
+ return;
+ }
+ ISnapshot snapshot = getSnapshot();
+ ISnapshot oldSnapshot = ((SourceElementBody)oldBody).getSnapshot();
+ if (!((snapshot == oldSnapshot) || (snapshot != null
+ && snapshot.isEqualTo(oldSnapshot))))
+ {
+ builder.changed(element, F_CONTENT | F_FINE_GRAINED);
+ return;
+ }
+ }
Set<String> newPropertyNames = getPropertyNames();
Set<String> oldPropertyNames =
((SourceElementBody)oldBody).getPropertyNames();

Back to the top