Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Chandra2017-02-06 14:14:12 +0000
committerVikas Chandra2017-02-10 10:25:27 +0000
commit2dafb800547def8b57ef81a7939941eb9c991428 (patch)
treead8b390c26e9a5a3e6b6f13e655cc7017df882e3
parent1af838b47303289f786d1f8dcece99dd0b0ef552 (diff)
downloadeclipse.pde.ui-2dafb800547def8b57ef81a7939941eb9c991428.tar.gz
eclipse.pde.ui-2dafb800547def8b57ef81a7939941eb9c991428.tar.xz
eclipse.pde.ui-2dafb800547def8b57ef81a7939941eb9c991428.zip
Bug 508720 - Error marker at wrong place for default method addition I20170212-2000I20170211-2000I20170210-2000I20170210-0615I20170210-0600
Change-Id: Ic97e70188cf783ff1291aae2c728ca42af371b09 Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/InterfaceDeltaTests.java4
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java33
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java1
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/DeltaProcessor.java1
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/IDelta.java13
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java3
6 files changed, 44 insertions, 11 deletions
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/InterfaceDeltaTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/InterfaceDeltaTests.java
index 882e0408bf..2510b10186 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/InterfaceDeltaTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/InterfaceDeltaTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2016 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -782,7 +782,7 @@ public class InterfaceDeltaTests extends DeltaTestSetup {
assertTrue("Is compatible", DeltaProcessor.isCompatible(child)); //$NON-NLS-1$
child = allLeavesDeltas[1];
assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); //$NON-NLS-1$
- assertEquals("Wrong flag", IDelta.DEFAULT_METHOD, child.getFlags()); //$NON-NLS-1$
+ assertEquals("Wrong flag", IDelta.SUPER_INTERFACE_DEFAULT_METHOD, child.getFlags()); //$NON-NLS-1$
assertEquals("Wrong element type", IDelta.INTERFACE_ELEMENT_TYPE, child.getElementType()); //$NON-NLS-1$
assertFalse("Not compatible", DeltaProcessor.isCompatible(child)); //$NON-NLS-1$
child = allLeavesDeltas[2];
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
index 4790310a7f..0196cc1c6a 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -289,19 +289,32 @@ public class ClassFileComparator {
// we should check if every method defined in the
// new interface exists in the old hierarchy
// could be methods moved up in the hierarchy
- methodLoop: for (int j = 0; j < length; j++) {
+ boolean isSuperInterfaceWithMethodDeltaAdded = false;
+ for (int j = 0; j < length; j++) {
IApiMethod method = methods[j];
IApiMethod method3 = this.type1.getMethod(method.getName(), method.getSignature());
if (method3 == null) {
+ String key = this.type1.getName();
boolean isDefaultMethod = false;
if (this.type2.getMethod(method.getName(), method.getSignature()) != null) {
isDefaultMethod = this.type2.getMethod(method.getName(), method.getSignature()).isDefaultMethod();
+ if(isDefaultMethod) {
+ key = getKeyForMethod(this.type2.getMethod(method.getName(), method.getSignature()), this.type2);
+ }
+ }
+ if (!isDefaultMethod && isSuperInterfaceWithMethodDeltaAdded == false) {
+ this.addDelta(getElementType(this.type1), IDelta.ADDED, IDelta.SUPER_INTERFACE_WITH_METHODS, this.currentDescriptorRestrictions, this.initialDescriptorRestrictions, this.type1.getModifiers(), this.type2.getModifiers(), this.type1, key, new String[] {
+ Util.getDescriptorName(type1),
+ type.getName(),
+ getMethodDisplayName(method, type) });
+ isSuperInterfaceWithMethodDeltaAdded = true;
+ }
+ if (isDefaultMethod) {
+ this.addDelta(getElementType(this.type1), IDelta.ADDED, IDelta.SUPER_INTERFACE_DEFAULT_METHOD, this.currentDescriptorRestrictions, this.initialDescriptorRestrictions, this.type1.getModifiers(), this.type2.getModifiers(), this.type1, key, new String[] {
+ Util.getDescriptorName(type1),
+ type.getName(),
+ getMethodDisplayName(method, type) });
}
- this.addDelta(getElementType(this.type1), IDelta.ADDED, isDefaultMethod ? IDelta.DEFAULT_METHOD : IDelta.SUPER_INTERFACE_WITH_METHODS, this.currentDescriptorRestrictions, this.initialDescriptorRestrictions, this.type1.getModifiers(), this.type2.getModifiers(), this.type1, this.type1.getName(), new String[] {
- Util.getDescriptorName(type1),
- type.getName(),
- getMethodDisplayName(method, type) });
- break methodLoop;
}
}
}
@@ -360,11 +373,15 @@ public class ClassFileComparator {
}
}
if (!found) {
+ String key = this.type1.getName();
boolean isDefaultMethod = false;
if(this.type2.getMethod(method.getName(), method.getSignature())!=null) {
isDefaultMethod = this.type2.getMethod(method.getName(), method.getSignature()).isDefaultMethod();
+ if (isDefaultMethod) {
+ key = getKeyForMethod(this.type2.getMethod(method.getName(), method.getSignature()), this.type2);
+ }
}
- this.addDelta(getElementType(this.type1), IDelta.ADDED, isDefaultMethod ? IDelta.DEFAULT_METHOD : IDelta.SUPER_INTERFACE_WITH_METHODS, this.currentDescriptorRestrictions, this.initialDescriptorRestrictions, this.type1.getModifiers(), this.type2.getModifiers(), this.type1, this.type1.getName(), new String[] {
+ this.addDelta(getElementType(this.type1), IDelta.ADDED, isDefaultMethod ? IDelta.DEFAULT_METHOD : IDelta.SUPER_INTERFACE_WITH_METHODS, this.currentDescriptorRestrictions, this.initialDescriptorRestrictions, this.type1.getModifiers(), this.type2.getModifiers(), this.type1, key, new String[] {
Util.getDescriptorName(type1),
type.getName(),
getMethodDisplayName(method, type) });
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
index f2a1789b47..3c53c2a14e 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
@@ -754,6 +754,7 @@ public class ApiProblemFactory {
case IDelta.METHOD:
return 44;
case IDelta.DEFAULT_METHOD:
+ case IDelta.SUPER_INTERFACE_DEFAULT_METHOD:
return 47;
case IDelta.RESTRICTIONS:
return 72;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/DeltaProcessor.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/DeltaProcessor.java
index 34235835ac..5f40d287cf 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/DeltaProcessor.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/DeltaProcessor.java
@@ -576,6 +576,7 @@ public class DeltaProcessor {
return RestrictionModifiers.isImplementRestriction(delta.getPreviousRestrictions()) || RestrictionModifiers.isImplementRestriction(delta.getCurrentRestrictions());
case IDelta.METHOD:
case IDelta.DEFAULT_METHOD:
+ case IDelta.SUPER_INTERFACE_DEFAULT_METHOD:
case IDelta.SUPER_INTERFACE_WITH_METHODS:
boolean isStatic = Flags.isStatic(delta.getNewModifiers());
if (isStatic == true) {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/IDelta.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/IDelta.java
index 04f7381a13..261c23eea6 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/IDelta.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/IDelta.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -855,6 +855,17 @@ public interface IDelta {
* @see #getFlags()
*/
public static final int DEFAULT_METHOD = 73;
+ /**
+ * Delta kind flag that denotes that an default method added to interface
+ * which has super interface with same method. <br>
+ * Applies to kinds:
+ * <ul>
+ * <li>{@link #ADDED}</li>
+ * </ul>
+ *
+ * @see #getFlags()
+ */
+ public static final int SUPER_INTERFACE_DEFAULT_METHOD = 74;
/**
* Return true if the receiver has no children deltas, false otherwise.
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java
index 719696e91d..8a0f68a59e 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java
@@ -775,6 +775,7 @@ public final class Util {
case IDelta.METHOD:
return "METHOD"; //$NON-NLS-1$
case IDelta.DEFAULT_METHOD:
+ case IDelta.SUPER_INTERFACE_DEFAULT_METHOD:
return "DEFAULT_METHOD"; //$NON-NLS-1$
case IDelta.METHOD_MOVED_UP:
return "METHOD_MOVED_UP"; //$NON-NLS-1$
@@ -1163,6 +1164,7 @@ public final class Util {
case IDelta.METHOD_WITHOUT_DEFAULT_VALUE:
case IDelta.METHOD:
case IDelta.DEFAULT_METHOD:
+ case IDelta.SUPER_INTERFACE_DEFAULT_METHOD:
case IDelta.CONSTRUCTOR:
return getMethod(type, key);
case IDelta.TYPE_MEMBER:
@@ -2332,6 +2334,7 @@ public final class Util {
return arguments[0];
case IDelta.METHOD:
case IDelta.DEFAULT_METHOD:
+ case IDelta.SUPER_INTERFACE_DEFAULT_METHOD:
case IDelta.CONSTRUCTOR:
case IDelta.ENUM_CONSTANT:
case IDelta.METHOD_WITH_DEFAULT_VALUE:

Back to the top