use of org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider in project xtext-xtend by eclipse.
the class TypeBasedSimpleBenchmark method setUp.
@Override
protected void setUp() throws Exception {
Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = new XtextResourceSet();
ClassLoader loader = getClass().getClassLoader();
resourceSet.setClasspathURIContext(loader);
typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
owner = new StandardTypeReferenceOwner(services, resourceSet);
}
use of org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider in project xtext-xtend by eclipse.
the class XtendBatchCompiler method internalInstallJvmTypeProvider.
/**
* Performs the actual installation of the JvmTypeProvider.
*/
private void internalInstallJvmTypeProvider(ResourceSet resourceSet, File tmpClassDirectory, boolean skipIndexLookup) {
Iterable<String> classPathEntries = concat(asList(tmpClassDirectory.toString()), getClassPathEntries(), getSourcePathDirectories());
classPathEntries = filter(classPathEntries, new Predicate<String>() {
@Override
public boolean apply(String input) {
return !Strings.isEmpty(input.trim());
}
});
Iterable<File> classpath = transform(classPathEntries, TO_FILE);
if (log.isDebugEnabled()) {
log.debug("classpath used for Xtend compilation : " + classpath);
}
ClassLoader parentClassLoader;
if (useCurrentClassLoaderAsParent) {
parentClassLoader = currentClassLoader;
} else {
if (isEmpty(bootClassPath)) {
parentClassLoader = ClassLoader.getSystemClassLoader().getParent();
} else {
Iterable<File> bootClassPathEntries = transform(getBootClassPathEntries(), TO_FILE);
parentClassLoader = new AlternateJdkLoader(bootClassPathEntries);
}
}
jvmTypesClassLoader = createClassLoader(classpath, parentClassLoader);
new ClasspathTypeProvider(jvmTypesClassLoader, resourceSet, skipIndexLookup ? null : indexedJvmTypeAccess, null);
((XtextResourceSet) resourceSet).setClasspathURIContext(jvmTypesClassLoader);
// for annotation processing we need to have the compiler's classpath as a parent.
annotationProcessingClassLoader = createClassLoader(classpath, currentClassLoader);
resourceSet.eAdapters().add(new ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter(annotationProcessingClassLoader));
}
use of org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider in project xtext-xtend by eclipse.
the class ConvertToArrayBenchmark method setUp.
@Override
protected void setUp() throws Exception {
Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = new XtextResourceSet();
ClassLoader loader = getClass().getClassLoader();
resourceSet.setClasspathURIContext(loader);
ClasspathTypeProvider typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resourceSet);
typeReference = type.getReference(typeProvider, owner);
EcoreUtil.resolveAll(resourceSet);
}
use of org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider in project xtext-xtend by eclipse.
the class ParameterizedTypeReferenceBenchmark method setUp.
@Override
protected void setUp() throws Exception {
Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = new XtextResourceSet();
ClassLoader loader = getClass().getClassLoader();
resourceSet.setClasspathURIContext(loader);
ClasspathTypeProvider typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resourceSet);
typeReference = type.getReference(typeProvider, owner);
EcoreUtil.resolveAll(resourceSet);
}
use of org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider in project xtext-xtend by eclipse.
the class IndexingTest method doTestResourceDescriptionWithoutGetContents.
private void doTestResourceDescriptionWithoutGetContents(final String input) throws IOException {
XtextResourceSet resourceSet = getResourceSet();
new ClasspathTypeProvider(classLoader, resourceSet, null, null);
final Wrapper<Boolean> wrapper = Wrapper.wrap(Boolean.FALSE);
for (int i = 0; i < 10; i++) {
DerivedStateAwareResource resource = (DerivedStateAwareResource) resourceSet.createResource(URI.createURI("Dummy" + i + ".xtend"));
resource.setDerivedStateComputer(new IDerivedStateComputer() {
@Override
public void installDerivedState(DerivedStateAwareResource resource, boolean preLinkingPhase) {
if (!preLinkingPhase) {
wrapper.set(Boolean.TRUE);
}
derivedStateComputer.installDerivedState(resource, preLinkingPhase);
}
@Override
public void discardDerivedState(DerivedStateAwareResource resource) {
derivedStateComputer.discardDerivedState(resource);
}
});
String actualInput = input;
if (i != 0) {
actualInput = "import C" + (i + 1) + " " + actualInput;
actualInput = "import C" + (i - 1) + " " + actualInput;
}
actualInput = String.format(actualInput, i, i + 1);
resource.load(new StringInputStream(actualInput), null);
}
for (int i = 0; i < 10; i++) {
Resource resource = resourceSet.getResources().get(i);
for (IEObjectDescription description : resourceDescriptionManager.getResourceDescription(resource).getExportedObjects()) {
description.getEObjectOrProxy();
}
}
assertFalse(wrapper.get());
}
Aggregations