use of org.eclipse.xtext.common.types.JvmExecutable in project xtext-xtend by eclipse.
the class XtendHoverSerializer method computeUnsugaredExpression.
public String computeUnsugaredExpression(EObject object) {
if (object instanceof XAbstractFeatureCall) {
StringBuilder stringBuilder = new StringBuilder();
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) object;
JvmIdentifiableElement feature = featureCall.getFeature();
if (feature != null && !feature.eIsProxy()) {
// Static extensions which are no expliciteOperationCalls
if (featureCall instanceof XMemberFeatureCall && feature instanceof JvmOperation && !((XMemberFeatureCall) featureCall).isExplicitOperationCall()) {
JvmOperation jvmOperation = (JvmOperation) feature;
if (jvmOperation.isStatic()) {
return stringBuilder.append(getStaticCallDesugaredVersion(featureCall, jvmOperation)).toString();
}
}
// Static calls with implicit receiver or implicit first argument
if (featureCall.getImplicitReceiver() != null || featureCall.getImplicitFirstArgument() != null) {
if (featureCall.isStatic()) {
return stringBuilder.append(getStaticCallDesugaredVersion(featureCall, (JvmMember) feature)).toString();
}
XExpression receiver = featureCall.getActualReceiver();
if (receiver instanceof XMemberFeatureCall) {
stringBuilder.append(THIS).append(DELIMITER);
stringBuilder.append(((XMemberFeatureCall) receiver).getFeature().getSimpleName()).append(DELIMITER);
} else if (receiver instanceof XAbstractFeatureCall) {
JvmIdentifiableElement receiverFeature = ((XAbstractFeatureCall) receiver).getFeature();
if (receiverFeature == feature.eContainer()) {
stringBuilder.append(THIS).append(DELIMITER);
} else {
stringBuilder.append(receiverFeature.getSimpleName()).append(DELIMITER);
}
}
stringBuilder.append(feature.getSimpleName());
if (feature instanceof JvmExecutable)
stringBuilder.append(computeArguments(featureCall));
return stringBuilder.toString();
}
}
}
return "";
}
use of org.eclipse.xtext.common.types.JvmExecutable in project xtext-xtend by eclipse.
the class CreateMemberQuickfixes method addQuickfixes.
@Override
public void addQuickfixes(Issue issue, IssueResolutionAcceptor issueResolutionAcceptor, IXtextDocument xtextDocument, XtextResource resource, EObject referenceOwner, EReference unresolvedReference) throws Exception {
if (referenceOwner instanceof XAbstractFeatureCall) {
XAbstractFeatureCall call = (XAbstractFeatureCall) referenceOwner;
String newMemberName = (issue.getData() != null && issue.getData().length > 0) ? issue.getData()[0] : null;
if (newMemberName != null) {
if (call instanceof XMemberFeatureCall) {
if (!call.isExplicitOperationCallOrBuilderSyntax()) {
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newGetterQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
}
newMethodQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
} else if (call instanceof XFeatureCall) {
if (!call.isExplicitOperationCallOrBuilderSyntax()) {
if (logicalContainerProvider.getNearestLogicalContainer(call) instanceof JvmExecutable)
newLocalVariableQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newGetterQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
}
newMethodQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
} else if (call instanceof XAssignment) {
newSetterQuickfix(issue, issueResolutionAcceptor, newMemberName, call);
XAssignment assigment = (XAssignment) call;
if (assigment.getAssignable() == null) {
newLocalVariableQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
} else if (isThis(assigment)) {
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
}
}
}
if (call.isOperation()) {
JvmIdentifiableElement feature = call.getFeature();
if (feature.eIsProxy()) {
String operatorMethodName = getOperatorMethodName(call);
if (operatorMethodName != null)
newMethodQuickfixes(operatorMethodName, call, issue, issueResolutionAcceptor);
}
}
if (call instanceof XFeatureCall && call.getFeature() instanceof JvmConstructor) {
newConstructorQuickfix(issue, issueResolutionAcceptor, (XFeatureCall) call);
}
}
if (referenceOwner instanceof XConstructorCall) {
newConstructorQuickfix(issue, issueResolutionAcceptor, (XConstructorCall) referenceOwner);
}
}
use of org.eclipse.xtext.common.types.JvmExecutable in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testXtendField_00.
@Test
public void testXtendField_00() throws Exception {
XtendFile xtendFile = file("class Foo { @Inject String string }");
JvmGenericType type = getInferredType(xtendFile);
Iterable<JvmField> iterable = type.getDeclaredFields();
JvmField next = iterable.iterator().next();
assertEquals("string", next.getSimpleName());
assertEquals(JvmVisibility.PRIVATE, next.getVisibility());
assertEquals("java.lang.String", next.getType().getIdentifier());
for (JvmMember member : type.getMembers()) {
if (member instanceof JvmExecutable) {
assertEquals(JvmVisibility.PUBLIC, member.getVisibility());
} else {
assertEquals(JvmVisibility.PRIVATE, member.getVisibility());
}
}
}
Aggregations