Skip to content

Commit 7260181

Browse files
committed
Remove usage of the sequence number from target files
Currently there is an attribute 'sequenceNumber' that should change "whenever something in the target that affects the set of features and bundles that would be resolved" but effectively this never worked very well: - A sequence number is not mandatory - Target files are often edited by humans and it is easy to forget to increment those - Updating it was never public API so only with some operations it was possible to implicitly change that - it is only used to check if a P2 profile is up-to-date where the sequence number is a very bad indication as actually even things outside the target can influence it - even if the sequence number does not matches, P2TargetUtils performed some other checks if maybe the profile has not changed, so P2TargetUtils is already aware of changes without it To summarize if the sequence number did not changed the profile is considered clean (what might be wrong), if it changed we ignore it and check our self if it changed. To prevent us from strange errors and uncertainties, this now completely removes the 'sequenceNumber' and corresponding code leaving the responsibility to detect something changes completely to the implementation of the target location.
1 parent cb0d691 commit 7260181

File tree

10 files changed

+7
-80
lines changed

10 files changed

+7
-80
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ public class TargetDefinition implements ITargetDefinition {
124124
private TargetFeature[] fFeatures;
125125
private TargetBundle[] fOtherBundles;
126126

127-
private int fSequenceNumber = -1;
128-
129127
/**
130128
* Constructs a target definition based on the given handle.
131129
*/
@@ -210,7 +208,6 @@ public String getWS() {
210208

211209
@Override
212210
public void setArch(String arch) {
213-
incrementSequenceNumber();
214211
fArch = arch;
215212
if (fRoot != null && arch != null && !arch.isEmpty()) {
216213
Element archNode = TargetDefinitionDocumentTools.getChildElement(fRoot,
@@ -224,7 +221,6 @@ public void setArch(String arch) {
224221

225222
@Override
226223
public void setNL(String nl) {
227-
incrementSequenceNumber();
228224
fNL = nl;
229225
if (fRoot != null && nl != null && !nl.isEmpty()) {
230226
Element nlNode = TargetDefinitionDocumentTools.getChildElement(fRoot,
@@ -250,7 +246,6 @@ public void setName(String name) {
250246

251247
@Override
252248
public void setOS(String os) {
253-
incrementSequenceNumber();
254249
fOS = os;
255250
if (fRoot != null && os != null && !os.isEmpty()) {
256251
Element nlNode = TargetDefinitionDocumentTools.getChildElement(fRoot,
@@ -296,7 +291,6 @@ public void setVMArguments(String args) {
296291

297292
@Override
298293
public void setWS(String ws) {
299-
incrementSequenceNumber();
300294
fWS = ws;
301295
if (fRoot != null && ws != null && !ws.isEmpty()) {
302296
Element nlNode = TargetDefinitionDocumentTools.getChildElement(fRoot,
@@ -310,7 +304,6 @@ public void setWS(String ws) {
310304

311305
@Override
312306
public void setTargetLocations(ITargetLocation[] locations) {
313-
incrementSequenceNumber();
314307
// Clear the feature model cache as it is based on the bundle container locations
315308
fFeatures = null;
316309
fOtherBundles = null;
@@ -770,7 +763,6 @@ void setContents(InputStream stream) throws CoreException {
770763
fProgramArgs = null;
771764
fVMArgs = null;
772765
fWS = null;
773-
fSequenceNumber = 0;
774766
fDocument = null;
775767
fRoot = null;
776768
TargetDefinitionPersistenceHelper.initFromXML(this, stream);
@@ -819,7 +811,6 @@ public NameVersionDescriptor[] getImplicitDependencies() {
819811

820812
@Override
821813
public void setImplicitDependencies(NameVersionDescriptor[] bundles) {
822-
incrementSequenceNumber();
823814
if (bundles != null && bundles.length == 0) {
824815
bundles = null;
825816
}
@@ -1106,26 +1097,6 @@ public void setUIMode(int mode) {
11061097
}
11071098
}
11081099

1109-
/**
1110-
* Returns the current sequence number of this target. Sequence numbers change
1111-
* whenever something in the target that affects the set of features and bundles that
1112-
* would be resolved.
1113-
*
1114-
* @return the current sequence number
1115-
*/
1116-
public int getSequenceNumber() {
1117-
return fSequenceNumber;
1118-
}
1119-
1120-
/**
1121-
* Increases the current sequence number.
1122-
* @see TargetDefinition#getSequenceNumber()
1123-
* @return the current sequence number after it has been increased
1124-
*/
1125-
public int incrementSequenceNumber() {
1126-
return ++fSequenceNumber;
1127-
}
1128-
11291100
private void removeElement(String... childNames) {
11301101
if (fRoot != null) {
11311102
TargetDefinitionDocumentTools.removeElement(fRoot, childNames);

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetPersistence36Helper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class TargetPersistence36Helper {
4141

4242
/* Example of Software location in Target XML
4343
44-
<?xml version="1.0" encoding="UTF-8"?><?pde version="3.6"?><target name="SoftwareSiteTarget" sequenceNumber="6">
44+
<?xml version="1.0" encoding="UTF-8"?><?pde version="3.6"?><target name="SoftwareSiteTarget">
4545
<locations>
4646
<location includeAllPlatforms="false" includeMode="slicer" includeSource="true" type="InstallableUnit">
4747
<unit id="org.eclipse.egit.feature.group" version="0.11.3"/>

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetPersistence38Helper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class TargetPersistence38Helper {
5454
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
5555
<?pde version="3.8"?>
5656
57-
<target name="test" sequenceNumber="9">
57+
<target name="test">
5858
<locations>
5959
<location path="${eclipse_home}" type="Directory"/>
6060
<location path="${eclipse_home}" type="Profile"/>

ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/AttributeNameCompletionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class AttributeNameCompletionTests extends AbstractTargetEditorTest {
2828
public void testAttributeNameSuggestions() throws Exception {
2929
Map<Integer, String[]> expectedProposalsByOffset = new HashMap<>();
3030
// target
31-
expectedProposalsByOffset.put(8, new String[] { "name", "sequenceNumber" });
31+
expectedProposalsByOffset.put(8, new String[] { "name" });
3232
// location
3333
expectedProposalsByOffset.put(33, new String[] { "followRepositoryReferences", "includeAllPlatforms",
3434
"includeConfigurePhase", "includeMode", "includeSource", "type" });

ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/autocomplete/TagCompletionProposal.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public class TagCompletionProposal extends TargetCompletionProposal {
2424

2525
static {
2626
tagStartingAttributesAndValues.put(ITargetConstants.TARGET_TAG, new Attribute[] {
27-
new Attribute(ITargetConstants.TARGET_NAME_ATTR, null),
28-
new Attribute(ITargetConstants.TARGET_SEQ_NO_ATTR, "1") });
27+
new Attribute(ITargetConstants.TARGET_NAME_ATTR, null) });
2928
tagStartingAttributesAndValues.put(ITargetConstants.LOCATION_DIRECTORY_COMPLETION_LABEL, new Attribute[] {
3029
new Attribute(ITargetConstants.LOCATION_PATH_ATTR, null),
3130
new Attribute(ITargetConstants.LOCATION_TYPE_ATTR, ITargetConstants.LOCATION_TYPE_ATTR_VALUE_DIRECTORY) });

ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/autocomplete/processors/AttributeNameCompletionProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class AttributeNameCompletionProcessor extends DelegateProcessor {
4747
private static final String ATTRIBUTE_NAME_FIND = "(?:\\s*(\\w*)\\s*=\\s*\".*?\")";// $NON-NLS-1$
4848
private static final Pattern ATT_NAME_PATTERN = Pattern.compile(ATTRIBUTE_NAME_FIND);
4949

50-
private final String[] target = new String[] { ITargetConstants.TARGET_NAME_ATTR, ITargetConstants.TARGET_SEQ_NO_ATTR };
50+
private final String[] target = new String[] { ITargetConstants.TARGET_NAME_ATTR };
5151
private final String[] locations = new String[] {};
5252
private final String[] location = new String[] { ITargetConstants.LOCATION_INCLUDE_PLATFORMS_ATTR,
5353
ITargetConstants.LOCATION_INCLUDE_CONFIG_PHASE_ATTR, ITargetConstants.LOCATION_FOLLOW_REPOSITORY_REFERENCES_ATTR,

ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/model/ITargetConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public interface ITargetConstants {
4848
String UNIT_ID_ATTR = "id"; //$NON-NLS-1$
4949
String UNIT_VERSION_ATTR = "version"; //$NON-NLS-1$
5050
String TARGET_NAME_ATTR = "name"; //$NON-NLS-1$
51-
String TARGET_SEQ_NO_ATTR = "sequenceNumber"; //$NON-NLS-1$
5251
String LOCATION_INCLUDE_PLATFORMS_ATTR = "includeAllPlatforms"; //$NON-NLS-1$
5352
String LOCATION_INCLUDE_CONFIG_PHASE_ATTR = "includeConfigurePhase"; //$NON-NLS-1$
5453
String LOCATION_FOLLOW_REPOSITORY_REFERENCES_ATTR = "followRepositoryReferences";

ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/reconciler/presentation/TargetPlatformAttributeRule.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515

1616
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.INCLUDE_DEPENDENCY_DEPTH;
1717
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.INCLUDE_DEPENDENCY_SCOPES;
18+
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_FOLLOW_REPOSITORY_REFERENCES_ATTR;
1819
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_INCLUDE_CONFIG_PHASE_ATTR;
1920
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_INCLUDE_MODE_ATTR;
2021
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_INCLUDE_PLATFORMS_ATTR;
21-
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_FOLLOW_REPOSITORY_REFERENCES_ATTR;
2222
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_INCLUDE_SOURCE_ATTR;
2323
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.LOCATION_TYPE_ATTR;
2424
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.MISSING_MANIFEST;
2525
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.REPOSITORY_LOCATION_ATTR;
2626
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.TARGET_JRE_PATH_ATTR;
2727
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.TARGET_NAME_ATTR;
28-
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.TARGET_SEQ_NO_ATTR;
2928
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.UNIT_ID_ATTR;
3029
import static org.eclipse.pde.internal.genericeditor.target.extension.model.ITargetConstants.UNIT_VERSION_ATTR;
3130

@@ -42,7 +41,7 @@ public class TargetPlatformAttributeRule extends WordRule {
4241

4342
private static final String[] ATTRIBUTES = new String[] { TARGET_NAME_ATTR, UNIT_VERSION_ATTR, UNIT_ID_ATTR,
4443
LOCATION_INCLUDE_PLATFORMS_ATTR, LOCATION_INCLUDE_MODE_ATTR, LOCATION_TYPE_ATTR, REPOSITORY_LOCATION_ATTR,
45-
TARGET_JRE_PATH_ATTR, TARGET_SEQ_NO_ATTR, LOCATION_INCLUDE_CONFIG_PHASE_ATTR,
44+
TARGET_JRE_PATH_ATTR, LOCATION_INCLUDE_CONFIG_PHASE_ATTR,
4645
LOCATION_FOLLOW_REPOSITORY_REFERENCES_ATTR, LOCATION_INCLUDE_SOURCE_ATTR, INCLUDE_DEPENDENCY_DEPTH,
4746
INCLUDE_DEPENDENCY_SCOPES, MISSING_MANIFEST };
4847
private final IToken attributeToken = new Token(

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -482,39 +482,6 @@ private static void validateTypeAndLocation(ITargetLocation container, Class<?>
482482
assertEquals(rawLocation, container.getLocation(false));
483483
}
484484

485-
/**
486-
* Tests that we increment the sequence number correctly when target is
487-
* modified contents.
488-
*/
489-
@Test
490-
public void testSequenceNumberChange() throws Exception {
491-
ITargetDefinition target = readOldTarget("featureLocations");
492-
493-
assertEquals("Wrong name", "Features", target.getName());
494-
TargetDefinition targetDef = (TargetDefinition) target;
495-
int currentSeqNo = targetDef.getSequenceNumber();
496-
target.setArch("x86");
497-
asssertSequenceNumber("Arch", currentSeqNo, targetDef);
498-
499-
currentSeqNo = targetDef.getSequenceNumber();
500-
target.setOS("win32");
501-
asssertSequenceNumber("OS", currentSeqNo, targetDef);
502-
503-
currentSeqNo = targetDef.getSequenceNumber();
504-
target.setNL("hi_IN");
505-
asssertSequenceNumber("NL", currentSeqNo, targetDef);
506-
507-
currentSeqNo = targetDef.getSequenceNumber();
508-
target.setWS("carbon");
509-
asssertSequenceNumber("WS", currentSeqNo, targetDef);
510-
511-
ITargetLocation[] newContainers = new ITargetLocation[1];
512-
newContainers[0] = new DirectoryBundleContainer("Path");
513-
currentSeqNo = targetDef.getSequenceNumber();
514-
target.setTargetLocations(newContainers);
515-
asssertSequenceNumber("Bundle Containers", currentSeqNo, targetDef);
516-
}
517-
518485
@Test
519486
public void testIncludeSource() throws Exception {
520487
ITargetDefinition target = readOldTarget("SoftwareSiteTarget");
@@ -684,9 +651,4 @@ private void assertTargetDefinitionsEqual(ITargetDefinition targetA, ITargetDefi
684651
assertTrue("Target content not equal", ((TargetDefinition) targetA).isContentEqual(targetB));
685652
}
686653

687-
private void asssertSequenceNumber(String name, int currentSeqNo, TargetDefinition targetDef) {
688-
assertEquals("Sequence number did not increment after updating '" + name + "'", currentSeqNo + 1,
689-
targetDef.getSequenceNumber());
690-
}
691-
692654
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/ToggleIncludeHandler.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ public IStatus toggle(ITargetDefinition target, TreePath[] treePath) {
101101
include.stream());
102102
}
103103
target.setIncluded(stream.toArray(NameVersionDescriptor[]::new));
104-
if (target instanceof TargetDefinition) {
105-
((TargetDefinition) target).incrementSequenceNumber();
106-
}
107104
return Status.OK_STATUS;
108105
}
109106

0 commit comments

Comments
 (0)