use of org.eclipse.xtext.ui.generator.trace.IEclipseTrace in project xtext-eclipse by eclipse.
the class XbaseEditorInputRedirector method findOriginalSource.
public IEditorInput findOriginalSource(IEditorInput input) {
IFile resource = ResourceUtil.getFile(input);
if (resource == null) {
return input;
}
IEditorInput original = findOriginalSourceForOuputFolderCopy(input);
if (original != input) {
return original;
}
IEclipseTrace trace = traceInformation.getTraceToSource(resource);
if (trace == null) {
return input;
}
for (ILocationInEclipseResource candidate : trace.getAllAssociatedLocations()) {
if (languageInfo.equals(candidate.getLanguage())) {
IStorage storage = candidate.getPlatformResource();
if (storage != null) {
return EditorUtils.createEditorInput(storage);
}
}
}
return input;
}
use of org.eclipse.xtext.ui.generator.trace.IEclipseTrace in project xtext-eclipse by eclipse.
the class JavaBreakPointProvider method getJavaTrace.
private IEclipseTrace getJavaTrace(final IJavaStratumLineBreakpoint breakpoint) throws CoreException {
IEclipseTrace result;
IClassFile classFile = getClassFile(breakpoint);
if (classFile == null) {
URI uri = URI.createURI((String) breakpoint.getMarker().getAttribute(StratumBreakpointAdapterFactory.ORG_ECLIPSE_XTEXT_XBASE_SOURCE_URI));
Pair<IStorage, IProject> storage = Iterables.getFirst(storage2UriMapper.getStorages(uri), null);
if (storage == null)
return null;
result = traceForStorageProvider.getTraceToTarget(storage.getFirst());
} else {
result = traceForTypeRootProvider.getTraceToSource(classFile);
}
return result;
}
use of org.eclipse.xtext.ui.generator.trace.IEclipseTrace in project xtext-eclipse by eclipse.
the class JavaBreakPointProvider method getJavaLocation.
private ILocationInEclipseResource getJavaLocation(final IJavaStratumLineBreakpoint breakpoint) throws CoreException {
IEclipseTrace javaTrace = getJavaTrace(breakpoint);
if (javaTrace == null)
return null;
TextRegion textRegion = new TextRegion(breakpoint.getCharStart(), 0);
ILocationInEclipseResource javaLocation = javaTrace.getBestAssociatedLocation(textRegion);
if (javaLocation == null)
return null;
return javaLocation;
}
use of org.eclipse.xtext.ui.generator.trace.IEclipseTrace in project xtext-eclipse by eclipse.
the class JavaEditorInputMatcher method matches.
@Override
public boolean matches(IEditorReference editorRef, IEditorInput inputToCheck) {
try {
if (!editorInfo.getEditorId().equals(editorRef.getId())) {
return false;
}
IEditorInput newInput = editorInputRedirector.findOriginalSourceForOuputFolderCopy(inputToCheck);
IEditorInput currentInput = editorRef.getEditorInput();
if (newInput.equals(currentInput)) {
if (decisions.decideAccordingToCaller() != Decision.FORCE_JAVA) {
ITypeRoot newTypeRoot = editorInputRedirector.getTypeRoot(newInput);
if (newTypeRoot != null) {
IEditorPart existingEditor = editorRef.getEditor(true);
if (existingEditor instanceof XbaseEditor) {
((XbaseEditor) existingEditor).markNextSelectionAsJavaOffset(newTypeRoot);
}
}
}
return true;
}
if (decisions.decideAccordingToCaller() == Decision.FORCE_JAVA)
return false;
ITypeRoot newTypeRoot = editorInputRedirector.getTypeRoot(newInput);
if (newTypeRoot == null) {
return false;
}
IResource currentResource = ResourceUtil.getResource(currentInput);
if (currentResource == null) {
return false;
}
IEclipseTrace traceToSource = traceInformation.getTraceToSource(newTypeRoot);
if (traceToSource == null) {
return false;
}
if (isCurrentResource(currentResource, traceToSource)) {
IEditorPart existingEditor = editorRef.getEditor(true);
if (existingEditor instanceof XbaseEditor) {
((XbaseEditor) existingEditor).markNextSelectionAsJavaOffset(newTypeRoot);
return true;
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
Aggregations