use of org.eclipse.xtext.testlanguages.fileAware.fileAware.Import in project xtext-core by eclipse.
the class FileAwareTestLanguageFormatter method _format.
protected void _format(final PackageDeclaration pkg, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.setNewLines(2);
};
document.append(this.textRegionExtensions.regionFor(pkg).feature(FileAwarePackage.Literals.PACKAGE_DECLARATION__NAME), _function);
EList<Import> _imports = pkg.getImports();
for (final Import imp : _imports) {
{
document.<Import>format(imp);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
int _xifexpression = (int) 0;
Import _last = IterableExtensions.<Import>last(pkg.getImports());
boolean _tripleEquals = (imp == _last);
if (_tripleEquals) {
_xifexpression = 2;
} else {
_xifexpression = 1;
}
it.setNewLines(_xifexpression);
};
document.<Import>append(imp, _function_1);
}
}
EList<Element> _contents = pkg.getContents();
for (final Element element : _contents) {
document.<Element>format(element);
}
}
use of org.eclipse.xtext.testlanguages.fileAware.fileAware.Import in project xtext-core by eclipse.
the class FileAwareTestLanguageImportScopeProvider method internalGetImportedNamespaceResolvers.
@Override
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, final boolean ignoreCase) {
final List<ImportNormalizer> resolvers = super.internalGetImportedNamespaceResolvers(context, ignoreCase);
if ((context instanceof PackageDeclaration)) {
QualifiedName _qualifiedName = this.getQualifiedNameConverter().toQualifiedName(((PackageDeclaration) context).getName());
ImportNormalizer _importNormalizer = new ImportNormalizer(_qualifiedName, true, false);
resolvers.add(_importNormalizer);
EList<Import> _imports = ((PackageDeclaration) context).getImports();
for (final Import imp : _imports) {
{
final QualifiedName name = this.getImportedNamespace(imp);
ImportNormalizer _importNormalizer_1 = new ImportNormalizer(name, false, false);
resolvers.add(_importNormalizer_1);
}
}
}
return resolvers;
}
use of org.eclipse.xtext.testlanguages.fileAware.fileAware.Import in project xtext-core by eclipse.
the class FileAwareTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == FileAwarePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case FileAwarePackage.ELEMENT:
sequence_Element(context, (Element) semanticObject);
return;
case FileAwarePackage.IMPORT:
sequence_Import(context, (Import) semanticObject);
return;
case FileAwarePackage.PACKAGE_DECLARATION:
sequence_PackageDeclaration(context, (PackageDeclaration) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.testlanguages.fileAware.fileAware.Import in project xtext-core by eclipse.
the class FileAwareTestLanguageReferenceUpdater method update.
@Override
public void update(final IReferenceUpdaterContext context) {
super.update(context);
EObject _head = IterableExtensions.<EObject>head(context.getResource().getContents());
final PackageDeclaration pkg = ((PackageDeclaration) _head);
final QualifiedName pkgName = this.names.getFullyQualifiedName(pkg);
final Function1<Import, Element> _function = (Import it) -> {
return it.getElement();
};
final Map<Element, Import> actual = IterableExtensions.<Element, Import>toMap(pkg.getImports(), _function);
final Function1<IUpdatableReference, EObject> _function_1 = (IUpdatableReference it) -> {
return it.getTargetEObject();
};
final Iterable<Element> targets = Iterables.<Element>filter(ListExtensions.<IUpdatableReference, EObject>map(context.getUpdatableReferences(), _function_1), Element.class);
final Function1<Element, Boolean> _function_2 = (Element it) -> {
boolean _startsWith = this.names.getFullyQualifiedName(it).startsWith(pkgName);
return Boolean.valueOf((!_startsWith));
};
final Set<Element> expected = IterableExtensions.<Element>toSet(IterableExtensions.<Element>filter(targets, _function_2));
final Function1<Element, Boolean> _function_3 = (Element it) -> {
boolean _containsKey = actual.containsKey(it);
return Boolean.valueOf((!_containsKey));
};
final Set<Element> toAdd = IterableExtensions.<Element>toSet(IterableExtensions.<Element>filter(expected, _function_3));
final Function2<Element, Import, Boolean> _function_4 = (Element $0, Import $1) -> {
boolean _contains = expected.contains($0);
return Boolean.valueOf((!_contains));
};
final Map<Element, Import> toDelete = MapExtensions.<Element, Import>filter(actual, _function_4);
if (((!toAdd.isEmpty()) || (!toDelete.isEmpty()))) {
final Runnable _function_5 = () -> {
final Consumer<Import> _function_6 = (Import it) -> {
EcoreUtil.remove(it);
};
toDelete.values().forEach(_function_6);
final Consumer<Element> _function_7 = (Element e) -> {
EList<Import> _imports = pkg.getImports();
Import _createImport = this._fileAwareFactory.createImport();
final Procedure1<Import> _function_8 = (Import it) -> {
it.setElement(e);
};
Import _doubleArrow = ObjectExtensions.<Import>operator_doubleArrow(_createImport, _function_8);
_imports.add(_doubleArrow);
};
toAdd.forEach(_function_7);
};
context.modifyModel(_function_5);
}
}
Aggregations