• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClassLiteralAccess类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess的典型用法代码示例。如果您正苦于以下问题:Java ClassLiteralAccess类的具体用法?Java ClassLiteralAccess怎么用?Java ClassLiteralAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClassLiteralAccess类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了ClassLiteralAccess类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getApplicableExtensionMethods

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
static List<Extension> getApplicableExtensionMethods(EclipseNode typeNode, Annotation ann, TypeBinding receiverType) {
	List<Extension> extensions = new ArrayList<Extension>();
	if ((typeNode != null) && (ann != null) && (receiverType != null)) {
		BlockScope blockScope = ((TypeDeclaration) typeNode.get()).initializerScope;
		EclipseNode annotationNode = typeNode.getNodeFor(ann);
		AnnotationValues<ExtensionMethod> annotation = createAnnotation(ExtensionMethod.class, annotationNode);
		boolean suppressBaseMethods = false;
		try {
			suppressBaseMethods = annotation.getInstance().suppressBaseMethods();
		} catch (AnnotationValueDecodeFail fail) {
			fail.owner.setError(fail.getMessage(), fail.idx);
		}
		for (Object extensionMethodProvider : annotation.getActualExpressions("value")) {
			if (extensionMethodProvider instanceof ClassLiteralAccess) {
				TypeBinding binding = ((ClassLiteralAccess) extensionMethodProvider).type.resolveType(blockScope);
				if (binding == null) continue;
				if (!binding.isClass() && !binding.isEnum()) continue;
				Extension e = new Extension();
				e.extensionMethods = getApplicableExtensionMethodsDefinedInProvider(typeNode, (ReferenceBinding) binding, receiverType);
				e.suppressBaseMethods = suppressBaseMethods;
				extensions.add(e);
			}
		}
	}
	return extensions;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:27,代码来源:PatchExtensionMethod.java


示例2: createFactoryParameter

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long)pS << 32 | pE;
	
	MessageSend factoryParameterCall = new MessageSend();
	setGeneratedBy(factoryParameterCall, source);
	
	factoryParameterCall.receiver = super.createFactoryParameter(type, source);
	factoryParameterCall.selector = "getName".toCharArray();
	
	factoryParameterCall.nameSourcePosition = p;
	factoryParameterCall.sourceStart = pS;
	factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE;
	
	return factoryParameterCall;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleLog.java


示例3: visit

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {

	final int numberOfParens = (classLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
	if (numberOfParens > 0) {
		manageOpeningParenthesizedExpression(classLiteral, numberOfParens);
	}
	classLiteral.type.traverse(this, scope);
	this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
	this.scribe.printNextToken(TerminalTokens.TokenNameclass);

	if (numberOfParens > 0) {
		manageClosingParenthesizedExpression(classLiteral, numberOfParens);
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CodeFormatterVisitor.java


示例4: calculateValue

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
/**
 * Returns the actual value of the given Literal or Literal-like node.
 */
public static Object calculateValue(Expression e) {
	if (e instanceof Literal) {
		((Literal)e).computeConstant();
		switch (e.constant.typeID()) {
		case TypeIds.T_int: return e.constant.intValue();
		case TypeIds.T_byte: return e.constant.byteValue();
		case TypeIds.T_short: return e.constant.shortValue();
		case TypeIds.T_char: return e.constant.charValue();
		case TypeIds.T_float: return e.constant.floatValue();
		case TypeIds.T_double: return e.constant.doubleValue();
		case TypeIds.T_boolean: return e.constant.booleanValue();
		case TypeIds.T_long: return e.constant.longValue();
		case TypeIds.T_JavaLangString: return e.constant.stringValue();
		default: return null;
		}
	} else if (e instanceof ClassLiteralAccess) {
		return Eclipse.toQualifiedName(((ClassLiteralAccess)e).type.getTypeName());
	} else if (e instanceof SingleNameReference) {
		return new String(((SingleNameReference)e).token);
	} else if (e instanceof QualifiedNameReference) {
		String qName = Eclipse.toQualifiedName(((QualifiedNameReference)e).tokens);
		int idx = qName.lastIndexOf('.');
		return idx == -1 ? qName : qName.substring(idx+1);
	}
	
	return null;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:31,代码来源:Eclipse.java


示例5: selfType

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
public static ClassLiteralAccess selfType(EclipseNode type, Annotation source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long)pS << 32 | pE;

	TypeDeclaration typeDeclaration = (TypeDeclaration)type.get();
	TypeReference typeReference = new SingleTypeReference(typeDeclaration.name, p);
	setGeneratedBy(typeReference, source);

	ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, typeReference);
	setGeneratedBy(result, source);
	
	return result;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:HandleLog.java


示例6: consumePrimaryNoNewArrayArrayType

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
protected void consumePrimaryNoNewArrayArrayType() {
	// PrimaryNoNewArray ::= Name Dims '.' 'class'
	this.intPtr--; // remove the class start position

	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
	pushOnGenericsLengthStack(0);
	ClassLiteralAccess cla;
	pushOnExpressionStack(
		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
	rejectIllegalTypeAnnotations(cla.type); // javac correctly rejects annotations on dimensions here.
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:Parser.java


示例7: consumePrimaryNoNewArrayName

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
protected void consumePrimaryNoNewArrayName() {
	// PrimaryNoNewArray ::= Name '.' 'class'
	this.intPtr--; // remove the class start position

	// handle type arguments
	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
	pushOnGenericsLengthStack(0);
	TypeReference typeReference = getTypeReference(0);
	
	rejectIllegalTypeAnnotations(typeReference);

	pushOnExpressionStack(
		new ClassLiteralAccess(this.intStack[this.intPtr--], typeReference));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:Parser.java


示例8: consumePrimaryNoNewArrayPrimitiveArrayType

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
protected void consumePrimaryNoNewArrayPrimitiveArrayType() {
	// PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
	this.intPtr--; // remove the class start position
	ClassLiteralAccess cla;
	pushOnExpressionStack(
		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
	rejectIllegalTypeAnnotations(cla.type, true /* tolerate annotations on dimensions for bug compatibility for now */);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:Parser.java


示例9: consumePrimaryNoNewArrayPrimitiveType

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
protected void consumePrimaryNoNewArrayPrimitiveType() {
	// PrimaryNoNewArray ::= PrimitiveType '.' 'class'
	this.intPtr--; // remove the class start position
	ClassLiteralAccess cla;
	pushOnExpressionStack(
		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(0)));
	rejectIllegalTypeAnnotations(cla.type);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:Parser.java


示例10: endVisit

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
@Override
public void endVisit(ClassLiteralAccess x, BlockScope scope) {
  try {
    SourceInfo info = makeSourceInfo(x);
    JType type = typeMap.get(x.targetType);
    push(new JClassLiteral(info, type));
  } catch (Throwable e) {
    throw translateException(x, e);
  }
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:11,代码来源:GwtAstBuilder.java


示例11: processAnnotation

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
	EclipseNode owner = annotationNode.up();
	switch (owner.getKind()) {
	case TYPE:
		TypeDeclaration typeDecl = null;
		if (owner.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) owner.get();
		int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
		
		boolean notAClass = (modifiers &
				(ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0;
		
		if (typeDecl == null || notAClass) {
			annotationNode.addError(framework.getAnnotationAsString() + " is legal only on classes and enums.");
			return;
		}
		
		if (fieldExists("log", owner) != MemberExistsResult.NOT_EXISTS) {
			annotationNode.addWarning("Field 'log' already exists.");
			return;
		}
		
		ClassLiteralAccess loggingType = selfType(owner, source);
		
		FieldDeclaration fieldDeclaration = createField(framework, source, loggingType);
		fieldDeclaration.traverse(new SetGeneratedByVisitor(source), typeDecl.staticInitializerScope);
		injectField(owner, fieldDeclaration);
		owner.rebuild();
		break;
	default:
		break;
	}
}
 
开发者ID:redundent,项目名称:lombok,代码行数:33,代码来源:HandleLog.java


示例12: selfType

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
private static ClassLiteralAccess selfType(EclipseNode type, Annotation source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long)pS << 32 | pE;

	TypeDeclaration typeDeclaration = (TypeDeclaration)type.get();
	TypeReference typeReference = new SingleTypeReference(typeDeclaration.name, p);
	setGeneratedBy(typeReference, source);

	ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, typeReference);
	setGeneratedBy(result, source);
	
	return result;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:14,代码来源:HandleLog.java


示例13: createField

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long)pS << 32 | pE;
	
	// 	private static final <loggerType> log = <factoryMethod>(<parameter>);

	FieldDeclaration fieldDecl = new FieldDeclaration("log".toCharArray(), 0, -1);
	setGeneratedBy(fieldDecl, source);
	fieldDecl.declarationSourceEnd = -1;
	fieldDecl.modifiers = Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL;
	
	fieldDecl.type = createTypeReference(framework.getLoggerTypeName(), source);
	
	MessageSend factoryMethodCall = new MessageSend();
	setGeneratedBy(factoryMethodCall, source);

	factoryMethodCall.receiver = createNameReference(framework.getLoggerFactoryTypeName(), source);
	factoryMethodCall.selector = framework.getLoggerFactoryMethodName().toCharArray();
	
	Expression parameter = framework.createFactoryParameter(loggingType, source);
	
	factoryMethodCall.arguments = new Expression[] { parameter };
	factoryMethodCall.nameSourcePosition = p;
	factoryMethodCall.sourceStart = pS;
	factoryMethodCall.sourceEnd = factoryMethodCall.statementEnd = pE;
	
	fieldDecl.initialization = factoryMethodCall;
	
	return fieldDecl;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:31,代码来源:HandleLog.java


示例14: visit

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
@Override public boolean visit(ClassLiteralAccess node, BlockScope scope) {
	fixPositions(setGeneratedBy(node, source));
	return super.visit(node, scope);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:5,代码来源:SetGeneratedByVisitor.java


示例15: visit

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
public boolean visit(
	ClassLiteralAccess classLiteralAccess,
	BlockScope scope) {
		addRealFragment(classLiteralAccess);
		return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:BinaryExpressionFragmentBuilder.java


示例16: getMemberValue

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
protected Object getMemberValue(org.eclipse.jdt.internal.core.MemberValuePair memberValuePair, Expression expression) {
	if (expression instanceof NullLiteral) {
		return null;
	} else if (expression instanceof Literal) {
		((Literal) expression).computeConstant();
		return Util.getAnnotationMemberValue(memberValuePair, expression.constant);
	} else if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) {
		org.eclipse.jdt.internal.compiler.ast.Annotation annotation = (org.eclipse.jdt.internal.compiler.ast.Annotation) expression;
		Object handle = acceptAnnotation(annotation, null, (JavaElement) this.handleStack.peek());
		memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
		return handle;
	} else if (expression instanceof ClassLiteralAccess) {
		ClassLiteralAccess classLiteral = (ClassLiteralAccess) expression;
		char[] name = CharOperation.concatWith(classLiteral.type.getTypeName(), '.');
		memberValuePair.valueKind = IMemberValuePair.K_CLASS;
		return new String(name);
	} else if (expression instanceof QualifiedNameReference) {
		char[] qualifiedName = CharOperation.concatWith(((QualifiedNameReference) expression).tokens, '.');
		memberValuePair.valueKind = IMemberValuePair.K_QUALIFIED_NAME;
		return new String(qualifiedName);
	} else if (expression instanceof SingleNameReference) {
		char[] simpleName = ((SingleNameReference) expression).token;
		if (simpleName == RecoveryScanner.FAKE_IDENTIFIER) {
			memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
			return null;
		}
		memberValuePair.valueKind = IMemberValuePair.K_SIMPLE_NAME;
		return new String(simpleName);
	} else if (expression instanceof ArrayInitializer) {
		memberValuePair.valueKind = -1; // modified below by the first call to getMemberValue(...)
		Expression[] expressions = ((ArrayInitializer) expression).expressions;
		int length = expressions == null ? 0 : expressions.length;
		Object[] values = new Object[length];
		for (int i = 0; i < length; i++) {
			int previousValueKind = memberValuePair.valueKind;
			Object value = getMemberValue(memberValuePair, expressions[i]);
			if (previousValueKind != -1 && memberValuePair.valueKind != previousValueKind) {
				// values are heterogeneous, value kind is thus unknown
				memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
			}
			values[i] = value;
		}
		if (memberValuePair.valueKind == -1)
			memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return values;
	} else if (expression instanceof UnaryExpression) {			// to deal with negative numerals (see bug - 248312)
		UnaryExpression unaryExpression = (UnaryExpression) expression;
		if ((unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT == OperatorIds.MINUS) {
			if (unaryExpression.expression instanceof Literal) {
				Literal subExpression = (Literal) unaryExpression.expression;
				subExpression.computeConstant();
				return Util.getNegativeAnnotationMemberValue(memberValuePair, subExpression.constant);
			}
		}
		memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return null;
	} else {
		memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:62,代码来源:CompilationUnitStructureRequestor.java


示例17: getAnnotationMemberValue

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
private Object getAnnotationMemberValue(MemberValuePair memberValuePair, Expression expression, JavaElement parentElement) {
	if (expression instanceof NullLiteral) {
		return null;
	} else if (expression instanceof Literal) {
		((Literal) expression).computeConstant();
		return Util.getAnnotationMemberValue(memberValuePair, expression.constant);
	} else if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) {
		memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
		return getAnnotation((org.eclipse.jdt.internal.compiler.ast.Annotation) expression, parentElement);
	} else if (expression instanceof ClassLiteralAccess) {
		ClassLiteralAccess classLiteral = (ClassLiteralAccess) expression;
		char[] typeName = CharOperation.concatWith(classLiteral.type.getTypeName(), '.');
		memberValuePair.valueKind = IMemberValuePair.K_CLASS;
		return new String(typeName);
	} else if (expression instanceof QualifiedNameReference) {
		char[] qualifiedName = CharOperation.concatWith(((QualifiedNameReference) expression).tokens, '.');
		memberValuePair.valueKind = IMemberValuePair.K_QUALIFIED_NAME;
		return new String(qualifiedName);
	} else if (expression instanceof SingleNameReference) {
		char[] simpleName = ((SingleNameReference) expression).token;
		if (simpleName == RecoveryScanner.FAKE_IDENTIFIER) {
			memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
			return null;
		}
		memberValuePair.valueKind = IMemberValuePair.K_SIMPLE_NAME;
		return new String(simpleName);
	} else if (expression instanceof ArrayInitializer) {
		memberValuePair.valueKind = -1; // modified below by the first call to getMemberValue(...)
		Expression[] expressions = ((ArrayInitializer) expression).expressions;
		int length = expressions == null ? 0 : expressions.length;
		Object[] values = new Object[length];
		for (int i = 0; i < length; i++) {
			int previousValueKind = memberValuePair.valueKind;
			Object value = getAnnotationMemberValue(memberValuePair, expressions[i], parentElement);
			if (previousValueKind != -1 && memberValuePair.valueKind != previousValueKind) {
				// values are heterogeneous, value kind is thus unknown
				memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
			}
			values[i] = value;
		}
		if (memberValuePair.valueKind == -1)
			memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return values;
	} else if (expression instanceof UnaryExpression) {			//to deal with negative numerals (see bug - 248312)
		UnaryExpression unaryExpression = (UnaryExpression) expression;
		if ((unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT == OperatorIds.MINUS) {
			if (unaryExpression.expression instanceof Literal) {
				Literal subExpression = (Literal) unaryExpression.expression;
				subExpression.computeConstant();
				return Util.getNegativeAnnotationMemberValue(memberValuePair, subExpression.constant);
			}
		}
		memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return null;
	} else {
		memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:60,代码来源:LocalVariable.java


示例18: visit

import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; //导入依赖的package包/类
@Override public boolean visit(ClassLiteralAccess node, BlockScope scope) {
	setGeneratedBy(node, source);
	applyOffsetExpression(node);
	return super.visit(node, scope);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:6,代码来源:SetGeneratedByVisitor.java



注:本文中的org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActionableDynamicQuery类代码示例发布时间:2022-05-23
下一篇:
Java AllocateAddressRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap