Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2016-01-05 21:29:30 -0500
committerGerrit Code Review @ Eclipse.org2016-01-07 20:35:31 -0500
commitd3e933501eb387cbf2e1c9c211ec8fac358f817b (patch)
treeae1a6f1ace7dfa0544f1329156026b4866088974 /codan/org.eclipse.cdt.codan.ui.cxx
parentbc953d2348156eac590c00aebeaa32e4eed9de95 (diff)
downloadorg.eclipse.cdt-d3e933501eb387cbf2e1c9c211ec8fac358f817b.tar.gz
org.eclipse.cdt-d3e933501eb387cbf2e1c9c211ec8fac358f817b.tar.xz
org.eclipse.cdt-d3e933501eb387cbf2e1c9c211ec8fac358f817b.zip
Bug 411579 - Add a "Create new class" Quick fix.
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui.cxx')
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF2
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/pom.xml2
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java60
3 files changed, 49 insertions, 15 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF
index 022ad8725f..3e381bb301 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.cdt.codan.ui.cxx;singleton:=true
-Bundle-Version: 3.2.0.qualifier
+Bundle-Version: 3.3.0.qualifier
Bundle-Activator: org.eclipse.cdt.codan.internal.ui.cxx.Activator
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml b/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml
index e9ba5a1898..0ac1b6c7e3 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml
@@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.codan.ui.cxx</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java
index c754417247..a37d148d73 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Alena Laskavaia
+ * Copyright (c) 2009, 2011 Alena Laskavaia
* 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
@@ -20,7 +20,9 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CDTUITools;
@@ -42,7 +44,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
* class for codanMarkerResolution extension. To add specific icon and
* description client class should additionally implement
* {@link IMarkerResolution2}
- *
+ *
* @since 2.0
*/
public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerResolution {
@@ -51,7 +53,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Get position offset from marker. If CHAR_START attribute is not set for
* marker, line and document would be used.
- *
+ *
* @param marker
* @param doc
* @return
@@ -82,10 +84,11 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Runs this resolution.
- *
+ *
* @param marker
* the marker to resolve
*/
+ @Override
public void run(IMarker marker) {
IDocument doc = openDocument(marker);
if (doc != null) {
@@ -96,7 +99,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Apply marker resolution for given marker in given open document.
- *
+ *
* @param marker
* @param document
*/
@@ -105,10 +108,11 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Override is extra checks is required to determine appicablity of marker
* resolution
- *
+ *
* @param marker
* @return
*/
+ @Override
public boolean isApplicable(IMarker marker) {
return true;
}
@@ -118,7 +122,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
* returns the corresponding IEditorPart. Please note that is code analysis
* is setup to run on reconsile this action would trigger checkers run, and
* original marker may be removed as a result.
- *
+ *
* @param marker
* the problem marker
* @return the opened document
@@ -137,7 +141,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Opens the editor and returns the document corresponding to a given
* marker.
- *
+ *
* @param marker
* the marker to find the editor
* @return the corresponding document
@@ -148,7 +152,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Returns the document corresponding to a given editor part.
- *
+ *
* @param editorPart
* an editor part
* @return the document of that part
@@ -164,7 +168,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Receives a translation unit from a given marker. Opens the editor.
- *
+ *
* @param marker
* A marker in an editor to get the translation unit
* @return The translation unit
@@ -176,7 +180,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Receives a translation unit from a given marker using the marker's path.
- *
+ *
* @param marker
* A marker in a translation unit
* @return The translation unit
@@ -190,7 +194,7 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
/**
* Receives an ASTName enclosing a given IMarker
- *
+ *
* @param marker
* The marker enclosing an ASTName
* @param ast
@@ -215,9 +219,39 @@ public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerReso
}
/**
+ * Returns the smallest element within translation unit that
+ * includes the given source position (that is, a method, field, etc.), or
+ * {@code null} if there is no element other than the translation
+ * unit itself at the given position, or if the given position is not
+ * within the source range of this translation unit.
+ *
+ * @param marker that contains a position inside the translation unit
+ * @return the innermost C element enclosing a given source position or
+ * {@code null}
+ * if none found (excluding the translation unit).
+ * @since 3.3
+ */
+ protected ICElement getCElementFromMarker(IMarker marker) {
+ ITranslationUnit tu = getTranslationUnitViaEditor(marker);
+ ICElement element = null;
+ try {
+ int charStart = marker.getAttribute(IMarker.CHAR_START, -1);
+ if (charStart > 0) {
+ element = tu.getElementAtOffset(charStart);
+ } else {
+ int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, -1);
+ element = tu.getElementAtLine(lineNumber);
+ }
+ } catch (CModelException e) {
+ CodanUIActivator.log(e);
+ }
+ return element;
+ }
+
+ /**
* Receives an {@link IIndex} corresponding to the given {@link IMarker}'s
* resource.
- *
+ *
* @param marker
* the marker to use
* @return the received index

Back to the top