本文整理汇总了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);
}
示例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));
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
}
}
}
}
示例10: getCtorFields
import com.strobel.assembler.metadata.MemberReference; //导入依赖的package包/类
Map<MemberInfo, Expression> getCtorFields(MemberReference ctor) {
return cf.ctorFields.get(new MemberInfo(ctor));
}
示例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();
}
示例12: create
import com.strobel.assembler.metadata.MemberReference; //导入依赖的package包/类
public WarningAnnotation<MemberInfo> create(MemberReference mr) {
return create(new MemberInfo(mr));
}
示例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);
}
示例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);
}
示例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);
}