use of org.eclipse.debug.core.model.ISourceLocator in project xtext-xtend by eclipse.
the class XtendFileHyperlink method linkActivated.
@Override
public void linkActivated() {
try {
try {
ISourceLocator _sourceLocator = this.getLaunch().getSourceLocator();
final ISourceLocator l = _sourceLocator;
boolean _matched = false;
if (l instanceof AbstractSourceLookupDirector) {
_matched = true;
final Object result = ((AbstractSourceLookupDirector) l).getSourceElement(this.fileName);
boolean _matched_1 = false;
if (result instanceof IFile) {
_matched_1 = true;
final IEditorPart editor = IDE.openEditor(this.workbench.getActiveWorkbenchWindow().getActivePage(), ((IFile) result));
boolean _matched_2 = false;
if (editor instanceof XtextEditor) {
_matched_2 = true;
final IRegion region = ((XtextEditor) editor).getDocument().getLineInformation((this.lineNumber - 1));
((XtextEditor) editor).selectAndReveal(region.getOffset(), region.getLength());
}
}
}
} catch (final Throwable _t) {
if (_t instanceof NumberFormatException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.debug.core.model.ISourceLocator in project linuxtools by eclipse.
the class ValgrindCoreParser method copyLaunchSourceLocator.
/**
* Return a safe source locator from launch object which won't be disposed if launch object is disposed
* @param launch - launch object
* @return source locator
*/
public static ISourceLocator copyLaunchSourceLocator(ILaunch launch) {
if (launch == null)
return null;
ISourceLocator sourceLocator = launch.getSourceLocator();
ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration();
// since we want to use it later we need to create a copy of it
if (sourceLocator instanceof ISourceLookupDirector) {
try {
ISourceLookupDirector director = (ISourceLookupDirector) sourceLocator;
String id = director.getId();
String memento = director.getMemento();
IPersistableSourceLocator sourceLocatorCopy = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(id);
if (sourceLocatorCopy instanceof IPersistableSourceLocator2) {
((IPersistableSourceLocator2) sourceLocatorCopy).initializeFromMemento(memento, launchConfiguration);
} else
sourceLocatorCopy.initializeFromMemento(memento);
return sourceLocatorCopy;
} catch (CoreException e) {
// ignore
}
}
return sourceLocator;
}
use of org.eclipse.debug.core.model.ISourceLocator in project linuxtools by eclipse.
the class LinkedResourceMarkerTest method isWorkspaceFrame.
private boolean isWorkspaceFrame(ValgrindStackFrame frame) {
ISourceLocator locator = frame.getSourceLocator();
Object result = DebugUITools.lookupSource(frame.getFile(), locator).getSourceElement();
return result != null && result instanceof IResource;
}
use of org.eclipse.debug.core.model.ISourceLocator in project linuxtools by eclipse.
the class MarkerTest method isWorkspaceFrame.
private boolean isWorkspaceFrame(ValgrindStackFrame frame) {
ISourceLocator locator = frame.getSourceLocator();
Object result = DebugUITools.lookupSource(frame.getFile(), locator).getSourceElement();
return result != null && result instanceof IResource;
}
use of org.eclipse.debug.core.model.ISourceLocator in project linuxtools by eclipse.
the class ValgrindLaunchConfigurationDelegate method createMarkers.
private void createMarkers(IValgrindMessage[] messages) throws CoreException {
// find the topmost stack frame within the workspace to annotate with marker
// traverse nested errors as well
Stack<IValgrindMessage> messageStack = new Stack<>();
messageStack.addAll(Arrays.asList(messages));
while (!messageStack.isEmpty()) {
IValgrindMessage message = messageStack.pop();
IMarker marker = null;
IValgrindMessage[] children = message.getChildren();
for (int i = 0; i < children.length; i++) {
// if we've found our marker we don't care about any further frames in this stack
if (children[i] instanceof ValgrindStackFrame && marker == null) {
ValgrindStackFrame frame = (ValgrindStackFrame) children[i];
if (frame.getLine() > 0) {
ISourceLocator locator = frame.getSourceLocator();
ISourceLookupResult result = DebugUITools.lookupSource(frame.getFile(), locator);
Object sourceElement = result.getSourceElement();
if (sourceElement != null) {
// Resolve IResource in case we get a LocalFileStorage object
if (sourceElement instanceof LocalFileStorage) {
IPath filePath = ((LocalFileStorage) sourceElement).getFullPath();
URI fileURI = URIUtil.toURI(filePath);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile[] files = root.findFilesForLocationURI(fileURI);
if (files.length > 0) {
// Take the first match
sourceElement = files[0];
}
}
if (sourceElement instanceof IResource) {
IResource resource = (IResource) sourceElement;
marker = resource.createMarker(ValgrindLaunchPlugin.MARKER_TYPE);
marker.setAttribute(IMarker.MESSAGE, message.getText());
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
marker.setAttribute(IMarker.LINE_NUMBER, frame.getLine());
}
}
}
} else if (children[i] instanceof ValgrindError) {
// nested error
messageStack.push(children[i]);
}
}
}
}
Aggregations