Search in sources :

Example 1 with AbstractSourceLookupDirector

use of org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector 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);
    }
}
Also used : AbstractSourceLookupDirector(org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector) IFile(org.eclipse.core.resources.IFile) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) IEditorPart(org.eclipse.ui.IEditorPart) ISourceLocator(org.eclipse.debug.core.model.ISourceLocator) IRegion(org.eclipse.jface.text.IRegion)

Example 2 with AbstractSourceLookupDirector

use of org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector in project linuxtools by eclipse.

the class STCSourceNotFoundEditor method addSourceMappingToCommon.

private void addSourceMappingToCommon(IPath missingPath, IPath newSourcePath) throws CoreException {
    AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
    addSourceMappingToDirector(missingPath, newSourcePath, director);
    try {
        InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).flush();
    } catch (BackingStoreException e) {
        IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.STCSourceNotFoundEditor_failed_saving_settings_for_content_type + CDebugCorePlugin.PLUGIN_ID, e);
        throw new CoreException(status);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) AbstractSourceLookupDirector(org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector) CoreException(org.eclipse.core.runtime.CoreException) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 3 with AbstractSourceLookupDirector

use of org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector in project linuxtools by eclipse.

the class STLink2SourceSupport method findFileInCommonSourceLookup.

private static IEditorInput findFileInCommonSourceLookup(IPath path) {
    try {
        AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
        ISourceContainer[] c = director.getSourceContainers();
        for (ISourceContainer sourceContainer : c) {
            Object[] o = sourceContainer.findSourceElements(path.toOSString());
            for (Object object : o) {
                if (object instanceof IFile) {
                    return new FileEditorInput((IFile) object);
                } else if (object instanceof LocalFileStorage) {
                    LocalFileStorage storage = (LocalFileStorage) object;
                    IFileStore ifs = EFS.getStore(storage.getFile().toURI());
                    return new FileStoreEditorInput(ifs);
                }
            }
        }
    } catch (CoreException e) {
    // do nothing
    }
    return null;
}
Also used : AbstractSourceLookupDirector(org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) LocalFileStorage(org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage) IFileStore(org.eclipse.core.filesystem.IFileStore) IBinaryObject(org.eclipse.cdt.core.IBinaryParser.IBinaryObject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput)

Aggregations

AbstractSourceLookupDirector (org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector)3 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IBinaryObject (org.eclipse.cdt.core.IBinaryParser.IBinaryObject)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISourceLocator (org.eclipse.debug.core.model.ISourceLocator)1 ISourceContainer (org.eclipse.debug.core.sourcelookup.ISourceContainer)1 LocalFileStorage (org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage)1 IRegion (org.eclipse.jface.text.IRegion)1 IEditorPart (org.eclipse.ui.IEditorPart)1 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1