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


Java ClassFileConstants.JDK1_4属性代码示例

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


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

示例1: manageSyntheticAccessIfNecessary

public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return;
	// if constructor from parameterized type got found, use the original constructor at codegen time
	MethodBinding codegenBinding = this.binding.original();

	ReferenceBinding declaringClass;
	if (codegenBinding.isPrivate() && TypeBinding.notEquals(currentScope.enclosingSourceType(), (declaringClass = codegenBinding.declaringClass))) {

		// from 1.4 on, local type constructor can lose their private flag to ease emulation
		if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
			// constructor will not be dumped as private, no emulation required thus
			codegenBinding.tagBits |= TagBits.ClearPrivateModifier;
		} else {
			this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess());
			currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:AllocationExpression.java

示例2: findLocalType

public final ReferenceBinding findLocalType(char[] name) {
	long compliance = compilerOptions().complianceLevel;
	for (int i = this.subscopeCount-1; i >= 0; i--) {
		if (this.subscopes[i] instanceof ClassScope) {
			LocalTypeBinding sourceType = (LocalTypeBinding)((ClassScope) this.subscopes[i]).referenceContext.binding;
			// from 1.4 on, local types should not be accessed across switch case blocks (52221)
			if (compliance >= ClassFileConstants.JDK1_4 && sourceType.enclosingCase != null) {
				if (!isInsideCase(sourceType.enclosingCase)) {
					continue;
				}
			}
			if (CharOperation.equals(sourceType.sourceName(), name))
				return sourceType;
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:BlockScope.java

示例3: findSingleImport

private Binding findSingleImport(char[][] compoundName, int mask, boolean findStaticImports) {
	if (compoundName.length == 1) {
		// findType records the reference
		// the name cannot be a package
		if (compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4)
			return new ProblemReferenceBinding(compoundName, null, ProblemReasons.NotFound);
		ReferenceBinding typeBinding = findType(compoundName[0], this.environment.defaultPackage, this.fPackage);
		if (typeBinding == null)
			return new ProblemReferenceBinding(compoundName, null, ProblemReasons.NotFound);
		return typeBinding;
	}

	if (findStaticImports)
		return findSingleStaticImport(compoundName, mask);
	return findImport(compoundName, compoundName.length);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:CompilationUnitScope.java

示例4: complainIfUnreachable

public int complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, int complaintLevel, boolean endOfBlock) {
	// before 1.4, empty statements are tolerated anywhere
	if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_4) {
		return complaintLevel;
	}
	return super.complainIfUnreachable(flowInfo, scope, complaintLevel, endOfBlock);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:7,代码来源:EmptyStatement.java

示例5: analyseCode

public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired) {
	switch (this.bits & ASTNode.RestrictiveFlagMASK) {
		case Binding.FIELD : // reading a field
			if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
				manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
			}
			// check if reading a final blank field
			FieldBinding fieldBinding = (FieldBinding) this.binding;
			if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
				FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
				if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
					currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
				}
			}
			if (!fieldBinding.isStatic()) {
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318682
				currentScope.resetDeclaringClassMethodStaticFlag(fieldBinding.declaringClass);
			}
			break;
		case Binding.LOCAL : // reading a local variable
			LocalVariableBinding localBinding;
			if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
				currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
			}
			if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
				localBinding.useFlag = LocalVariableBinding.USED;
			} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
				localBinding.useFlag = LocalVariableBinding.FAKE_USED;
			}
	}
	if (valueRequired) {
		manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
	}
	return flowInfo;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:35,代码来源:SingleNameReference.java

示例6: versionToJdkLevel

public static long versionToJdkLevel(Object versionID) {
	if (versionID instanceof String) {
		String version = (String) versionID;
		// verification is optimized for all versions with same length and same "1." prefix
		if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
			switch (version.charAt(2)) {
				case '1':
					return ClassFileConstants.JDK1_1;
				case '2':
					return ClassFileConstants.JDK1_2;
				case '3':
					return ClassFileConstants.JDK1_3;
				case '4':
					return ClassFileConstants.JDK1_4;
				case '5':
					return ClassFileConstants.JDK1_5;
				case '6':
					return ClassFileConstants.JDK1_6;
				case '7':
					return ClassFileConstants.JDK1_7;
				default:
					return 0; // unknown
			}
		}
		if (VERSION_JSR14.equals(versionID)) {
			return ClassFileConstants.JDK1_4;
		}
		if (VERSION_CLDC1_1.equals(versionID)) {
			return ClassFileConstants.CLDC_1_1;
		}
	}
	return 0; // unknown
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:CompilerOptions.java

示例7: AST

/**
 * Creates a new, empty abstract syntax tree using the given options.
 * <p>
 * Following option keys are significant:
 * <ul>
 * <li><code>"org.eclipse.jdt.core.compiler.source"</code> -
 *    indicates source compatibility mode (as per <code>JavaCore</code>);
 *    <code>"1.3"</code> means the source code is as per JDK 1.3;
 *    <code>"1.4"</code> means the source code is as per JDK 1.4
 *    (<code>"assert"</code> is now a keyword);
 *    <code>"1.5"</code> means the source code is as per JDK 1.5
 *    (<code>"enum"</code> is now a keyword);
 *    <code>"1.7"</code> means the source code is as per JDK 1.7;
 *    additional legal values may be added later. </li>
 * </ul>
 * Options other than the above are ignored.
 * </p>
 *
 * @param options the table of options (key type: <code>String</code>;
 *    value type: <code>String</code>)
 * @see JavaCore#getDefaultOptions()
 * @deprecated Clients should port their code to use the new JLS4 AST API and call
 *    {@link #newAST(int) AST.newAST(AST.JLS4)} instead of using this constructor.
 */
public AST(Map options) {
	this(JLS2);
	Object sourceLevelOption = options.get(JavaCore.COMPILER_SOURCE);
	long sourceLevel = ClassFileConstants.JDK1_3;
	if (JavaCore.VERSION_1_4.equals(sourceLevelOption)) {
		sourceLevel = ClassFileConstants.JDK1_4;
	} else if (JavaCore.VERSION_1_5.equals(sourceLevelOption)) {
		sourceLevel = ClassFileConstants.JDK1_5;
	} else if (JavaCore.VERSION_1_7.equals(sourceLevelOption)) {
		sourceLevel = ClassFileConstants.JDK1_7;
	}
	Object complianceLevelOption = options.get(JavaCore.COMPILER_COMPLIANCE);
	long complianceLevel = ClassFileConstants.JDK1_3;
	if (JavaCore.VERSION_1_4.equals(complianceLevelOption)) {
		complianceLevel = ClassFileConstants.JDK1_4;
	} else if (JavaCore.VERSION_1_5.equals(complianceLevelOption)) {
		complianceLevel = ClassFileConstants.JDK1_5;
	} else if (JavaCore.VERSION_1_7.equals(complianceLevelOption)) {
		complianceLevel = ClassFileConstants.JDK1_7;
	}
	// override scanner if 1.4 or 1.5 asked for
	this.scanner = new Scanner(
		true /*comment*/,
		true /*whitespace*/,
		false /*nls*/,
		sourceLevel /*sourceLevel*/,
		complianceLevel /*complianceLevel*/,
		null/*taskTag*/,
		null/*taskPriorities*/,
		true/*taskCaseSensitive*/);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:55,代码来源:AST.java

示例8: versionFromJdkLevel

public static String versionFromJdkLevel(long jdkLevel) {
	switch ((int)(jdkLevel>>16)) {
		case ClassFileConstants.MAJOR_VERSION_1_1 :
			if (jdkLevel == ClassFileConstants.JDK1_1)
				return VERSION_1_1;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_2 :
			if (jdkLevel == ClassFileConstants.JDK1_2)
				return VERSION_1_2;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_3 :
			if (jdkLevel == ClassFileConstants.JDK1_3)
				return VERSION_1_3;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_4 :
			if (jdkLevel == ClassFileConstants.JDK1_4)
				return VERSION_1_4;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_5 :
			if (jdkLevel == ClassFileConstants.JDK1_5)
				return VERSION_1_5;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_6 :
			if (jdkLevel == ClassFileConstants.JDK1_6)
				return VERSION_1_6;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_7 :
			if (jdkLevel == ClassFileConstants.JDK1_7)
				return VERSION_1_7;
			break;
	}
	return Util.EMPTY_STRING; // unknown version
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:CompilerOptions.java

示例9: versionToJdkLevel

public static long versionToJdkLevel(Object versionID) {
	if (versionID instanceof String) {
		String version = (String) versionID;
		// verification is optimized for all versions with same length and same "1." prefix
		if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
			switch (version.charAt(2)) {
				case '1':
					return ClassFileConstants.JDK1_1;
				case '2':
					return ClassFileConstants.JDK1_2;
				case '3':
					return ClassFileConstants.JDK1_3;
				case '4':
					return ClassFileConstants.JDK1_4;
				case '5':
					return ClassFileConstants.JDK1_5;
				case '6':
					return ClassFileConstants.JDK1_6;
				case '7':
					return ClassFileConstants.JDK1_7;
				case '8':
					return ClassFileConstants.JDK1_8;
				default:
					return 0; // unknown
			}
		}
		if (VERSION_JSR14.equals(versionID)) {
			return ClassFileConstants.JDK1_4;
		}
		if (VERSION_CLDC1_1.equals(versionID)) {
			return ClassFileConstants.CLDC_1_1;
		}
	}
	return 0; // unknown
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:CompilerOptions.java

示例10: versionFromJdkLevel

public static String versionFromJdkLevel(long jdkLevel) {
	switch ((int)(jdkLevel>>16)) {
		case ClassFileConstants.MAJOR_VERSION_1_1 :
			if (jdkLevel == ClassFileConstants.JDK1_1)
				return VERSION_1_1;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_2 :
			if (jdkLevel == ClassFileConstants.JDK1_2)
				return VERSION_1_2;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_3 :
			if (jdkLevel == ClassFileConstants.JDK1_3)
				return VERSION_1_3;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_4 :
			if (jdkLevel == ClassFileConstants.JDK1_4)
				return VERSION_1_4;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_5 :
			if (jdkLevel == ClassFileConstants.JDK1_5)
				return VERSION_1_5;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_6 :
			if (jdkLevel == ClassFileConstants.JDK1_6)
				return VERSION_1_6;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_7 :
			if (jdkLevel == ClassFileConstants.JDK1_7)
				return VERSION_1_7;
			break;
		case ClassFileConstants.MAJOR_VERSION_1_8 :
			if (jdkLevel == ClassFileConstants.JDK1_8)
				return VERSION_1_8;
			break;
	}
	return Util.EMPTY_STRING; // unknown version
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:CompilerOptions.java

示例11: createScanner

/**
 * Create a scanner, indicating the level of detail requested for tokenizing. The scanner can then be
 * used to tokenize some source in a Java aware way.
 * Here is a typical scanning loop:
 *
 * <code>
 * <pre>
 *   IScanner scanner = ToolFactory.createScanner(false, false, false, false);
 *   scanner.setSource("int i = 0;".toCharArray());
 *   while (true) {
 *     int token = scanner.getNextToken();
 *     if (token == ITerminalSymbols.TokenNameEOF) break;
 *     System.out.println(token + " : " + new String(scanner.getCurrentTokenSource()));
 *   }
 * </pre>
 * </code>
 *
 * <p>By default the compliance used to create the scanner is the workspace's compliance when running inside the IDE
 * or 1.4 if running from outside of a headless eclipse.
 * </p>
 *
 * @param tokenizeComments if set to <code>false</code>, comments will be silently consumed
 * @param tokenizeWhiteSpace if set to <code>false</code>, white spaces will be silently consumed,
 * @param assertMode if set to <code>false</code>, occurrences of 'assert' will be reported as identifiers
 * ({@link ITerminalSymbols#TokenNameIdentifier}), whereas if set to <code>true</code>, it
 * would report assert keywords ({@link ITerminalSymbols#TokenNameassert}). Java 1.4 has introduced
 * a new 'assert' keyword.
 * @param recordLineSeparator if set to <code>true</code>, the scanner will record positions of encountered line
 * separator ends. In case of multi-character line separators, the last character position is considered. These positions
 * can then be extracted using {@link IScanner#getLineEnds()}. Only non-unicode escape sequences are
 * considered as valid line separators.
 	 * @return a scanner
 * @see org.eclipse.jdt.core.compiler.IScanner
 * @see #createScanner(boolean, boolean, boolean, String, String)
 */
public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator){
	// use default workspace compliance
	long complianceLevelValue = CompilerOptions.versionToJdkLevel(JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE));
	if (complianceLevelValue == 0) complianceLevelValue = ClassFileConstants.JDK1_4; // fault-tolerance
	PublicScanner scanner =
		new PublicScanner(
			tokenizeComments,
			tokenizeWhiteSpace,
			false/*nls*/,
			assertMode ? ClassFileConstants.JDK1_4 : ClassFileConstants.JDK1_3/*sourceLevel*/,
			complianceLevelValue,
			null/*taskTags*/,
			null/*taskPriorities*/,
			true/*taskCaseSensitive*/);
	scanner.recordLineSeparator = recordLineSeparator;
	return scanner;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:52,代码来源:ToolFactory.java

示例12: generateSyntheticEnclosingInstanceValues

/**
 * Code responsible to generate the suitable code to supply values for the synthetic enclosing
 * instance arguments of a constructor invocation of a nested type.
 */
public void generateSyntheticEnclosingInstanceValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, ASTNode invocationSite) {
	// supplying enclosing instance for the anonymous type's superclass
	ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? (ReferenceBinding)targetType.superclass().erasure() : targetType;
	boolean hasExtraEnclosingInstance = enclosingInstance != null;
	if (hasExtraEnclosingInstance
			&& (!checkedTargetType.isNestedType() || checkedTargetType.isStatic())) {
		currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
		return;
	}

	// perform some emulation work in case there is some and we are inside a local type only
	ReferenceBinding[] syntheticArgumentTypes;
	if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes()) != null) {

		ReferenceBinding targetEnclosingType = checkedTargetType.enclosingType();
		long compliance = currentScope.compilerOptions().complianceLevel;

		// deny access to enclosing instance argument for allocation and super constructor call (if 1.4)
		// always consider it if complying to 1.5
		boolean denyEnclosingArgInConstructorCall;
		if (compliance <= ClassFileConstants.JDK1_3) {
			denyEnclosingArgInConstructorCall = invocationSite instanceof AllocationExpression;
		} else if (compliance == ClassFileConstants.JDK1_4){
			denyEnclosingArgInConstructorCall = invocationSite instanceof AllocationExpression
				|| invocationSite instanceof ExplicitConstructorCall && ((ExplicitConstructorCall)invocationSite).isSuperAccess();
		} else {
			//compliance >= JDK1_5
			denyEnclosingArgInConstructorCall = (invocationSite instanceof AllocationExpression
					|| invocationSite instanceof ExplicitConstructorCall && ((ExplicitConstructorCall)invocationSite).isSuperAccess())
				&& !targetType.isLocalType();
		}

		boolean complyTo14 = compliance >= ClassFileConstants.JDK1_4;
		for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
			ReferenceBinding syntheticArgType = syntheticArgumentTypes[i];
			if (hasExtraEnclosingInstance && TypeBinding.equalsEquals(syntheticArgType, targetEnclosingType)) {
				hasExtraEnclosingInstance = false;
				enclosingInstance.generateCode(currentScope, this, true);
				if (complyTo14){
					dup();
					invokeObjectGetClass(); // will perform null check
					pop();
				}
			} else {
				Object[] emulationPath = currentScope.getEmulationPath(
						syntheticArgType,
						false /*not only exact match (that is, allow compatible)*/,
						denyEnclosingArgInConstructorCall);
				generateOuterAccess(emulationPath, invocationSite, syntheticArgType, currentScope);
			}
		}
		if (hasExtraEnclosingInstance){
			currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:60,代码来源:CodeStream.java

示例13: generateCode

public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
	int pc = codeStream.position;
	if ((this.bits & Binding.VARIABLE) == 0) { // nothing to do if type ref
		codeStream.recordPositionsFrom(pc, this.sourceStart);
		return;
	}
	FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1];
	if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) {
		super.generateCode(currentScope, codeStream, valueRequired);
		return;
	}
	lastFieldBinding = generateReadSequence(currentScope, codeStream);
	if (lastFieldBinding != null) {
		boolean isStatic = lastFieldBinding.isStatic();
		Constant fieldConstant = lastFieldBinding.constant();
		if (fieldConstant != Constant.NotAConstant) {
			if (!isStatic){
				codeStream.invokeObjectGetClass();
				codeStream.pop();
			}
			if (valueRequired) { // inline the last field constant
				codeStream.generateConstant(fieldConstant, this.implicitConversion);
			}
		} else {
			boolean isFirst = lastFieldBinding == this.binding
											&& (this.indexOfFirstFieldBinding == 1 || TypeBinding.equalsEquals(lastFieldBinding.declaringClass, currentScope.enclosingReceiverType()))
											&& this.otherBindings == null; // could be dup: next.next.next
			TypeBinding requiredGenericCast = getGenericCast(this.otherBindings == null ? 0 : this.otherBindings.length);
			if (valueRequired
					|| (!isFirst && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4)
					|| ((this.implicitConversion & TypeIds.UNBOXING) != 0)
					|| requiredGenericCast != null) {
				int lastFieldPc = codeStream.position;
				if (lastFieldBinding.declaringClass == null) { // array length
					codeStream.arraylength();
					if (valueRequired) {
						codeStream.generateImplicitConversion(this.implicitConversion);
					} else {
						// could occur if !valueRequired but compliance >= 1.4
						codeStream.pop();
					}
				} else {
					codeStream.generateEmulatedReadAccessForField(lastFieldBinding);
					if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast);
					if (valueRequired) {
						codeStream.generateImplicitConversion(this.implicitConversion);
					} else {
						boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
						// conversion only generated if unboxing
						if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion);
						switch (isUnboxing ? postConversionType(currentScope).id : lastFieldBinding.type.id) {
							case T_long :
							case T_double :
								codeStream.pop2();
								break;
							default :
								codeStream.pop();
						}
					}
				}

				int fieldPosition = (int) (this.sourcePositions[this.sourcePositions.length - 1] >>> 32);
				codeStream.recordPositionsFrom(lastFieldPc, fieldPosition);
			} else {
				if (!isStatic){
					codeStream.invokeObjectGetClass(); // perform null check
					codeStream.pop();
				}
			}
		}
	}
	codeStream.recordPositionsFrom(pc, this.sourceStart);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:73,代码来源:CodeSnippetQualifiedNameReference.java

示例14: findDefaultAbstractMethod

protected MethodBinding findDefaultAbstractMethod(
	ReferenceBinding receiverType,
	char[] selector,
	TypeBinding[] argumentTypes,
	InvocationSite invocationSite,
	ReferenceBinding classHierarchyStart,
	ObjectVector found,
	MethodBinding concreteMatch) {

	int startFoundSize = found.size;
	ReferenceBinding currentType = classHierarchyStart;
	while (currentType != null) {
		findMethodInSuperInterfaces(currentType, selector, found, invocationSite);
		currentType = currentType.superclass();
	}
	MethodBinding[] candidates = null;
	int candidatesCount = 0;
	MethodBinding problemMethod = null;
	int foundSize = found.size;
	if (foundSize > startFoundSize) {
		// argument type compatibility check
		for (int i = startFoundSize; i < foundSize; i++) {
			MethodBinding methodBinding = (MethodBinding) found.elementAt(i);
			MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite);
			if (compatibleMethod != null) {
				if (compatibleMethod.isValidBinding()) {
					if (concreteMatch != null && environment().methodVerifier().areMethodsCompatible(concreteMatch, compatibleMethod))
						continue; // can skip this method since concreteMatch overrides it
					if (candidatesCount == 0) {
						candidates = new MethodBinding[foundSize - startFoundSize + 1];
						if (concreteMatch != null)
							candidates[candidatesCount++] = concreteMatch;
					}
					candidates[candidatesCount++] = compatibleMethod;
				} else if (problemMethod == null) {
					problemMethod = compatibleMethod;
				}
			}
		}
	}

	if (candidatesCount < 2) {
		if (concreteMatch == null) {
			if (candidatesCount == 0)
				return problemMethod; // can be null
			concreteMatch = candidates[0];
		}
		compilationUnitScope().recordTypeReferences(concreteMatch.thrownExceptions);
		return concreteMatch;
	}
	// no need to check for visibility - interface methods are public
	if (compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4)
		return mostSpecificMethodBinding(candidates, candidatesCount, argumentTypes, invocationSite, receiverType);
	return mostSpecificInterfaceMethodBinding(candidates, candidatesCount, invocationSite);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:55,代码来源:Scope.java

示例15: addFieldAttributes

private int addFieldAttributes(FieldBinding fieldBinding, int fieldAttributeOffset) {
	int attributesNumber = 0;
	// 4.7.2 only static constant fields get a ConstantAttribute
	// Generate the constantValueAttribute
	Constant fieldConstant = fieldBinding.constant();
	if (fieldConstant != Constant.NotAConstant){
		attributesNumber += generateConstantValueAttribute(fieldConstant, fieldBinding, fieldAttributeOffset);
	}
	if (this.targetJDK < ClassFileConstants.JDK1_5 && fieldBinding.isSynthetic()) {
		attributesNumber += generateSyntheticAttribute();
	}
	if (fieldBinding.isDeprecated()) {
		attributesNumber += generateDeprecatedAttribute();
	}
	// add signature attribute
	char[] genericSignature = fieldBinding.genericSignature();
	if (genericSignature != null) {
		attributesNumber += generateSignatureAttribute(genericSignature);
	}
	if (this.targetJDK >= ClassFileConstants.JDK1_4) {
		FieldDeclaration fieldDeclaration = fieldBinding.sourceField();
		if (fieldDeclaration != null) {
			Annotation[] annotations = fieldDeclaration.annotations;
			if (annotations != null) {
				attributesNumber += generateRuntimeAnnotations(annotations, TagBits.AnnotationForField);
			}

			if ((this.produceAttributes & ClassFileConstants.ATTR_TYPE_ANNOTATION) != 0) {
				List allTypeAnnotationContexts = new ArrayList();
				if (annotations != null && (fieldDeclaration.bits & ASTNode.HasTypeAnnotations) != 0) {
					fieldDeclaration.getAllAnnotationContexts(AnnotationTargetTypeConstants.FIELD, allTypeAnnotationContexts);
				}
				int invisibleTypeAnnotationsCounter = 0;
				int visibleTypeAnnotationsCounter = 0;
				TypeReference fieldType = fieldDeclaration.type;
				if (fieldType != null && ((fieldType.bits & ASTNode.HasTypeAnnotations) != 0)) {
					fieldType.getAllAnnotationContexts(AnnotationTargetTypeConstants.FIELD, allTypeAnnotationContexts);
				}
				int size = allTypeAnnotationContexts.size();
				if (size != 0) {
					AnnotationContext[] allTypeAnnotationContextsArray = new AnnotationContext[size];
					allTypeAnnotationContexts.toArray(allTypeAnnotationContextsArray);
					for (int i = 0, max = allTypeAnnotationContextsArray.length; i < max; i++) {
						AnnotationContext annotationContext = allTypeAnnotationContextsArray[i];
						if ((annotationContext.visibility & AnnotationContext.INVISIBLE) != 0) {
							invisibleTypeAnnotationsCounter++;
							allTypeAnnotationContexts.add(annotationContext);
						} else {
							visibleTypeAnnotationsCounter++;
							allTypeAnnotationContexts.add(annotationContext);
						}
					}
					attributesNumber += generateRuntimeTypeAnnotations(
							allTypeAnnotationContextsArray,
							visibleTypeAnnotationsCounter,
							invisibleTypeAnnotationsCounter);
				}
			}
		}
	}
	if ((fieldBinding.tagBits & TagBits.HasMissingType) != 0) {
		this.missingTypes = fieldBinding.type.collectMissingTypes(this.missingTypes);
	}
	return attributesNumber;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:65,代码来源:ClassFile.java


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