當前位置: 首頁>>代碼示例>>Java>>正文


Java MemberReference類代碼示例

本文整理匯總了Java中com.strobel.assembler.metadata.MemberReference的典型用法代碼示例。如果您正苦於以下問題:Java MemberReference類的具體用法?Java MemberReference怎麽用?Java MemberReference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MemberReference類屬於com.strobel.assembler.metadata包,在下文中一共展示了MemberReference類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visitMemberReferenceExpression

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@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.getErasedSignature().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(), new Type(ref.getErasedSignature()));
		index.addReference(node.getMemberNameToken(), fieldEntry, m_behaviorEntry);
	}
	
	return recurse(node, index);
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:17,代碼來源:SourceIndexBehaviorVisitor.java

示例2: visit

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@AstVisitor(nodes=AstNodes.EXPRESSIONS, methodName="<clinit>")
public void visit(Expression expr, NodeChain nc, MethodContext mc, TypeDefinition td) {
    if(expr.getOperand() instanceof MemberReference) {
        MemberReference mr = (MemberReference) expr.getOperand();
        TypeReference tr = mr.getDeclaringType();
        TypeDefinition subType = tr == null ? null : tr.resolve();
        if (subType != null && (subType.isAnonymous() || subType.isLocalClass())) {
            subType = subType.getBaseType().resolve();
        }
        if (subType != null && !td.isEquivalentTo(subType) && Types.isInstance(subType, td) && nc
                .getLambdaMethod() == null) {
            mc.report("InitializerRefersSubclass", td.isNonPublic() || subType.isNonPublic() ? 5 : 0, expr,
                Roles.SUBCLASS.create(subType));
        }
    }
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:17,代碼來源:InitializerRefersSubclass.java

示例3: visitMemberReferenceExpression

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@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.getErasedSignature().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(), new Type(
				ref.getErasedSignature()));
		index.addReference(node.getMemberNameToken(), fieldEntry,
			m_behaviorEntry);
	}
	
	return recurse(node, index);
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-Enigma,代碼行數:23,代碼來源:SourceIndexBehaviorVisitor.java

示例4: visitIdentifierExpression

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@Override
public Void visitIdentifierExpression(IdentifierExpression node,
	SourceIndex index)
{
	MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE);
	if(ref != null)
	{
		ClassEntry classEntry =
			new ClassEntry(ref.getDeclaringType().getInternalName());
		FieldEntry fieldEntry =
			new FieldEntry(classEntry, ref.getName(), new Type(
				ref.getErasedSignature()));
		index.addReference(node.getIdentifierToken(), fieldEntry,
			m_behaviorEntry);
	}
	
	return recurse(node, index);
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-Enigma,代碼行數:19,代碼來源:SourceIndexBehaviorVisitor.java

示例5: visitObjectCreationExpression

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@Override
public Void visitObjectCreationExpression(ObjectCreationExpression node,
	SourceIndex index)
{
	MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE);
	if(ref != null)
	{
		ClassEntry classEntry =
			new ClassEntry(ref.getDeclaringType().getInternalName());
		ConstructorEntry constructorEntry =
			new ConstructorEntry(classEntry, new Signature(
				ref.getErasedSignature()));
		if(node.getType() instanceof SimpleType)
		{
			SimpleType simpleTypeNode = (SimpleType)node.getType();
			index.addReference(simpleTypeNode.getIdentifierToken(),
				constructorEntry, m_behaviorEntry);
		}
	}
	
	return recurse(node, index);
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-Enigma,代碼行數:23,代碼來源:SourceIndexBehaviorVisitor.java

示例6: visitIdentifierExpression

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@Override
public Void visitIdentifierExpression(IdentifierExpression node, SourceIndex index) {
	MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE);
	if (ref != null) {
		ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName());
		FieldEntry fieldEntry = new FieldEntry(classEntry, ref.getName(), new Type(ref.getErasedSignature()));
		index.addReference(node.getIdentifierToken(), fieldEntry, m_behaviorEntry);
	}
	
	return recurse(node, index);
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:12,代碼來源:SourceIndexBehaviorVisitor.java

示例7: visitObjectCreationExpression

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@Override
public Void visitObjectCreationExpression(ObjectCreationExpression node, SourceIndex index) {
	MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE);
	if (ref != null) {
		ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName());
		ConstructorEntry constructorEntry = new ConstructorEntry(classEntry, new Signature(ref.getErasedSignature()));
		if (node.getType() instanceof SimpleType) {
			SimpleType simpleTypeNode = (SimpleType)node.getType();
			index.addReference(simpleTypeNode.getIdentifierToken(), constructorEntry, m_behaviorEntry);
		}
	}
	
	return recurse(node, index);
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:15,代碼來源:SourceIndexBehaviorVisitor.java

示例8: registerAsserter

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
MemberAsserter registerAsserter(MemberReference mr) {
    MemberAsserter ma = MemberAsserter.forMember(ca, mr);
    if (!ma.isEmpty()) {
        if (mas == null)
            mas = new HashMap<>();
        if (mas.put(new MemberInfo(mr), ma) != null) {
            throw new InternalError("Asserter is registered twice for " + mr);
        }
    }
    return ma;
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:12,代碼來源:ClassData.java

示例9: visit

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
@AstVisitor(nodes = AstNodes.EXPRESSIONS)
public void visit(Expression expr, NodeChain nc, MethodContext mc, MethodDefinition md) {
    if (expr.getCode() == AstCode.InvokeVirtual || expr.getCode() == AstCode.InvokeInterface) {
        MethodReference mr = (MethodReference) expr.getOperand();
        if (mr.getName().equals("put")) {
            TypeReference tr = ValuesFlow.reduceType(Exprs.getChild(expr, 0));
            String typeName = tr == null ? mr.getDeclaringType().getInternalName() : tr.getInternalName();
            if (typeName.equals("java/util/concurrent/ConcurrentHashMap") || typeName
                        .equals("java/util/concurrent/ConcurrentSkipListMap")) {
                Expression self = expr.getArguments().get(0);
                Expression key = expr.getArguments().get(1);
                Expression value = expr.getArguments().get(2);
                Expression prevCall = null;
                int priority = 0;
                while (prevCall == null && nc != null) {
                    if (nc.getNode() instanceof Condition) {
                        Expression cond = ((Condition) nc.getNode()).getCondition();
                        prevCall = Exprs.findExpression(cond, child -> isGetOrContains(self, key, child));
                        if (prevCall == null) {
                            prevCall = Exprs
                                    .findExpressionWithSources(cond, child -> isGetOrContains(self, key, child));
                            priority = 10;
                        }
                    }
                    nc = nc.getParent();
                }
                if (prevCall == null) {
                    priority = 0;
                    prevCall = Exprs.findExpression(expr.getArguments().get(2), child -> isGetOrContains(self, key,
                        child));
                    if (prevCall == null) {
                        prevCall = Exprs.findExpressionWithSources(expr.getArguments().get(2),
                            child -> isGetOrContains(self, key, child));
                        priority = 10;
                    }
                }
                if(nc != null && nc.isSynchronized() || Flags.testAny(md.getFlags(), Flags.SYNCHRONIZED)) {
                    priority += 40;
                }
                if(Types.isImmutable(value.getInferredType())) {
                    priority += 30;
                }
                if (prevCall != null) {
                    mc.report("NonAtomicOperationOnConcurrentMap", priority, self, FIRST_METHOD.create(
                        (MemberReference) prevCall.getOperand()), SECOND_METHOD.create(mr));
                }
            }
        }
    }
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:51,代碼來源:AtomicConcurrent.java

示例10: getCtorFields

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
Map<MemberInfo, Expression> getCtorFields(MemberReference ctor) {
    return cf.ctorFields.get(new MemberInfo(ctor));
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:4,代碼來源:FrameContext.java

示例11: MemberInfo

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
public MemberInfo(MemberReference mr) {
    this.type = new TypeInfo(mr.getDeclaringType().getInternalName());
    this.name = mr.getName();
    this.signature = mr.getErasedSignature();
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:6,代碼來源:WarningAnnotation.java

示例12: create

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
public WarningAnnotation<MemberInfo> create(MemberReference mr) {
    return create(new MemberInfo(mr));
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:4,代碼來源:Role.java

示例13: ErrorMessage

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
public ErrorMessage(Detector detector, MemberReference method, int line, Throwable error) {
    this(detector == null ? null : detector.toString(), method.getDeclaringType().getFullName(), method
            .getFullName(), method.getSignature(), line, error);
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:5,代碼來源:ErrorMessage.java

示例14: forMember

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
public static MemberAsserter forMember(MemberReference md) {
    List<AssertionData> assertions = analyzeMember(md);
    if(assertions.isEmpty())
        return EMPTY_ASSERTER;
    return new MemberAsserter(null, assertions);
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:7,代碼來源:MemberAsserter.java

示例15: getAsserter

import com.strobel.assembler.metadata.MemberReference; //導入依賴的package包/類
MemberAsserter getAsserter(MemberReference mr) {
    if (mas == null)
        return ca;
    return mas.getOrDefault(new MemberInfo(mr), ca);
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:6,代碼來源:ClassData.java


注:本文中的com.strobel.assembler.metadata.MemberReference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。