Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.MemberReference


    @Override
    public Void visitMemberReferenceExpression(final MemberReferenceExpression node, final Void data) {
        super.visitMemberReferenceExpression(node, data);

        if (isCurrentMemberVisible()) {
            MemberReference member = node.getUserData(Keys.MEMBER_REFERENCE);

            if (member == null && node.getParent() != null) {
                member = node.getParent().getUserData(Keys.MEMBER_REFERENCE);
            }
View Full Code Here


    }

    @Override
    public Void visitMemberReferenceExpression(final MemberReferenceExpression node, final Void data) {
        if (_simplifyMemberReferences) {
            final MemberReference member = node.getUserData(Keys.MEMBER_REFERENCE);

            if (member instanceof FieldReference &&
                context.getCurrentType() != null &&
                MetadataHelper.isEnclosedBy(context.getCurrentType(), member.getDeclaringType())) {

                final Object resolvedObject = resolveName(node, member.getName(), NameResolveMode.EXPRESSION);

                if (resolvedObject instanceof FieldReference &&
                    MetadataHelper.isSameType(((FieldReference) resolvedObject).getDeclaringType(), member.getDeclaringType())) {

                    _removeQualifierCandidates.add(node);
                }
            }
        }
View Full Code Here

        if (!m2.success()) {
            return null;
        }

        final InvocationExpression hashCodeCall = first(m2.<InvocationExpression>get("hashCodeCall"));
        final MemberReference hashCodeMethod = hashCodeCall.getUserData(Keys.MEMBER_REFERENCE);

        if (!(hashCodeMethod instanceof MethodReference &&
              "java/lang/String".equals(hashCodeMethod.getDeclaringType().getInternalName()))) {

            return null;
        }

        final List<Match> matches = new ArrayList<>();
View Full Code Here

                final Expression expression = ((ExpressionStatement) current).getExpression();
                final Match match = FIELD_ASSIGNMENT.match(expression);

                if (match.success()) {
                    final Expression target = (Expression) firstOrDefault(match.get("target"));
                    final MemberReference reference = target.getUserData(Keys.MEMBER_REFERENCE);

                    if (StringUtilities.equals(context.getCurrentType().getInternalName(), reference.getDeclaringType().getInternalName())) {
                        _initializers.put(
                            reference.getFullName(),
                            (AssignmentExpression) expression
                        );
                    }
                }
                else {
View Full Code Here

    @Override
    public Void visitMemberReferenceExpression(final MemberReferenceExpression node, final Void data) {
        super.visitMemberReferenceExpression(node, data);

        MemberReference member = node.getUserData(Keys.MEMBER_REFERENCE);

        if (member == null && node.getParent() != null && node.getRole() == Roles.TARGET_EXPRESSION) {
            member = node.getParent().getUserData(Keys.MEMBER_REFERENCE);
        }

        if (member == null) {
            return null;
        }
        final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER);

        if (astBuilder == null) {
            return null;
        }

        final ResolveResult valueResult = _resolver.apply(node.getTarget());

        TypeReference declaringType = member.getDeclaringType();

        if (valueResult != null &&
            valueResult.getType() != null) {

            if (MetadataHelper.isAssignableFrom(declaringType, valueResult.getType())) {
View Full Code Here

            return;
        }

        final Expression field = first(m.<IdentifierExpression>get("$assertionsDisabled"));
        final ClassOfExpression type = m.<ClassOfExpression>get("type").iterator().next();
        final MemberReference reference = field.getUserData(Keys.MEMBER_REFERENCE);

        if (!(reference instanceof FieldReference)) {
            return;
        }
View Full Code Here

            if (left instanceof MemberReferenceExpression &&
                ((MemberReferenceExpression) left).getTarget() instanceof ThisReferenceExpression) {

                final MemberReferenceExpression reference = (MemberReferenceExpression) left;
                final MemberReference memberReference = reference.getUserData(Keys.MEMBER_REFERENCE);

                if (memberReference instanceof FieldReference) {
                    final FieldDefinition resolvedField = ((FieldReference) memberReference).resolve();

                    if (resolvedField != null && resolvedField.hasConstantValue()) {
View Full Code Here

        if (!m2.success()) {
            return null;
        }

        final InvocationExpression hashCodeCall = first(m2.<InvocationExpression>get("hashCodeCall"));
        final MemberReference hashCodeMethod = hashCodeCall.getUserData(Keys.MEMBER_REFERENCE);

        if (!(hashCodeMethod instanceof MethodReference &&
              "java/lang/String".equals(hashCodeMethod.getDeclaringType().getInternalName()))) {

            return null;
        }

        final Map<Integer, List<String>> tableInputMap = new LinkedHashMap<>();
View Full Code Here

  }
 
  @Override
  public Void visitInvocationExpression( InvocationExpression node, SourceIndex index )
  {
    MemberReference ref = node.getUserData( Keys.MEMBER_REFERENCE );
   
    // get the behavior entry
    ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() );
    BehaviorEntry behaviorEntry = null;
    if( ref instanceof MethodReference )
    {
      MethodReference methodRef = (MethodReference)ref;
      if( methodRef.isConstructor() )
      {
        behaviorEntry = new ConstructorEntry( classEntry, ref.getSignature() );
      }
      else if( methodRef.isTypeInitializer() )
      {
        behaviorEntry = new ConstructorEntry( classEntry );
      }
      else
      {
        behaviorEntry = new MethodEntry( classEntry, ref.getName(), ref.getSignature() );
      }
    }
    if( behaviorEntry != null )
    {
      // get the node for the token
View Full Code Here

  }
 
  @Override
  public Void visitMemberReferenceExpression( MemberReferenceExpression node, SourceIndex index )
  {
    MemberReference ref = node.getUserData( Keys.MEMBER_REFERENCE );
    if( ref != null )
    {
      // make sure this is actually a field
      if( ref.getSignature().indexOf( '(' ) >= 0 )
      {
        throw new Error( "Expected a field here! got " + ref );
      }
     
      ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() );
      FieldEntry fieldEntry = new FieldEntry( classEntry, ref.getName() );
      index.addReference( node.getMemberNameToken(), fieldEntry, m_behaviorEntry );
    }
   
    return recurse( node, index );
  }
View Full Code Here

TOP

Related Classes of com.strobel.assembler.metadata.MemberReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.