Lines 25-35
Link Here
|
25 |
import org.eclipse.core.resources.IResource; |
25 |
import org.eclipse.core.resources.IResource; |
26 |
import org.eclipse.core.runtime.CoreException; |
26 |
import org.eclipse.core.runtime.CoreException; |
27 |
import org.eclipse.core.runtime.IAdaptable; |
27 |
import org.eclipse.core.runtime.IAdaptable; |
|
|
28 |
import org.eclipse.mylyn.commons.core.StatusHandler; |
28 |
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge; |
29 |
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge; |
29 |
import org.eclipse.mylyn.context.core.ContextCorePlugin; |
|
|
30 |
import org.eclipse.mylyn.context.core.IInteractionElement; |
30 |
import org.eclipse.mylyn.context.core.IInteractionElement; |
|
|
31 |
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin; |
31 |
import org.eclipse.mylyn.internal.resources.ui.ResourceStructureBridge; |
32 |
import org.eclipse.mylyn.internal.resources.ui.ResourceStructureBridge; |
32 |
import org.eclipse.mylyn.monitor.core.StatusHandler; |
|
|
33 |
import org.eclipse.ui.internal.WorkingSet; |
33 |
import org.eclipse.ui.internal.WorkingSet; |
34 |
import org.eclipse.ui.views.markers.internal.ConcreteMarker; |
34 |
import org.eclipse.ui.views.markers.internal.ConcreteMarker; |
35 |
|
35 |
|
Lines 100-107
Link Here
|
100 |
return childHandles; |
100 |
return childHandles; |
101 |
} catch (CModelException e) { |
101 |
} catch (CModelException e) { |
102 |
// ignore these, usually indicate no-existent element |
102 |
// ignore these, usually indicate no-existent element |
103 |
} catch (Exception e) { |
|
|
104 |
StatusHandler.fail(e, CDTUIBridgePlugin.getResourceString("MylynCDT.childAccessFailed"), false); // $NON-NLS-1$ |
105 |
} |
103 |
} |
106 |
} |
104 |
} |
107 |
} |
105 |
} |
Lines 109-160
Link Here
|
109 |
} |
107 |
} |
110 |
|
108 |
|
111 |
public static ICElement getElementForHandle(String handle) { |
109 |
public static ICElement getElementForHandle(String handle) { |
112 |
// System.out.println("[handle is " + handle); |
|
|
113 |
// ICElement s = null; |
114 |
// |
115 |
// s = CoreModel.create(handle); |
116 |
// if (s == null) |
117 |
// System.out.println("[null handle is " + handle); |
118 |
// else |
119 |
// System.out.println("[element is " + s.getElementName()); |
120 |
// |
121 |
// return s; |
122 |
return CoreModel.create(handle); |
110 |
return CoreModel.create(handle); |
123 |
// try { |
|
|
124 |
// String[] s = handle.split("\\|"); // $NON-NLS-1$ |
125 |
// if (s.length < 1) |
126 |
// return null; |
127 |
// int kind = Integer.valueOf(s[0]); |
128 |
// switch (kind) { |
129 |
// case ICElement.C_PROJECT: { |
130 |
// return CoreModel.getDefault().getCModel().getCProject(s[1]); |
131 |
// } |
132 |
// case ICElement.C_CCONTAINER: { |
133 |
// ICProject cproject = CoreModel.getDefault().getCModel().getCProject(s[1]); |
134 |
// return cproject.findElement(new Path(s[3])); |
135 |
// } |
136 |
// case C_SOURCEROOT: { |
137 |
// ICProject cproject = CoreModel.getDefault().getCModel().getCProject(s[1]); |
138 |
// return cproject.findSourceRoot(new Path(s[3])); |
139 |
// } |
140 |
// case ICElement.C_MODEL: { |
141 |
// return CoreModel.getDefault().getCModel(); |
142 |
// } |
143 |
// case ICElement.C_UNIT: { |
144 |
// IPath path = new Path(s[3]); |
145 |
// ICElement element = CoreModel.getDefault().create(path); |
146 |
// return (ITranslationUnit)element; |
147 |
// } |
148 |
// } |
149 |
// |
150 |
// // Otherwise, find the element by name within the TranslationUnit |
151 |
// IPath path = new Path(s[3]); |
152 |
// ICElement element = CoreModel.getDefault().create(path); |
153 |
// return ((ITranslationUnit)element).getElement(s[2]); |
154 |
// } catch (CModelException e) { |
155 |
// StatusHandler.log(CDTUIBridgePlugin.getFormattedString("MylynCDT.log.noObjectForHandle", new String[]{handle}), null); // $NON-NLS-1$ |
156 |
// return null; |
157 |
// } |
158 |
} |
111 |
} |
159 |
|
112 |
|
160 |
|
113 |
|
Lines 170-208
Link Here
|
170 |
// The element name (optional) allows us to find an element within the |
123 |
// The element name (optional) allows us to find an element within the |
171 |
// TranslationUnit. |
124 |
// TranslationUnit. |
172 |
public static String getHandleForElement(ICElement element) { |
125 |
public static String getHandleForElement(ICElement element) { |
173 |
// System.out.println("element is " + element.getClass().getName()); |
|
|
174 |
// System.out.println("handle is " + element.getHandleIdentifier()); |
175 |
return element.getHandleIdentifier(); |
126 |
return element.getHandleIdentifier(); |
176 |
// IPath path = element.getUnderlyingResource().getRawLocation(); |
|
|
177 |
// int elementType = element.getElementType(); |
178 |
// switch (elementType) { |
179 |
// case ICElement.C_PROJECT: |
180 |
// return ICElement.C_PROJECT + "|" + element.getCProject().getElementName() + "||"; // $NON-NLS-1$ // $NON-NLS-2$ |
181 |
// case ICElement.C_UNIT: |
182 |
// // FIXME: don't need project (external files won't have project |
183 |
// return ICElement.C_UNIT + "|" + element.getCProject().getElementName() + "||" + path.toPortableString(); // $NON-NLS-1$ // $NON-NLS-2$ |
184 |
// case ICElement.C_MODEL: |
185 |
// return ICElement.C_MODEL + "|"; // $NON-NLS-1$ |
186 |
// case ICElement.C_CCONTAINER: { |
187 |
// if (element instanceof ISourceRoot) { |
188 |
// // Special case of CContainer. A SourceRoot doesn't have a path set. |
189 |
// ISourceRoot root = (ISourceRoot)element; |
190 |
// path = element.getPath(); |
191 |
// return Integer.toString(C_SOURCEROOT) + "|" + element.getCProject().getElementName() + "||" + path.toPortableString(); // $NON-NLS-1$ // $NON-NLS-2$ |
192 |
// } |
193 |
// return ICElement.C_CCONTAINER + "|" + element.getCProject().getElementName() + "||" + path.toPortableString(); // $NON-NLS-1$ // $NON-NLS-2$ |
194 |
// } |
195 |
// case ICElement.C_BINARY: |
196 |
// case ICElement.C_ARCHIVE: |
197 |
// case ICElement.C_VCONTAINER: |
198 |
// case ICElement.C_UNKNOWN_DECLARATION: |
199 |
// // FIXME: For now, don't handle these |
200 |
// return null; |
201 |
// default: |
202 |
// // We default all other elements as children of the TranslationUnit |
203 |
// return Integer.toString(0) + "|" + element.getCProject().getElementName() + "|" + element.getElementName() // $NON-NLS-1$ // $NON-NLS-2$ |
204 |
// + "|" + path.toPortableString(); // $NON-NLS-1$ |
205 |
// } |
206 |
} |
127 |
} |
207 |
|
128 |
|
208 |
/** |
129 |
/** |
Lines 328-337
Link Here
|
328 |
} |
249 |
} |
329 |
} catch (CModelException ex) { |
250 |
} catch (CModelException ex) { |
330 |
if (ex.doesNotExist()) |
251 |
if (ex.doesNotExist()) |
331 |
StatusHandler.fail(ex, ex.getLocalizedMessage(), false); |
252 |
StatusHandler.fail(ex.getStatus()); |
332 |
return null; |
|
|
333 |
} catch (Throwable t) { |
334 |
StatusHandler.fail(t, CDTUIBridgePlugin.getFormattedString("MylynCDT.cantFindElement", new String[]{marker.toString()}), false); // $NON-NLS-1$ |
335 |
return null; |
253 |
return null; |
336 |
} |
254 |
} |
337 |
} |
255 |
} |