org.eclipse.jdt.internal.compiler.lookup.TypeBinding Java Examples
The following examples show how to use
org.eclipse.jdt.internal.compiler.lookup.TypeBinding.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConstantPool.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public int literalIndexForMethodHandle(int referenceKind, TypeBinding declaringClass, char[] selector, char[] signature, boolean isInterface) { int indexForMethod = literalIndexForMethod(declaringClass, selector, signature, isInterface); int index = this.currentIndex++; int length = this.offsets.length; if (length <= index) { // resize System.arraycopy(this.offsets, 0, (this.offsets = new int[index * 2]), 0, length); } this.offsets[index] = this.currentOffset; writeU1(MethodHandleTag); writeU1(referenceKind); writeU2(indexForMethod); return index; }
Example #2
Source File: CastExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Complain if assigned expression is cast, but not actually used as such, e.g. Object o = (List) object; */ public static void checkNeedForAssignedCast(BlockScope scope, TypeBinding expectedType, CastExpression rhs) { CompilerOptions compilerOptions = scope.compilerOptions(); if (compilerOptions.getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return; TypeBinding castedExpressionType = rhs.expression.resolvedType; // int i = (byte) n; // cast still had side effect // double d = (float) n; // cast to float is unnecessary if (castedExpressionType == null || rhs.resolvedType.isBaseType()) return; //if (castedExpressionType.id == T_null) return; // tolerate null expression cast if (castedExpressionType.isCompatibleWith(expectedType, scope)) { if (compilerOptions.isAnnotationBasedNullAnalysisEnabled && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8) { // are null annotations compatible, too? if (NullAnnotationMatching.analyse(expectedType, castedExpressionType, -1).isAnyMismatch()) return; // already reported unchecked cast (nullness), say no more. } scope.problemReporter().unnecessaryCast(rhs); } }
Example #3
Source File: JavaStatementPostfixContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * This is a recursive method which performs a depth first search in the inheritance graph of the given {@link TypeBinding}. * * @param sb a TypeBinding * @param signature a fully qualified type * @return true if the given TypeBinding itself or one of its superclass/superinterfaces resolves to the given signature. false otherwise. */ private boolean resolvesReferenceBindingTo(TypeBinding sb, String signature) { if (sb == null) { return false; } if (new String(sb.readableName()).startsWith(signature) || (sb instanceof ArrayBinding && "array".equals(signature))) { return true; } List<ReferenceBinding> bindings = new ArrayList<>(); Collections.addAll(bindings, sb.superInterfaces()); bindings.add(sb.superclass()); boolean result = false; Iterator<ReferenceBinding> it = bindings.iterator(); while (it.hasNext() && result == false) { result = resolvesReferenceBindingTo(it.next(), signature); } return result; }
Example #4
Source File: CastExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Determines whether apparent unnecessary cast wasn't actually used to * perform return type inference of generic method invocation or boxing. */ private boolean isIndirectlyUsed() { if (this.expression instanceof MessageSend) { MethodBinding method = ((MessageSend)this.expression).binding; if (method instanceof ParameterizedGenericMethodBinding && ((ParameterizedGenericMethodBinding)method).inferredReturnType) { if (this.expectedType == null) return true; if (TypeBinding.notEquals(this.resolvedType, this.expectedType)) return true; } } if (this.expectedType != null && this.resolvedType.isBaseType() && !this.resolvedType.isCompatibleWith(this.expectedType)) { // boxing: Short s = (short) _byte return true; } return false; }
Example #5
Source File: LambdaExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public boolean isPertinentToApplicability(TypeBinding targetType, MethodBinding method) { if (targetType == null) // assumed to signal another primary error return true; if (argumentsTypeElided()) return false; if (!super.isPertinentToApplicability(targetType, method)) return false; if (this.body instanceof Expression) { if (!((Expression) this.body).isPertinentToApplicability(targetType, method)) return false; } else { Expression [] returnExpressions = this.resultExpressions; for (int i = 0, length = returnExpressions.length; i < length; i++) { if (!returnExpressions[i].isPertinentToApplicability(targetType, method)) return false; } } return true; }
Example #6
Source File: FakedTrackingVariable.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Before analyzing an assignment of this shape: <code>singleName = new Allocation()</code> * connect any tracking variable of the LHS with the allocation on the RHS. * Also the assignment is temporarily stored in the tracking variable in case we need to * report errors because the assignment leaves the old LHS value unclosed. * In this case the assignment should be used as the error location. * * @param location the assignment/local declaration being analyzed * @param local the local variable being assigned to * @param rhs the rhs of the assignment resp. the initialization of the local variable declaration. * <strong>Precondition:</strong> client has already checked that the resolved type of this expression is either a closeable type or NULL. */ public static void preConnectTrackerAcrossAssignment(ASTNode location, LocalVariableBinding local, Expression rhs, FlowInfo flowInfo) { FakedTrackingVariable closeTracker = null; if (containsAllocation(rhs)) { closeTracker = local.closeTracker; if (closeTracker == null) { if (rhs.resolvedType != TypeBinding.NULL) { // not NULL means valid closeable as per method precondition closeTracker = new FakedTrackingVariable(local, location, flowInfo, null, FlowInfo.UNKNOWN); if (local.isParameter()) { closeTracker.globalClosingState |= OWNED_BY_OUTSIDE; } } } if (closeTracker != null) { closeTracker.currentAssignment = location; preConnectTrackerAcrossAssignment(location, local, flowInfo, closeTracker, rhs); } } }
Example #7
Source File: CompletionOnJavadocFieldReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected TypeBinding internalResolveType(Scope scope) { if (this.token != null) { return super.internalResolveType(scope); } // Resolve only receiver if (this.receiver == null) { this.actualReceiverType = scope.enclosingSourceType(); } else if (scope.kind == Scope.CLASS_SCOPE) { this.actualReceiverType = this.receiver.resolveType((ClassScope) scope); } else { this.actualReceiverType = this.receiver.resolveType((BlockScope)scope); } return null; }
Example #8
Source File: ExceptionHandlingFlowContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void recordHandlingException( ReferenceBinding exceptionType, UnconditionalFlowInfo flowInfo, TypeBinding raisedException, TypeBinding caughtException, ASTNode invocationSite, boolean wasAlreadyDefinitelyCaught) { int index = this.indexes.get(exceptionType); int cacheIndex = index / ExceptionHandlingFlowContext.BitCacheSize; int bitMask = 1 << (index % ExceptionHandlingFlowContext.BitCacheSize); if (!wasAlreadyDefinitelyCaught) { this.isNeeded[cacheIndex] |= bitMask; } this.isReached[cacheIndex] |= bitMask; int catchBlock = this.exceptionToCatchBlockMap != null? this.exceptionToCatchBlockMap[index] : index; if (caughtException != null && this.catchArguments != null && this.catchArguments.length > 0 && !wasAlreadyDefinitelyCaught) { CatchParameterBinding catchParameter = (CatchParameterBinding) this.catchArguments[catchBlock].binding; catchParameter.setPreciseType(caughtException); } this.initsOnExceptions[catchBlock] = (this.initsOnExceptions[catchBlock].tagBits & FlowInfo.UNREACHABLE) == 0 ? this.initsOnExceptions[catchBlock].mergedWith(flowInfo): flowInfo.unconditionalCopy(); }
Example #9
Source File: PatchVal.java From EasyMPermission with MIT License | 6 votes |
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; }
Example #10
Source File: CodeSnippetMessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { // if method from parameterized type got found, use the original method at codegen time MethodBinding codegenBinding = this.binding.original(); if (codegenBinding != this.binding) { // extra cast needed if method return type was type variable if (codegenBinding.returnType.isTypeVariable()) { TypeVariableBinding variableReturnType = (TypeVariableBinding) codegenBinding.returnType; if (TypeBinding.notEquals(variableReturnType.firstBound, this.binding.returnType)) { // no need for extra cast if same as first bound anyway this.valueCast = this.binding.returnType; } } } } }
Example #11
Source File: PatchExtensionMethod.java From EasyMPermission with MIT License | 6 votes |
private static NameReference createNameRef(TypeBinding typeBinding, ASTNode source) { long p = ((long) source.sourceStart << 32) | source.sourceEnd; char[] pkg = typeBinding.qualifiedPackageName(); char[] basename = typeBinding.qualifiedSourceName(); StringBuilder sb = new StringBuilder(); if (pkg != null) sb.append(pkg); if (sb.length() > 0) sb.append("."); sb.append(basename); String tName = sb.toString(); if (tName.indexOf('.') == -1) { return new SingleNameReference(basename, p); } else { char[][] sources; String[] in = tName.split("\\."); sources = new char[in.length][]; for (int i = 0; i < in.length; i++) sources[i] = in[i].toCharArray(); long[] poss = new long[in.length]; Arrays.fill(poss, p); return new QualifiedNameReference(sources, poss, source.sourceStart, source.sourceEnd); } }
Example #12
Source File: ASTNode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static TypeBinding mergeAnnotationsIntoType(BlockScope scope, AnnotationBinding[] se8Annotations, long se8nullBits, Annotation se8NullAnnotation, TypeReference typeRef, TypeBinding existingType) { if (existingType == null || !existingType.isValidBinding()) return existingType; TypeReference unionRef = typeRef.isUnionType() ? ((UnionTypeReference) typeRef).typeReferences[0] : null; // for arrays: @T X[] SE7 associates @T to the type, but in SE8 it affects the leaf component type long prevNullBits = existingType.leafComponentType().tagBits & TagBits.AnnotationNullMASK; if (se8nullBits != 0 && prevNullBits != se8nullBits && ((prevNullBits | se8nullBits) == TagBits.AnnotationNullMASK)) { scope.problemReporter().contradictoryNullAnnotations(se8NullAnnotation); } TypeBinding oldLeafType = (unionRef == null) ? existingType.leafComponentType() : unionRef.resolvedType; AnnotationBinding [][] goodies = new AnnotationBinding[typeRef.getAnnotatableLevels()][]; goodies[0] = se8Annotations; // @T X.Y.Z local; ==> @T should annotate X TypeBinding newLeafType = scope.environment().createAnnotatedType(oldLeafType, goodies); if (unionRef == null) { typeRef.resolvedType = existingType.isArrayType() ? scope.environment().createArrayType(newLeafType, existingType.dimensions(), existingType.getTypeAnnotations()) : newLeafType; } else { unionRef.resolvedType = newLeafType; unionRef.bits |= HasTypeAnnotations; } return typeRef.resolvedType; }
Example #13
Source File: MethodBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * @see IMethodBinding#getExceptionTypes() */ public ITypeBinding[] getExceptionTypes() { if (this.exceptionTypes != null) { return this.exceptionTypes; } org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] exceptions = this.binding.thrownExceptions; int length = exceptions == null ? 0 : exceptions.length; if (length == 0) { return this.exceptionTypes = NO_TYPE_BINDINGS; } ITypeBinding[] exTypes = new ITypeBinding[length]; for (int i = 0; i < length; i++) { ITypeBinding typeBinding = this.resolver.getTypeBinding(exceptions[i]); if (typeBinding == null) { return this.exceptionTypes = NO_TYPE_BINDINGS; } exTypes[i] = typeBinding; } return this.exceptionTypes = exTypes; }
Example #14
Source File: ExceptionHandlingFlowContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void mergeUnhandledException(TypeBinding newException){ if (this.extendedExceptions == null){ this.extendedExceptions = new ArrayList(5); for (int i = 0; i < this.handledExceptions.length; i++){ this.extendedExceptions.add(this.handledExceptions[i]); } } boolean isRedundant = false; for(int i = this.extendedExceptions.size()-1; i >= 0; i--){ switch(Scope.compareTypes(newException, (TypeBinding)this.extendedExceptions.get(i))){ case Scope.MORE_GENERIC : this.extendedExceptions.remove(i); break; case Scope.EQUAL_OR_MORE_SPECIFIC : isRedundant = true; break; case Scope.NOT_RELATED : break; } } if (!isRedundant){ this.extendedExceptions.add(newException); } }
Example #15
Source File: SelectionRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void acceptLocalType(TypeBinding typeBinding) { IJavaElement res = null; if(typeBinding instanceof ParameterizedTypeBinding) { LocalTypeBinding localTypeBinding = (LocalTypeBinding)((ParameterizedTypeBinding)typeBinding).genericType(); res = findLocalElement(localTypeBinding.sourceStart()); } else if(typeBinding instanceof SourceTypeBinding) { res = findLocalElement(((SourceTypeBinding)typeBinding).sourceStart()); } if(res != null && res.getElementType() == IJavaElement.TYPE) { res = ((JavaElement)res).resolved(typeBinding); addElement(res); if(SelectionEngine.DEBUG){ System.out.print("SELECTION - accept type("); //$NON-NLS-1$ System.out.print(res.toString()); System.out.println(")"); //$NON-NLS-1$ } } }
Example #16
Source File: TypeAnnotationCodeStream.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void checkcast(TypeReference typeReference, TypeBinding typeBinding) { /* We use a slightly sub-optimal generation for intersection casts by resorting to a runtime cast for every intersecting type, but in reality this should not matter. In its intended use form such as (I & Serializable) () -> {}, no cast is emitted at all. Also note intersection cast type references cannot nest i.e ((X & I) & J) is not valid syntax. */ if (typeReference != null) { TypeReference [] typeReferences = typeReference.getTypeReferences(); for (int i = typeReferences.length - 1; i >= 0; i--) { // need to emit right to left. typeReference = typeReferences[i]; if (typeReference != null) { if ((typeReference.bits & ASTNode.HasTypeAnnotations) != 0) addAnnotationContext(typeReference, this.position, i, AnnotationTargetTypeConstants.CAST); super.checkcast(typeReference, typeReference.resolvedType); } } } else { super.checkcast(null, typeBinding); } }
Example #17
Source File: FlowContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public FlowInfo getInitsForFinalBlankInitializationCheck(TypeBinding declaringType, FlowInfo flowInfo) { FlowContext current = this; FlowInfo inits = flowInfo; do { if (current instanceof InitializationFlowContext) { InitializationFlowContext initializationContext = (InitializationFlowContext) current; if (TypeBinding.equalsEquals(((TypeDeclaration)initializationContext.associatedNode).binding, declaringType)) { return inits; } inits = initializationContext.initsBeforeContext; current = initializationContext.initializationParent; } else if (current instanceof ExceptionHandlingFlowContext) { ExceptionHandlingFlowContext exceptionContext = (ExceptionHandlingFlowContext) current; current = exceptionContext.initializationParent == null ? exceptionContext.getLocalParent() : exceptionContext.initializationParent; } else { current = current.getLocalParent(); } } while (current != null); // not found return null; }
Example #18
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public MethodBinding binding(TypeBinding targetType, boolean reportErrors, Scope scope) { if (reportErrors) { if (this.binding == null) scope.problemReporter().genericInferenceError("method is unexpectedly unresolved", this); //$NON-NLS-1$ else if (!this.binding.isValidBinding()) scope.problemReporter().invalidMethod(this, this.binding); } return this.binding; }
Example #19
Source File: VariableElementImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Object getConstantValue() { VariableBinding variableBinding = (VariableBinding) _binding; Constant constant = variableBinding.constant(); if (constant == null || constant == Constant.NotAConstant) return null; TypeBinding type = variableBinding.type; switch (type.id) { case TypeIds.T_boolean: return constant.booleanValue(); case TypeIds.T_byte: return constant.byteValue(); case TypeIds.T_char: return constant.charValue(); case TypeIds.T_double: return constant.doubleValue(); case TypeIds.T_float: return constant.floatValue(); case TypeIds.T_int: return constant.intValue(); case TypeIds.T_JavaLangString: return constant.stringValue(); case TypeIds.T_long: return constant.longValue(); case TypeIds.T_short: return constant.shortValue(); } return null; }
Example #20
Source File: WildcardTypeImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public TypeMirror getExtendsBound() { WildcardBinding wildcardBinding = (WildcardBinding) this._binding; if (wildcardBinding.boundKind != Wildcard.EXTENDS) return null; TypeBinding bound = wildcardBinding.bound; if (bound == null) return null; return _env.getFactory().newTypeMirror(bound); }
Example #21
Source File: WildcardTypeImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public TypeMirror getSuperBound() { WildcardBinding wildcardBinding = (WildcardBinding) this._binding; if (wildcardBinding.boundKind != Wildcard.SUPER) return null; TypeBinding bound = wildcardBinding.bound; if (bound == null) return null; return _env.getFactory().newTypeMirror(bound); }
Example #22
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public TypeBinding checkAgainstFinalTargetType(TypeBinding targetType, Scope scope) { if (this.binding instanceof ParameterizedGenericMethodBinding) { InferenceContext18 ctx = getInferenceContext((ParameterizedMethodBinding) this.binding); if (ctx != null && ctx.stepCompleted < InferenceContext18.TYPE_INFERRED) { this.expectedType = targetType; MethodBinding updatedBinding = ctx.inferInvocationType(this, (ParameterizedGenericMethodBinding) this.binding); if (updateBindings(updatedBinding, targetType)) { ASTNode.resolvePolyExpressionArguments(this, updatedBinding, scope); } } } return this.resolvedType; }
Example #23
Source File: TypeVariableImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public TypeMirror getUpperBound() { TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this._binding; TypeBinding firstBound = typeVariableBinding.firstBound; ReferenceBinding[] superInterfaces = typeVariableBinding.superInterfaces; if (firstBound == null || superInterfaces.length == 0) { // no explicit bound return _env.getFactory().newTypeMirror(typeVariableBinding.upperBound()); } if (firstBound != null && superInterfaces.length == 1 && TypeBinding.equalsEquals(superInterfaces[0], firstBound)) { // only one bound that is an interface return _env.getFactory().newTypeMirror(typeVariableBinding.upperBound()); } return this._env.getFactory().newTypeMirror((TypeVariableBinding) this._binding); }
Example #24
Source File: SelectionOnSingleNameReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public TypeBinding resolveType(BlockScope scope) { if (this.actualReceiverType != null) { this.binding = scope.getField(this.actualReceiverType, this.token, this); if (this.binding != null && this.binding.isValidBinding()) { throw new SelectionNodeFound(this.binding); } } // it can be a package, type, member type, local variable or field this.binding = scope.getBinding(this.token, Binding.VARIABLE | Binding.TYPE | Binding.PACKAGE, this, true /*resolve*/); if (!this.binding.isValidBinding()) { if (this.binding instanceof ProblemFieldBinding) { // tolerate some error cases if (this.binding.problemId() == ProblemReasons.NotVisible || this.binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName || this.binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation || this.binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext){ throw new SelectionNodeFound(this.binding); } scope.problemReporter().invalidField(this, (FieldBinding) this.binding); } else if (this.binding instanceof ProblemReferenceBinding || this.binding instanceof MissingTypeBinding) { // tolerate some error cases if (this.binding.problemId() == ProblemReasons.NotVisible){ throw new SelectionNodeFound(this.binding); } scope.problemReporter().invalidType(this, (TypeBinding) this.binding); } else { scope.problemReporter().unresolvableReference(this, this.binding); } throw new SelectionNodeFound(); } throw new SelectionNodeFound(this.binding); }
Example #25
Source File: SelectionOnMessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private MethodBinding findNonDefaultAbstractMethod(MethodBinding methodBinding) { ReferenceBinding[] itsInterfaces = methodBinding.declaringClass.superInterfaces(); if (itsInterfaces != Binding.NO_SUPERINTERFACES) { ReferenceBinding[] interfacesToVisit = itsInterfaces; int nextPosition = interfacesToVisit.length; for (int i = 0; i < nextPosition; i++) { ReferenceBinding currentType = interfacesToVisit[i]; MethodBinding[] methods = currentType.getMethods(methodBinding.selector); if(methods != null) { for (int k = 0; k < methods.length; k++) { if(methodBinding.areParametersEqual(methods[k])) return methods[k]; } } if ((itsInterfaces = currentType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface : for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (TypeBinding.equalsEquals(next, interfacesToVisit[b])) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } } return methodBinding; }
Example #26
Source File: ConstantPool.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public int literalIndex(TypeBinding binding) { TypeBinding typeBinding = binding.leafComponentType(); if ((typeBinding.tagBits & TagBits.ContainsNestedTypeReferences) != 0) { Util.recordNestedType(this.classFile, typeBinding); } return literalIndex(binding.signature()); }
Example #27
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean updateBindings(MethodBinding updatedBinding, TypeBinding targetType) { boolean hasUpdate = this.binding != updatedBinding; if (this.inferenceContexts != null) { InferenceContext18 ctx = (InferenceContext18)this.inferenceContexts.removeKey(this.binding); if (ctx != null && updatedBinding instanceof ParameterizedGenericMethodBinding) { this.inferenceContexts.put(updatedBinding, ctx); // solution may have come from an outer inference, mark now that this (inner) is done (but not deep inners): hasUpdate |= ctx.registerSolution(targetType, updatedBinding); } } this.binding = updatedBinding; this.resolvedType = updatedBinding.returnType; return hasUpdate; }
Example #28
Source File: TypesImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public ArrayType getArrayType(TypeMirror componentType) { TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) componentType; TypeBinding typeBinding = (TypeBinding) typeMirrorImpl._binding; return (ArrayType) _env.getFactory().newTypeMirror( this._env.getLookupEnvironment().createArrayType( typeBinding.leafComponentType(), typeBinding.dimensions() + 1)); }
Example #29
Source File: CodeSnippetReturnStatement.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void generateStoreSaveValueIfNecessary(CodeStream codeStream){ // push receiver codeStream.aload_0(); // push the 2 parameters of "setResult(Object, Class)" if (this.expression == null || this.expression.resolvedType == TypeBinding.VOID) { // expressionType == VoidBinding if code snippet is the expression "System.out.println()" // push null codeStream.aconst_null(); // void.class codeStream.generateClassLiteralAccessForType(TypeBinding.VOID, null); } else { // swap with expression int valueTypeID = this.expression.resolvedType.id; if (valueTypeID == T_long || valueTypeID == T_double) { codeStream.dup_x2(); codeStream.pop(); } else { codeStream.swap(); } // generate wrapper if needed if (this.expression.resolvedType.isBaseType() && this.expression.resolvedType != TypeBinding.NULL) { codeStream.generateBoxingConversion(this.expression.resolvedType.id); } // generate the expression type codeStream.generateClassLiteralAccessForType(this.expression.resolvedType, null); } // generate the invoke virtual to "setResult(Object,Class)" codeStream.invoke(Opcodes.OPC_invokevirtual, this.setResultMethod, null /* default declaringClass */); }
Example #30
Source File: SelectionOnNameOfMemberValuePair.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resolveTypeExpecting(BlockScope scope, TypeBinding requiredType) { super.resolveTypeExpecting(scope, requiredType); if(this.binding != null) { throw new SelectionNodeFound(this.binding); } throw new SelectionNodeFound(); }