protected IScope doGetTypeScope(XMemberFeatureCall call, JvmType type) { if (call.isPackageFragment()) { if (type instanceof JvmDeclaredType) { int segmentIndex = countSegments(call); String packageName = ((JvmDeclaredType) type).getPackageName(); List<String> splitted = Strings.split(packageName, '.'); String segment = splitted.get(segmentIndex); return new SingletonScope(EObjectDescription.create(segment, type), IScope.NULLSCOPE); } return IScope.NULLSCOPE; } else { if (type instanceof JvmDeclaredType && ((JvmDeclaredType) type).getDeclaringType() == null) { return new SingletonScope( EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE); } else { XAbstractFeatureCall target = (XAbstractFeatureCall) call.getMemberCallTarget(); if (target.isPackageFragment()) { String qualifiedName = type.getQualifiedName(); int dot = qualifiedName.lastIndexOf('.'); String simpleName = qualifiedName.substring(dot + 1); return new SingletonScope(EObjectDescription.create(simpleName, type), IScope.NULLSCOPE); } else { return new SingletonScope( EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE); } } } }
private int countSegments(XMemberFeatureCall call) { int result = 1; while (call.getMemberCallTarget() instanceof XMemberFeatureCall) { call = (XMemberFeatureCall) call.getMemberCallTarget(); result++; } return result; }
protected String _case( JvmField input, XMemberFeatureCall context, EReference ref, JvmFeatureDescription jvmFeatureDescription) { if (!context.getMemberCallArguments().isEmpty()) return INVALID_NUMBER_OF_ARGUMENTS; if (context.isExplicitOperationCall()) return FIELD_ACCESS_WITH_PARENTHESES; if (input.isStatic()) return INSTANCE_ACCESS_TO_STATIC_MEMBER; return null; }
@Override public void acceptForLoop( @NonNull JvmFormalParameter parameter, @NonNull XExpression expression) { if (!ignore()) { XMemberFeatureCall featureCall = (XMemberFeatureCall) expression; XStringLiteral receiver = (XStringLiteral) featureCall.getMemberCallTarget(); int length = receiver.getValue().length(); if (length != 0) forLoopStack.push(length * -1); else forLoopStack.push(null); } }
@Override protected ITextRegion getLocationOfContainmentReference( EObject owner, EReference reference, int indexInList, RegionDescription query) { if (owner instanceof XMemberFeatureCall && reference == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) { XMemberFeatureCall casted = (XMemberFeatureCall) owner; if (casted.isExplicitStatic() || casted.isStaticWithDeclaringType()) { XExpression target = ((XMemberFeatureCall) owner).getMemberCallTarget(); return getTextRegion(target, query); } } return super.getLocationOfContainmentReference(owner, reference, indexInList, query); }
protected String _case( JvmOperation input, XMemberFeatureCall context, EReference ref, JvmFeatureDescription jvmFeatureDescription) { if (input.isStatic() && input.getParameters().size() == context.getMemberCallArguments().size()) { return INSTANCE_ACCESS_TO_STATIC_MEMBER; } else { return checkJvmOperation( input, context, context.isExplicitOperationCall(), jvmFeatureDescription, context.getMemberCallArguments()); } }