use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class XtendBatchCompiler method getXtendFile.
/* @Nullable */
protected XtendFile getXtendFile(Resource resource) {
XtextResource xtextResource = (XtextResource) resource;
IParseResult parseResult = xtextResource.getParseResult();
if (parseResult != null) {
EObject model = parseResult.getRootASTElement();
if (model instanceof XtendFile) {
XtendFile xtendFile = (XtendFile) model;
return xtendFile;
}
}
return null;
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class XtendImportsConfiguration method getLocallyDefinedTypes.
@Override
public Iterable<JvmDeclaredType> getLocallyDefinedTypes(XtextResource resource) {
XtendFile xtendFile = getXtendFile(resource);
if (xtendFile == null)
return emptyList();
final List<JvmDeclaredType> locallyDefinedTypes = newArrayList();
for (XtendTypeDeclaration xtendType : xtendFile.getXtendTypes()) {
for (EObject inferredElement : associations.getJvmElements(xtendType)) {
if (inferredElement instanceof JvmDeclaredType) {
JvmDeclaredType declaredType = (JvmDeclaredType) inferredElement;
locallyDefinedTypes.add(declaredType);
addInnerTypes(declaredType, new IAcceptor<JvmDeclaredType>() {
@Override
public void accept(JvmDeclaredType t) {
locallyDefinedTypes.add(t);
}
});
}
}
}
return locallyDefinedTypes;
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method infer.
@Override
public void infer(/* @Nullable */
EObject object, final /* @NonNull */
IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase) {
if (!(object instanceof XtendFile))
return;
final Set<JvmDeclaredType> types = new LinkedHashSet<JvmDeclaredType>();
final IJvmDeclaredTypeAcceptor wrapper = new IJvmDeclaredTypeAcceptor() {
@SuppressWarnings("deprecation")
@Override
public <T extends JvmDeclaredType> IPostIndexingInitializing<T> accept(T type) {
types.add(type);
return acceptor.accept(type);
}
@Override
public <T extends JvmDeclaredType> void accept(T type, Procedure1<? super T> lateInitialization) {
types.add(type);
acceptor.accept(type, lateInitialization);
}
};
final XtendFile xtendFile = (XtendFile) object;
generatorConfig = generatorConfigProvider.get(xtendFile);
final List<Runnable> doLater = newArrayList();
for (final XtendTypeDeclaration declaration : xtendFile.getXtendTypes()) {
inferTypeSceleton(declaration, wrapper, preIndexingPhase, xtendFile, doLater, null);
}
ActiveAnnotationContexts contexts = null;
BatchLinkableResource resource = (BatchLinkableResource) xtendFile.eResource();
try {
compilerPhases.setIndexing(xtendFile, true);
try {
contexts = contextProvider.computeContext(xtendFile);
} catch (Throwable t) {
operationCanceledManager.propagateAsErrorIfCancelException(t);
logger.error("Couldn't create annotation contexts", t);
return;
}
try {
contexts.before(ActiveAnnotationContexts.AnnotationCallback.INDEXING);
for (ActiveAnnotationContext ctx : contexts.getContexts().values()) {
try {
annotationProcessor.indexingPhase(ctx, wrapper, CancelIndicator.NullImpl);
} catch (Throwable t) {
operationCanceledManager.propagateAsErrorIfCancelException(t);
ctx.handleProcessingError(xtendFile.eResource(), t);
}
}
} finally {
contexts.after(ActiveAnnotationContexts.AnnotationCallback.INDEXING);
}
} finally {
compilerPhases.setIndexing(xtendFile, false);
resource.getCache().clear(resource);
}
if (!preIndexingPhase) {
final ActiveAnnotationContexts finalContexts = contexts;
Runnable lateInit = new Runnable() {
@Override
public void run() {
for (Runnable runnable : doLater) {
runnable.run();
}
try {
finalContexts.before(ActiveAnnotationContexts.AnnotationCallback.INFERENCE);
for (ActiveAnnotationContext ctx : finalContexts.getContexts().values()) {
try {
annotationProcessor.inferencePhase(ctx, CancelIndicator.NullImpl);
} catch (Throwable t) {
operationCanceledManager.propagateAsErrorIfCancelException(t);
ctx.handleProcessingError(xtendFile.eResource(), t);
}
}
} finally {
finalContexts.after(ActiveAnnotationContexts.AnnotationCallback.INFERENCE);
}
}
};
resource.addJvmMemberInitializer(lateInit);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class OverrideHelperTest method checkFindOverriddenOperation_03.
@Test
public void checkFindOverriddenOperation_03() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("import java.util.Map");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo implements Bar {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override bar(Map<?, ?> map) {}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("interface Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void bar(Map<?, ?> map)");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.file(_builder.toString());
EObject _primaryJvmElement = this._iJvmModelAssociations.getPrimaryJvmElement(IterableExtensions.<XtendFunction>head(Iterables.<XtendFunction>filter(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers(), XtendFunction.class)));
final JvmOperation operation = ((JvmOperation) _primaryJvmElement);
Assert.assertNotNull(this.overrideHelper.findOverriddenOperation(operation));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class AmbiguityBug427352Test method assertUnambiguous.
@Override
public void assertUnambiguous(final CharSequence contents) {
final XtendFile file = this.getParsedXtendFile(contents);
this._validationTestHelper.assertNoErrors(file, IssueCodes.AMBIGUOUS_FEATURE_CALL);
}
Aggregations