use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class PreferenceStoreWhitespaceInformationProvider method getLineSeparatorPreference.
protected String getLineSeparatorPreference(URI uri) {
if (uri.isPlatformResource()) {
IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(true)));
String delimiter = senseLineDelimiter(file);
if (delimiter != null)
return delimiter;
}
IProject project = null;
if (uri.isPlatformResource()) {
project = workspace.getRoot().getProject(uri.segment(1));
} else {
for (Pair<IStorage, IProject> storage : storage2UriMapper.getStorages(uri)) {
project = storage.getSecond();
break;
}
}
if (project != null) {
String result = getLineSeparatorPreference(new ProjectScope(project));
if (result != null)
return result;
}
@SuppressWarnings("all") String result = getLineSeparatorPreference(new InstanceScope());
if (result != null)
return result;
return System.getProperty("line.separator");
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class XbaseResourceForEditorInputFactoryTest method testValidationIsDisabled_03.
@Test
public void testValidationIsDisabled_03() throws Exception {
IProject project = AbstractXbaseUITestCase.createPluginProject("my.plugin.project");
IJavaProject jp = JavaCore.create(project);
boolean wasTested = false;
for (IPackageFragmentRoot pfr : jp.getAllPackageFragmentRoots()) {
if (pfr.isArchive()) {
for (Object o : pfr.getNonJavaResources()) {
if (o instanceof IStorage) {
assertTrue(isValidationDisabled((IStorage) o));
wasTested = true;
}
}
}
}
assertTrue(wasTested);
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class EclipseGeneratorConfigProvider method get.
@Override
public GeneratorConfig get(EObject context) {
GeneratorConfig result = new GeneratorConfig();
IProject project = null;
if (context.eResource() != null) {
Pair<IStorage, IProject> pair = Iterables.getFirst(storage2UriMapper.getStorages(context.eResource().getURI()), null);
if (pair != null) {
project = pair.getSecond();
}
}
xbaseBuilderPreferenceAccess.loadBuilderPreferences(result, project);
return result;
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class StorageAwareTrace method findStorage.
@Override
protected IStorage findStorage(SourceRelativeURI uri, IProject project) {
AbsoluteURI resolvePath = resolvePath(uri);
Iterable<Pair<IStorage, IProject>> allStorages = getStorage2uriMapper().getStorages(resolvePath.getURI());
for (Pair<IStorage, IProject> storage : allStorages) {
if (project.equals(storage.getSecond())) {
return storage.getFirst();
}
}
return null;
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class DerivedResourceMarkerBasedOpenerContributor method collectSourceFileOpeners.
@Override
public boolean collectSourceFileOpeners(IEditorPart editor, IAcceptor<FileOpener> acceptor) {
IStorage storage = getStorage(editor);
if (storage instanceof IResource) {
IResource resource = (IResource) storage;
try {
Set<URI> uris = Sets.newHashSet();
IMarker[] markers = derivedResourceMarkers.findDerivedResourceMarkers(resource);
for (IMarker marker : markers) {
String source = derivedResourceMarkers.getSource(marker);
if (source != null)
uris.add(URI.createURI(source));
}
for (URI uri : uris) for (Pair<IStorage, IProject> destination : storage2UriMapper.getStorages(uri)) acceptor.accept(createOpener(destination.getFirst()));
return true;
} catch (CoreException e) {
LOG.error(e.getMessage(), e);
}
}
return false;
}
Aggregations