use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.
the class TestLanguageGenerator method doGenerate.
@Override
public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
String _scheme = fsa.getURI("").scheme();
boolean _equals = Objects.equal(_scheme, "inmemory");
if (_equals) {
return;
}
List<TypeDeclaration> _list = IteratorExtensions.<TypeDeclaration>toList(Iterators.<TypeDeclaration>filter(resource.getAllContents(), TypeDeclaration.class));
for (final TypeDeclaration type : _list) {
String _name = type.getName();
String _plus = (_name + ".java");
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class ");
String _name_1 = type.getName();
_builder.append(_name_1);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.class);
for (final Property p : _filter) {
_builder.append("\t");
_builder.append("private ");
String _java = this.toJava(p.getType());
_builder.append(_java, "\t");
_builder.append(" ");
String _name_2 = p.getName();
_builder.append(_name_2, "\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public void set");
String _firstUpper = StringExtensions.toFirstUpper(p.getName());
_builder.append(_firstUpper, "\t");
_builder.append("(");
String _java_1 = this.toJava(p.getType());
_builder.append(_java_1, "\t");
_builder.append(" ");
String _name_3 = p.getName();
_builder.append(_name_3, "\t");
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("this.");
String _name_4 = p.getName();
_builder.append(_name_4, "\t\t");
_builder.append(" = ");
String _name_5 = p.getName();
_builder.append(_name_5, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _java_2 = this.toJava(p.getType());
_builder.append(_java_2, "\t");
_builder.append(" get");
String _firstUpper_1 = StringExtensions.toFirstUpper(p.getName());
_builder.append(_firstUpper_1, "\t");
_builder.append("() {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return this.");
String _name_6 = p.getName();
_builder.append(_name_6, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
fsa.generateFile(_plus, _builder);
}
}
use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.
the class ColoringServiceImpl method getColoring.
@Override
public List<? extends ColoringInformation> getColoring(final XtextResource resource, final Document document) {
if ((resource == null)) {
return CollectionLiterals.<ColoringInformation>emptyList();
}
final ImmutableList.Builder<ColoringInformation> builder = ImmutableList.<ColoringInformation>builder();
final Procedure1<Object> _function = (Object it) -> {
List<INode> _xifexpression = null;
if ((it instanceof Property)) {
_xifexpression = NodeModelUtils.findNodesForFeature(((EObject) it), TestLanguagePackage.Literals.MEMBER__NAME);
} else {
List<INode> _xifexpression_1 = null;
if ((it instanceof Operation)) {
_xifexpression_1 = NodeModelUtils.findNodesForFeature(((EObject) it), TestLanguagePackage.Literals.MEMBER__NAME);
} else {
_xifexpression_1 = CollectionLiterals.<INode>emptyList();
}
_xifexpression = _xifexpression_1;
}
final List<INode> nodes = _xifexpression;
final Consumer<INode> _function_1 = (INode it_1) -> {
final int start = it_1.getOffset();
int _offset = it_1.getOffset();
int _length = it_1.getLength();
final int end = (_offset + _length);
Position _position = document.getPosition(start);
Position _position_1 = document.getPosition(end);
final Range range = new Range(_position, _position_1);
ColoringInformation _coloringInformation = new ColoringInformation(range, ColoringServiceImpl.STYLE_IDS);
builder.add(_coloringInformation);
};
nodes.forEach(_function_1);
};
IteratorExtensions.<Object>forEach(EcoreUtil.<Object>getAllContents(resource, true), _function);
return builder.build();
}
use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.
the class TestLanguageFormatter method _format.
protected void _format(final TypeDeclaration type, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(document.prepend(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_1), _function_2);
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.<ISemanticRegion, ISemanticRegion>interior(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_3);
Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.class);
for (final Property property : _filter) {
document.<Property>format(property);
}
}
use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.
the class TestLanguageSemanticSequencer 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 == TestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case TestLanguagePackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case TestLanguagePackage.OPERATION:
sequence_Operation(context, (Operation) semanticObject);
return;
case TestLanguagePackage.OPERATION_CALL:
sequence_OperationCall(context, (OperationCall) semanticObject);
return;
case TestLanguagePackage.PACKAGE_DECLARATION:
sequence_PackageDeclaration(context, (PackageDeclaration) semanticObject);
return;
case TestLanguagePackage.PARAMETER:
sequence_Parameter(context, (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Parameter) semanticObject);
return;
case TestLanguagePackage.PRIMITIVE_TYPE:
if (rule == grammarAccess.getPrimitiveTypeRule()) {
sequence_PrimitiveType(context, (PrimitiveType) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRule()) {
sequence_PrimitiveType_Type(context, (PrimitiveType) semanticObject);
return;
} else
break;
case TestLanguagePackage.PROPERTY:
sequence_Property(context, (Property) semanticObject);
return;
case TestLanguagePackage.TYPE_DECLARATION:
sequence_TypeDeclaration(context, (TypeDeclaration) semanticObject);
return;
case TestLanguagePackage.TYPE_REFERENCE:
if (rule == grammarAccess.getTypeReferenceRule()) {
sequence_TypeReference(context, (TypeReference) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRule()) {
sequence_Type_TypeReference(context, (TypeReference) semanticObject);
return;
} else
break;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations