| author | kwannheden | 2009-10-16 06:36:53 (EDT) |
|---|---|---|
| committer | sefftinge | 2009-10-16 06:36:53 (EDT) |
| commit | 01b8f32481353ae5cd17896873dcab49e53a77cf (patch) (side-by-side diff) | |
| tree | 6bbbd2c3d614ff93939e9e05c47b108547627d73 | |
| parent | ba953733433cb5016e65678d5a2c732196966122 (diff) | |
| download | org.eclipse.xtext-01b8f32481353ae5cd17896873dcab49e53a77cf.zip org.eclipse.xtext-01b8f32481353ae5cd17896873dcab49e53a77cf.tar.gz org.eclipse.xtext-01b8f32481353ae5cd17896873dcab49e53a77cf.tar.bz2 | |
Fix: quickfix support must check that resource matches expected grammar
| -rw-r--r-- | plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/quickfix/AbstractDeclarativeQuickfixProvider.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/quickfix/AbstractDeclarativeQuickfixProvider.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/quickfix/AbstractDeclarativeQuickfixProvider.java index abbdfc2..2cdd787 100644 --- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/quickfix/AbstractDeclarativeQuickfixProvider.java +++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/quickfix/AbstractDeclarativeQuickfixProvider.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Set; import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; @@ -41,6 +42,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.Inject; +import com.google.inject.name.Named; /** * @author Knut Wannheden - Initial contribution and API @@ -61,6 +63,23 @@ public class AbstractDeclarativeQuickfixProvider implements IMarkerResolutionGen return imageHelper; } + @Inject + @Named("file.extensions") + private String fileExtensions; + + protected String[] getFileExtensions() { + return fileExtensions.split(","); + } + + protected boolean isLanguageResource(IResource resource) { + String fileExtension = resource.getFullPath().getFileExtension(); + for (String ext : getFileExtensions()) { + if (ext.equals(fileExtension)) + return true; + } + return false; + } + protected IXtextDocument getDocument(IMarker marker) { return XtextDocumentUtil.get(marker.getResource()); } @@ -195,6 +214,8 @@ public class AbstractDeclarativeQuickfixProvider implements IMarkerResolutionGen } catch (CoreException e) { return false; } + if (!isLanguageResource(marker.getResource())) + return false; if (getCode(marker) == null) return false; |

