use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation in project xtext-core by eclipse.
the class OperationCallImpl method setOperation.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOperation(Operation newOperation) {
Operation oldOperation = operation;
operation = newOperation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TestLanguagePackage.OPERATION_CALL__OPERATION, oldOperation, operation));
}
use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation 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.Operation in project xtext-core by eclipse.
the class SignatureHelpServiceImpl method getSignatureHelp.
private SignatureHelp getSignatureHelp(final OperationCall call, final String operationName, final int offset) {
final List<Integer> separatorIndices = CollectionLiterals.<Integer>newArrayList();
BidiIterable<INode> _children = NodeModelUtils.getNode(call).getChildren();
for (final INode node : _children) {
{
final String text = node.getText();
if ((Objects.equal(SignatureHelpServiceImpl.OPENING_CHAR, text) && (node.getOffset() >= offset))) {
return ISignatureHelpService.EMPTY;
} else {
if ((Objects.equal(SignatureHelpServiceImpl.CLOSING_CHAR, text) && (node.getOffset() < offset))) {
return ISignatureHelpService.EMPTY;
} else {
boolean _equals = Objects.equal(SignatureHelpServiceImpl.SEPARATOR_CHAR, text);
if (_equals) {
separatorIndices.add(Integer.valueOf(node.getOffset()));
}
}
}
}
}
final int paramCount = call.getParams().size();
final int separatorCount = separatorIndices.size();
if ((((separatorCount + 1) == paramCount) || (separatorCount == paramCount))) {
final List<INode> paramNodes = NodeModelUtils.findNodesForFeature(call, this._testLanguagePackage.getOperation_Params());
for (int i = 0; (i < separatorCount); i++) {
{
final INode paramNode = paramNodes.get(i);
int _offset = paramNode.getOffset();
int _length = paramNode.getLength();
int _plus = (_offset + _length);
Integer _get = separatorIndices.get(i);
boolean _greaterThan = (_plus > (_get).intValue());
if (_greaterThan) {
return ISignatureHelpService.EMPTY;
}
}
}
} else {
return ISignatureHelpService.EMPTY;
}
int _xifexpression = (int) 0;
if ((paramCount == 0)) {
_xifexpression = 0;
} else {
int _xifexpression_1 = (int) 0;
boolean _contains = separatorIndices.contains(Integer.valueOf(offset));
if (_contains) {
int _indexOf = separatorIndices.indexOf(Integer.valueOf(offset));
_xifexpression_1 = (_indexOf + 2);
} else {
int _binarySearch = Arrays.binarySearch(((int[]) Conversions.unwrapArray(separatorIndices, int.class)), offset);
_xifexpression_1 = (-_binarySearch);
}
_xifexpression = _xifexpression_1;
}
final int currentParameter = _xifexpression;
final Function1<Operation, Boolean> _function = (Operation it) -> {
int _size = it.getParams().size();
return Boolean.valueOf((currentParameter <= _size));
};
final Iterable<Operation> visibleOperations = IterableExtensions.<Operation>filter(this.getVisibleOperationsWithName(call, operationName), _function);
int _xifexpression_2 = (int) 0;
boolean _contains_1 = separatorIndices.contains(Integer.valueOf(offset));
if (_contains_1) {
_xifexpression_2 = 2;
} else {
_xifexpression_2 = 1;
}
final int paramOffset = _xifexpression_2;
Integer _xifexpression_3 = null;
if ((paramCount == 0)) {
Integer _xblockexpression = null;
{
final Function1<Operation, Integer> _function_1 = (Operation it) -> {
return Integer.valueOf(it.getParams().size());
};
final Iterable<Integer> paramSize = IterableExtensions.<Operation, Integer>map(visibleOperations, _function_1);
Integer _xifexpression_4 = null;
if (((!IterableExtensions.<Integer>exists(paramSize, ((Function1<Integer, Boolean>) (Integer it) -> {
return Boolean.valueOf(((it).intValue() == 0));
}))) && IterableExtensions.<Operation>exists(visibleOperations, ((Function1<Operation, Boolean>) (Operation it) -> {
boolean _isEmpty = it.getParams().isEmpty();
return Boolean.valueOf((!_isEmpty));
})))) {
_xifexpression_4 = Integer.valueOf(0);
} else {
_xifexpression_4 = null;
}
_xblockexpression = _xifexpression_4;
}
_xifexpression_3 = _xblockexpression;
} else {
_xifexpression_3 = Integer.valueOf((currentParameter - paramOffset));
}
final Integer activeParamIndex = _xifexpression_3;
SignatureHelp _signatureHelp = new SignatureHelp();
final Procedure1<SignatureHelp> _function_1 = (SignatureHelp it) -> {
it.setActiveParameter(activeParamIndex);
it.setActiveSignature(Integer.valueOf(0));
final Function1<Operation, SignatureInformation> _function_2 = (Operation operation) -> {
SignatureInformation _signatureInformation = new SignatureInformation();
final Procedure1<SignatureInformation> _function_3 = (SignatureInformation it_1) -> {
it_1.setLabel(this.getLabel(operation));
final Function1<Parameter, ParameterInformation> _function_4 = (Parameter param) -> {
ParameterInformation _parameterInformation = new ParameterInformation();
final Procedure1<ParameterInformation> _function_5 = (ParameterInformation it_2) -> {
StringConcatenation _builder = new StringConcatenation();
String _name = param.getName();
_builder.append(_name);
_builder.append(": ");
String _label = this.getLabel(param.getType());
_builder.append(_label);
it_2.setLabel(_builder.toString());
};
return ObjectExtensions.<ParameterInformation>operator_doubleArrow(_parameterInformation, _function_5);
};
it_1.setParameters(ListExtensions.<Parameter, ParameterInformation>map(operation.getParams(), _function_4));
};
return ObjectExtensions.<SignatureInformation>operator_doubleArrow(_signatureInformation, _function_3);
};
it.setSignatures(IterableExtensions.<SignatureInformation>sortWith(IterableExtensions.<SignatureInformation>toList(IterableExtensions.<Operation, SignatureInformation>map(visibleOperations, _function_2)), SignatureHelpServiceImpl.SIGNATURE_INFO_ORDERING));
};
return ObjectExtensions.<SignatureHelp>operator_doubleArrow(_signatureHelp, _function_1);
}
use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation 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.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