Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression on marker updates from #984 #994

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true
Bundle-Version: 3.16.100.qualifier
Bundle-Version: 3.17.0.qualifier
Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.runtime.CoreException;

import org.eclipse.core.resources.IMarker;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;

import org.eclipse.ui.internal.editors.text.EditorsPlugin;


/**
* Updates a marker's positional attributes which are
Expand Down Expand Up @@ -99,11 +95,7 @@ public boolean updateMarker(IMarker marker, IDocument document, Position positio
}

if (!attributeChanges.isEmpty()) {
try {
marker.setAttributes(attributeChanges);
} catch (CoreException e) {
EditorsPlugin.log(e);
}
MarkerUtilities.changeAttributes(marker, attributeChanges);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.osgi.framework.Bundle;

Expand Down Expand Up @@ -402,4 +404,50 @@ public static String[] getSuperTypes(String markerType) {
fgMarkerTypeHierarchy= new MarkerTypeHierarchy();
return fgMarkerTypeHierarchy.getSuperTypes(markerType);
}

/**
* Changes the given attribute key-value pairs of the map on this marker. The values must be
* <code>null</code> or an instance of one of the following classes: <code>String</code>,
* <code>Integer</code>, or <code>Boolean</code>. If a value is <code>null</code>, the new value
* of the attribute is considered to be undefined.
*
* <p>
* The values of the attributes cannot be <code>String</code> whose UTF encoding exceeds 65535
* bytes. On persistent markers this limit is enforced by an assertion.
* </p>
*
* <p>
* This method changes resources; these changes will be reported in a subsequent resource change
* event, including an indication that this marker has been modified.
* </p>
*
* @param marker the marker
* @param attributeChanges map with to be executed attribute changes
* @see IMarker#setAttributes(String[], Object[])
* @since 3.17
*/
public static void changeAttributes(IMarker marker, Map<String, Object> attributeChanges) {

iloveeclipse marked this conversation as resolved.
Show resolved Hide resolved
Set<Entry<String, Object>> entries= attributeChanges.entrySet();
int size= entries.size();

String[] keys= new String[size];
Object[] values= new Object[size];

int i= 0;
for (Entry<String, Object> e : entries) {
keys[i]= e.getKey();
values[i]= e.getValue();
i++;
}

try {
if (marker.exists()) {
marker.setAttributes(keys, values);
}
} catch (CoreException e) {
handleCoreException(e);
}

}
}
Loading