From d5a771f061d6d063ea942fe0162459304d42b176 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Tue, 15 Oct 2024 23:09:01 +0200 Subject: [PATCH 1/2] [TP-Editor] Adapt content-assist to support of version-ranges/no-version - Remove 'version' attribute from 'unit' proposal Now that PDE supports no versions in unit declarations it does not have to be proposed for all cases. - Skip units with version-range in the 'UpdateUnitVersions' action from the context menu in the Source tab. --- .../autocomplete/TagCompletionProposal.java | 5 ++--- .../extension/command/UpdateUnitVersions.java | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/autocomplete/TagCompletionProposal.java b/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/autocomplete/TagCompletionProposal.java index c8265b2553..806e49ce7e 100644 --- a/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/autocomplete/TagCompletionProposal.java +++ b/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/autocomplete/TagCompletionProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Red Hat Inc. and others + * Copyright (c) 2018, 2024 Red Hat Inc. and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -39,8 +39,7 @@ public class TagCompletionProposal extends TargetCompletionProposal { new Attribute(ITargetConstants.LOCATION_PATH_ATTR, null), new Attribute(ITargetConstants.LOCATION_TYPE_ATTR, ITargetConstants.LOCATION_TYPE_ATTR_VALUE_PROFILE) }); tagStartingAttributesAndValues.put(ITargetConstants.UNIT_TAG, new Attribute[] { - new Attribute(ITargetConstants.UNIT_ID_ATTR, null), - new Attribute(ITargetConstants.UNIT_VERSION_ATTR, ITargetConstants.UNIT_VERSION_ATTR_GENERIC) }); + new Attribute(ITargetConstants.UNIT_ID_ATTR, null) }); tagStartingAttributesAndValues.put(ITargetConstants.REPOSITORY_TAG, new Attribute[] { new Attribute(ITargetConstants.REPOSITORY_LOCATION_ATTR, null) }); tagStartingAttributesAndValues.put(ITargetConstants.TARGET_JRE_TAG, new Attribute[] { diff --git a/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/command/UpdateUnitVersions.java b/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/command/UpdateUnitVersions.java index 260f72d984..904d7fa554 100644 --- a/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/command/UpdateUnitVersions.java +++ b/ui/org.eclipse.pde.genericeditor.extension/src/org/eclipse/pde/internal/genericeditor/target/extension/command/UpdateUnitVersions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2022 Red Hat Inc. and others + * Copyright (c) 2018, 2024 Red Hat Inc. and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -87,6 +87,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException { List repositoryUnits = cache.fetchP2UnitsFromRepo(repositoryLocation, false); for (Node n2 : locationNode.getChildNodesByTag(ITargetConstants.UNIT_TAG)) { UnitNode unitNode = ((UnitNode) n2); + String declaredVersion = unitNode.getVersion(); + + @SuppressWarnings("restriction") + // if not ok, probably a version range + boolean isValidExplicitVersion = org.eclipse.pde.internal.core.util.VersionUtil + .validateVersion(declaredVersion).isOK(); + if (declaredVersion == null || !isValidExplicitVersion) { + continue; + } List versions = null; for (UnitNode unit : repositoryUnits) { if (unit.getId().equals(unitNode.getId())) { @@ -99,20 +108,19 @@ public Object execute(ExecutionEvent event) throws ExecutionException { } Collections.sort(versions, (v1, v2) -> (new Version(v2)).compareTo(new Version(v1))); String version = versions.get(0); - if (version == null || version.isEmpty() || unitNode.getVersion() == null - || version.equals(unitNode.getVersion())) { + if (version == null || version.isEmpty() || version.equals(declaredVersion)) { continue; } String nodeString = documentText.substring(unitNode.getOffsetStart() + offsetChange, unitNode.getOffsetEnd() + offsetChange); - nodeString = nodeString.replaceFirst("version=\"" + unitNode.getVersion() + "\"", + nodeString = nodeString.replaceFirst("version=\"" + declaredVersion + "\"", "version=\"" + version + "\""); documentText = documentText.substring(0, unitNode.getOffsetStart() + offsetChange) + nodeString + documentText.substring(unitNode.getOffsetEnd() + offsetChange, documentText.length()); - offsetChange += version.length() - unitNode.getVersion().length(); + offsetChange += version.length() - declaredVersion.length(); } } if (document.get().equals(documentText)) { From e02909dc628e5474004cb0d21c95e1db804bbcfa Mon Sep 17 00:00:00 2001 From: Eclipse PDE Bot Date: Wed, 16 Oct 2024 18:03:47 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.34 stream --- ui/org.eclipse.pde.genericeditor.extension/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/org.eclipse.pde.genericeditor.extension/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.genericeditor.extension/META-INF/MANIFEST.MF index eb6d8b1050..121014c534 100644 --- a/ui/org.eclipse.pde.genericeditor.extension/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.genericeditor.extension/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde.genericeditor.extension;singleton:=true -Bundle-Version: 1.2.400.qualifier +Bundle-Version: 1.2.500.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, org.eclipse.jface.text,