当前位置: 首页>>代码示例>>Java>>正文


Java ClassFileConstants类代码示例

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


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

示例1: toClassFmt

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
private long toClassFmt(final JavaVersion version) {
  if (version != null) {
    switch (version) {
      case JAVA5:
        return ClassFileConstants.JDK1_5;
      case JAVA6:
        return ClassFileConstants.JDK1_6;
      case JAVA7:
        return ClassFileConstants.JDK1_7;
      case JAVA8:
        return (((ClassFileConstants.MAJOR_VERSION_1_7 + 1) << 16) + ClassFileConstants.MINOR_VERSION_0);
      case JAVA9:
        return (((ClassFileConstants.MAJOR_VERSION_1_7 + 2) << 16) + ClassFileConstants.MINOR_VERSION_0);
      default:
        break;
    }
  }
  return 0;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:InMemoryJavaCompiler.java

示例2: getLatestEcjCompilerVersionConstant

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
public static long getLatestEcjCompilerVersionConstant() {
	if (latestEcjCompilerVersionConstantCached != 0) return latestEcjCompilerVersionConstantCached;
	
	int highestVersionSoFar = 0;
	for (Field f : ClassFileConstants.class.getDeclaredFields()) {
		try {
			if (f.getName().startsWith("JDK1_")) {
				int thisVersion = Integer.parseInt(f.getName().substring("JDK1_".length()));
				if (thisVersion > highestVersionSoFar) {
					highestVersionSoFar = thisVersion;
					latestEcjCompilerVersionConstantCached = (Long) f.get(null);
				}
			}
		} catch (Exception ignore) {}
	}
	
	if (highestVersionSoFar > 6 && !ecjSupportsJava7Features()) {
		latestEcjCompilerVersionConstantCached = ClassFileConstants.JDK1_6;
	}
	return latestEcjCompilerVersionConstantCached;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:Eclipse.java

示例3: handleValForForEach

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
public static boolean handleValForForEach(ForeachStatement forEach, BlockScope scope) {
	if (forEach.elementVariable == null) return false;
	
	if (!isVal(forEach.elementVariable.type, scope)) return false;
	
	TypeBinding component = getForEachComponentType(forEach.collection, scope);
	if (component == null) return false;
	TypeReference replacement = makeType(component, forEach.elementVariable.type, false);
	
	forEach.elementVariable.modifiers |= ClassFileConstants.AccFinal;
	forEach.elementVariable.annotations = addValAnnotation(forEach.elementVariable.annotations, forEach.elementVariable.type, scope);
	forEach.elementVariable.type = replacement != null ? replacement :
			new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(forEach.elementVariable.type, 3));
	
	return false;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:PatchVal.java

示例4: setFieldDefaultsForField

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
public void setFieldDefaultsForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean makeFinal) {
	FieldDeclaration field = (FieldDeclaration) fieldNode.get();
	if (level != null && level != AccessLevel.NONE) {
		if ((field.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected)) == 0) {
			if (!hasAnnotation(PackagePrivate.class, fieldNode)) {
				field.modifiers |= EclipseHandlerUtil.toEclipseModifier(level);
			}
		}
	}
	
	if (makeFinal && (field.modifiers & ClassFileConstants.AccFinal) == 0) {
		if (!hasAnnotation(NonFinal.class, fieldNode)) {
			if ((field.modifiers & ClassFileConstants.AccStatic) == 0 || field.initialization != null) {
				field.modifiers |= ClassFileConstants.AccFinal;
			}
		}
	}
	
	fieldNode.rebuild();
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:21,代码来源:HandleFieldDefaults.java

示例5: toEclipseModifier

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
/**
 * Turns an {@code AccessLevel} instance into the flag bit used by eclipse.
 */
public static int toEclipseModifier(AccessLevel value) {
	switch (value) {
	case MODULE:
	case PACKAGE:
		return 0;
	default:
	case PUBLIC:
		return ClassFileConstants.AccPublic;
	case PROTECTED:
		return ClassFileConstants.AccProtected;
	case NONE:
	case PRIVATE:
		return ClassFileConstants.AccPrivate;
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:EclipseHandlerUtil.java

示例6: createListOfNonExistentFields

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
/**
 * Given a list of field names and a node referring to a type, finds each name in the list that does not match a field within the type.
 */
public static List<Integer> createListOfNonExistentFields(List<String> list, EclipseNode type, boolean excludeStandard, boolean excludeTransient) {
	boolean[] matched = new boolean[list.size()];
	
	for (EclipseNode child : type.down()) {
		if (list.isEmpty()) break;
		if (child.getKind() != Kind.FIELD) continue;
		if (excludeStandard) {
			if ((((FieldDeclaration)child.get()).modifiers & ClassFileConstants.AccStatic) != 0) continue;
			if (child.getName().startsWith("$")) continue;
		}
		if (excludeTransient && (((FieldDeclaration)child.get()).modifiers & ClassFileConstants.AccTransient) != 0) continue;
		int idx = list.indexOf(child.getName());
		if (idx > -1) matched[idx] = true;
	}
	
	List<Integer> problematic = new ArrayList<Integer>();
	for (int i = 0 ; i < list.size() ; i++) {
		if (!matched[i]) problematic.add(i);
	}
	
	return problematic;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:EclipseHandlerUtil.java

示例7: generateCleanMethod

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
	List<Statement> statements = new ArrayList<Statement>();
	
	for (BuilderFieldData bfd : builderFields) {
		if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
			bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
		}
	}
	
	FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
	thisUnclean.receiver = new ThisReference(0, 0);
	statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
	MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
	decl.selector = CLEAN_METHOD_NAME;
	decl.modifiers = ClassFileConstants.AccPrivate;
	decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
	decl.statements = statements.toArray(new Statement[0]);
	decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
	return decl;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:HandleBuilder.java

示例8: generateBuilderMethod

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
public MethodDeclaration generateBuilderMethod(boolean isStatic, String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long) pS << 32 | pE;
	
	MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
	out.selector = builderMethodName.toCharArray();
	out.modifiers = ClassFileConstants.AccPublic;
	if (isStatic) out.modifiers |= ClassFileConstants.AccStatic;
	out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	out.returnType = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
	out.typeParameters = copyTypeParams(typeParams, source);
	AllocationExpression invoke = new AllocationExpression();
	invoke.type = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
	out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)};
	
	out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
	return out;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:HandleBuilder.java

示例9: makeSimpleSetterMethodForBuilder

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, EclipseNode fieldNode, EclipseNode sourceNode, boolean fluent, boolean chain) {
	TypeDeclaration td = (TypeDeclaration) builderType.get();
	AbstractMethodDeclaration[] existing = td.methods;
	if (existing == null) existing = EMPTY;
	int len = existing.length;
	FieldDeclaration fd = (FieldDeclaration) fieldNode.get();
	char[] name = fd.name;
	
	for (int i = 0; i < len; i++) {
		if (!(existing[i] instanceof MethodDeclaration)) continue;
		char[] existingName = existing[i].selector;
		if (Arrays.equals(name, existingName)) return;
	}
	
	String setterName = fluent ? fieldNode.getName() : HandlerUtil.buildAccessorName("set", fieldNode.getName());
	
	MethodDeclaration setter = HandleSetter.createSetter(td, fieldNode, setterName, chain, ClassFileConstants.AccPublic,
		sourceNode, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList());
	injectMethod(builderType, setter);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:21,代码来源:HandleBuilder.java

示例10: generateFields

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
@Override public List<EclipseNode> generateFields(SingularData data, EclipseNode builderType) {
	if (useGuavaInstead(builderType)) {
		return guavaListSetSingularizer.generateFields(data, builderType);
	}
	
	TypeReference type = new QualifiedTypeReference(JAVA_UTIL_ARRAYLIST, NULL_POSS);
	type = addTypeArgs(1, false, builderType, type, data.getTypeArgs());
	
	FieldDeclaration buildField = new FieldDeclaration(data.getPluralName(), 0, -1);
	buildField.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	buildField.modifiers = ClassFileConstants.AccPrivate;
	buildField.declarationSourceEnd = -1;
	buildField.type = type;
	data.setGeneratedByRecursive(buildField);
	return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:EclipseJavaUtilListSetSingularizer.java

示例11: generateClearMethod

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
private void generateClearMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType) {
	MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
	md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	md.modifiers = ClassFileConstants.AccPublic;
	
	FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
	thisDotField.receiver = new ThisReference(0, 0);
	FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L);
	thisDotField2.receiver = new ThisReference(0, 0);
	md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
	MessageSend clearMsg = new MessageSend();
	clearMsg.receiver = thisDotField2;
	clearMsg.selector = "clear".toCharArray();
	Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsg, 0, 0);
	md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
	md.returnType = returnType;
	injectMethod(builderType, md);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:EclipseJavaUtilListSetSingularizer.java

示例12: parse

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
@Nullable
private static Node parse(String code) {
  CompilerOptions options = new CompilerOptions();
  options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_7;
  options.parseLiteralExpressionsAsConstants = true;
  ProblemReporter problemReporter = new ProblemReporter(
    DefaultErrorHandlingPolicies.exitOnFirstError(), options, new DefaultProblemFactory());
  Parser parser = new Parser(problemReporter, options.parseLiteralExpressionsAsConstants);
  parser.javadocParser.checkDocComment = false;
  EcjTreeConverter converter = new EcjTreeConverter();
  org.eclipse.jdt.internal.compiler.batch.CompilationUnit sourceUnit =
    new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(code.toCharArray(), "unitTest", "UTF-8");
  CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
  CompilationUnitDeclaration unit = parser.parse(sourceUnit, compilationResult);
  if (unit == null) {
    return null;
  }
  converter.visit(code, unit);
  List<? extends Node> nodes = converter.getAll();
  for (lombok.ast.Node node : nodes) {
    if (node instanceof lombok.ast.CompilationUnit) {
      return node;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LombokPsiConverterTest.java

示例13: setFieldDefaultsForField

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
public void setFieldDefaultsForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean makeFinal) {
	FieldDeclaration field = (FieldDeclaration) fieldNode.get();
	if (level != null && level != AccessLevel.NONE) {
		if ((field.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected)) == 0) {
			if (!hasAnnotation(PackagePrivate.class, fieldNode)) {
				field.modifiers |= EclipseHandlerUtil.toEclipseModifier(level);
			}
		}
	}
	
	if (makeFinal && (field.modifiers & ClassFileConstants.AccFinal) == 0) {
		if (!hasAnnotation(NonFinal.class, fieldNode)) {
			field.modifiers |= ClassFileConstants.AccFinal;
		}
	}
	
	fieldNode.rebuild();
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:19,代码来源:HandleFieldDefaults.java

示例14: generateBuilderMethod

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
public MethodDeclaration generateBuilderMethod(String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
	int pS = source.sourceStart, pE = source.sourceEnd;
	long p = (long) pS << 32 | pE;
	
	MethodDeclaration out = new MethodDeclaration(
			((CompilationUnitDeclaration) type.top().get()).compilationResult);
	out.selector = builderMethodName.toCharArray();
	out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic;
	out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
	out.returnType = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
	out.typeParameters = copyTypeParams(typeParams, source);
	AllocationExpression invoke = new AllocationExpression();
	invoke.type = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
	out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)};
	
	out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
	return out;
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:19,代码来源:HandleBuilder.java

示例15: makeSimpleSetterMethodForBuilder

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; //导入依赖的package包/类
private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, EclipseNode fieldNode, EclipseNode sourceNode, boolean fluent, boolean chain) {
	TypeDeclaration td = (TypeDeclaration) builderType.get();
	AbstractMethodDeclaration[] existing = td.methods;
	if (existing == null) existing = EMPTY;
	int len = existing.length;
	FieldDeclaration fd = (FieldDeclaration) fieldNode.get();
	char[] name = fd.name;
	
	for (int i = 0; i < len; i++) {
		if (!(existing[i] instanceof MethodDeclaration)) continue;
		char[] existingName = existing[i].selector;
		if (Arrays.equals(name, existingName)) return;
	}
	
	String setterName = fluent ? fieldNode.getName() : HandlerUtil.buildAccessorName("set", fieldNode.getName());
	
	MethodDeclaration setter = HandleSetter.createSetter(td, fieldNode, setterName, chain, ClassFileConstants.AccPublic,
			sourceNode, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList());
	injectMethod(builderType, setter);
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:21,代码来源:HandleBuilder.java


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