use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class LocalClassAwareTypeNames method doVisitParameterizedTypeReference.
@Override
protected void doVisitParameterizedTypeReference(ParameterizedTypeReference reference, StringBuilder param) {
JvmType type = reference.getType();
if (type instanceof JvmDeclaredType) {
boolean local = ((JvmDeclaredType) type).isLocal();
if (local) {
param.append("new ");
Iterables.getLast(reference.getSuperTypes()).accept(this, param);
param.append("(){}");
return;
}
}
super.doVisitParameterizedTypeReference(reference, param);
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class NestedTypesScope method doGetSingleElement.
@Override
protected IEObjectDescription doGetSingleElement(QualifiedName name, String firstSegment, int dollarIndex) {
JvmDeclaredType declaredType = innermost;
while (declaredType != null) {
IEObjectDescription result = doGetSingleElement(declaredType, name, firstSegment, dollarIndex);
if (result != null) {
return result;
}
declaredType = EcoreUtil2.getContainerOfType(declaredType.eContainer(), JvmDeclaredType.class);
}
if (dollarIndex > 0 && name.getSegmentCount() == 1) {
QualifiedName splitted = QualifiedName.create(Strings.split(name.getFirstSegment(), '$'));
IEObjectDescription result = doGetSingleElement(splitted, splitted.getFirstSegment(), -1);
if (result != null) {
return new AliasedEObjectDescription(name, result);
}
}
return null;
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class TypeScopeWithWildcardImports method doGetElements.
@Override
protected void doGetElements(JvmType type, List<IEObjectDescription> result) {
if (!(type instanceof JvmDeclaredType)) {
return;
}
JvmDeclaredType declaredType = (JvmDeclaredType) type;
String packageName = declaredType.getPackageName();
if (!Strings.isEmpty(packageName)) {
QualifiedName qualifiedPackageName = QualifiedName.create(Strings.split(packageName, '.'));
QualifiedName withDot = null;
String withDollar = null;
for (int i = 0; i < imports.length; i++) {
ImportNormalizer[] chunk = imports[i];
for (int j = 0; j < chunk.length; j++) {
ImportNormalizer normalizer = chunk[j];
QualifiedName namespacePrefix = normalizer.getImportedNamespacePrefix();
if (namespacePrefix.equals(qualifiedPackageName)) {
if (withDot == null) {
withDot = QualifiedName.create(Strings.split(type.getQualifiedName('.'), '.'));
withDollar = type.eContainer() instanceof JvmType ? type.getQualifiedName('$').substring(packageName.length() + 1) : null;
}
result.add(EObjectDescription.create(withDot.skipFirst(qualifiedPackageName.getSegmentCount()), type));
if (withDollar != null) {
result.add(EObjectDescription.create(withDollar, type));
}
}
}
}
}
if (parent != null) {
parent.doGetElements(type, result);
} else {
Iterables.addAll(result, typeScope.getElements(type));
}
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method inferTypeSceleton.
protected void inferTypeSceleton(final XtendTypeDeclaration declaration, final IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase, XtendFile xtendFile, List<Runnable> doLater, JvmDeclaredType containerSceleton) {
JvmDeclaredType inferredSceleton = doInferTypeSceleton(declaration, acceptor, preIndexingPhase, xtendFile, doLater);
if (inferredSceleton != null) {
setNameAndAssociate(xtendFile, declaration, inferredSceleton);
if (containerSceleton != null)
containerSceleton.getMembers().add(inferredSceleton);
acceptor.accept(inferredSceleton);
for (XtendMember member : declaration.getMembers()) {
if (member instanceof XtendTypeDeclaration)
inferTypeSceleton((XtendTypeDeclaration) member, acceptor, preIndexingPhase, xtendFile, doLater, inferredSceleton);
}
}
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class AbstractXtendCompilerTest method compile.
private ArrayList<CharSequence> compile(final XtendFile file, final CharSequence input, final GeneratorConfig config) {
try {
final ArrayList<CharSequence> results = CollectionLiterals.<CharSequence>newArrayList();
Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(file.eResource().getContents(), JvmDeclaredType.class);
for (final JvmDeclaredType inferredType : _filter) {
{
Assert.assertFalse(DisableCodeGenerationAdapter.isDisabled(inferredType));
CharSequence javaCode = this.generator.generateType(inferredType, config);
javaCode = this.postProcessor.postProcess(null, javaCode);
results.add(javaCode);
if ((this.useJavaCompiler && (input != null))) {
final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
it.getCompiledClass();
};
this.compilationTestHelper.compile(input, _function);
}
}
}
return results;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations