@Override public void acceptName(char[] name) { CompletionEngine.this.acceptUnresolvedName(name); proposedNames.add(name); } };
private void addForbiddenBindingsForMemberTypes(TypeDeclaration typeDeclaration) { TypeDeclaration[] memberTypes = typeDeclaration.memberTypes; int memberTypesLen = memberTypes == null ? 0 : memberTypes.length; for (int i = 0; i < memberTypesLen; i++) { addForbiddenBindings(memberTypes[i].binding); addForbiddenBindingsForMemberTypes(memberTypes[i]); } }
private void computeUninterestingBindings(ASTNode parent, Scope scope){ if(parent instanceof LocalDeclaration) { addUninterestingBindings(((LocalDeclaration)parent).binding); } else if (parent instanceof FieldDeclaration) { addUninterestingBindings(((FieldDeclaration)parent).binding); } }
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); allowingLongComputationProposals && this.assistNodeIsConstructor && (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) || !isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)); checkCancel(); findNestedTypes(token, scope.enclosingSourceType(), scope, proposeAllMemberTypes, typesFound); if(!this.assistNodeIsInterface && !this.assistNodeIsConstructor && checkCancel(); findTypeParameters(token, scope); checkCancel(); if(isForbidden(sourceType)) continue next; findSubMemberTypes( token, sourceType, if (isFailedMatch(token, sourceType.sourceName)) continue next; if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) { continue next;
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); allowingLongComputationProposals && this.assistNodeIsConstructor && (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) || !isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)); checkCancel(); if (isForbidden(sourceType)) continue; if (this.assistNodeIsClass && sourceType.isInterface()) continue; if (this.assistNodeIsInterface && sourceType.isClass()) continue; int relevance = computeBaseRelevance(); relevance += computeRelevanceForResolution(); relevance += computeRelevanceForInterestingProposal(sourceType); relevance += computeRelevanceForCaseMatching(qualifiedName, qualifiedSourceTypeName); relevance += computeRelevanceForExpectingType(sourceType); relevance += computeRelevanceForQualification(false); relevance += computeRelevanceForRestrictions(accessibility); relevance += computeRelevanceForAnnotation(); } else if (sourceType.isInterface()) { relevance += computeRelevanceForInterface(); } else if (sourceType.isClass()) { relevance += computeRelevanceForClass(); relevance += computeRelevanceForException(sourceType.sourceName); (!this.assistNodeIsConstructor ||
this.assistNodeIsConstructor = singleRef.isConstructorType; this.assistNodeIsSuperType = singleRef.isSuperType(); this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); (astNodeParent instanceof ParameterizedSingleTypeReference || astNodeParent instanceof ParameterizedQualifiedTypeReference)) { this.setSourceAndTokenRange(astNode.sourceStart, astNode.sourceStart - 1, false); findParameterizedType((TypeReference)astNodeParent, scope); } else { ObjectVector typesFound = new ObjectVector(); if (this.assistNodeIsException && astNodeParent instanceof TryStatement) { findExceptionFromTryStatement( this.completionToken, null, checkCancel(); findTypesAndPackages(this.completionToken, scope, this.assistNodeIsConstructor, false, typesFound); findMemberTypes( this.completionToken, (ReferenceBinding) qualifiedBinding,
this.assistNodeIsInterface = ref.isInterface(); this.assistNodeIsSuperType = ref.isSuperType(); this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition); (this.requestor.isAllowingRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF))) { if(ref.tokens.length == 1) { findMemberTypesFromMissingType( ref, ref.sourcePositions[0], ObjectVector typesFound = new ObjectVector(); if (this.assistNodeIsException && astNodeParent instanceof TryStatement) { findExceptionFromTryStatement( this.completionToken, (ReferenceBinding)qualifiedBinding, checkCancel(); findMemberTypes( this.completionToken, (ReferenceBinding) qualifiedBinding,
if(binding != null) { if(!(variable.initialization instanceof ArrayInitializer)) { addExpectedType(binding, scope); } else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747 addExpectedType(binding, scope); TypeBinding binding = ((Assignment)parent).lhs.resolvedType; if(binding != null) { addExpectedType(binding, scope); TypeBinding binding = methodBinding == null ? null : methodBinding.returnType; if(binding != null) { addExpectedType(binding, scope); TypeBinding binding = methodBinding == null ? null : methodBinding.returnType; if (binding != null) { addExpectedType(binding, scope); TypeBinding binding = e.resolvedType; if(binding != null){ addExpectedType(binding, scope); this.expectedTypesFilter = SUBTYPE | SUPERTYPE; computeExpectedTypesForMessageSend( binding, messageSend.selector, messageSend,
this.assistNodeIsConstructor = ref.isConstructorType; this.assistNodeIsSuperType = ref.isSuperType(); this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition); if (this.assistNodeInJavadoc == 0 && (this.requestor.isAllowingRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF))) { if(ref.tokens.length == 1) { findMemberTypesFromMissingType( ref.tokens[0], ref.sourcePositions[0], setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition); findExceptionFromTryStatement( this.completionToken, (ReferenceBinding)qualifiedBinding, checkCancel(); findMemberTypes( this.completionToken, (ReferenceBinding) qualifiedBinding, setSourceRange(astNode.sourceStart, (int) completionPosition); setTokenRange((int) (completionPosition >>> 32), (int) completionPosition); findTypesAndSubpackages(this.completionToken, (PackageBinding) qualifiedBinding, scope);
CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor); engine.complete(cu, prefix.length + position, prefix.length, null/*extended context isn't computed*/); } else { engine.complete(this, snippet, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic);
if(binding != null) { if(!(variable.initialization instanceof ArrayInitializer)) { addExpectedType(binding, scope); } else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747 addExpectedType(binding, scope); TypeBinding binding = ((Assignment)parent).lhs.resolvedType; if(binding != null) { addExpectedType(binding, scope); TypeBinding binding = methodBinding == null ? null : methodBinding.returnType; if(binding != null) { addExpectedType(binding, scope); TypeBinding binding = e.resolvedType; if(binding != null){ addExpectedType(binding, scope); this.expectedTypesFilter = SUBTYPE | SUPERTYPE; computeExpectedTypesForMessageSend( binding, messageSend.selector, messageSend, isStatic); computeExpectedTypesForMessageSendForInterface( binding, messageSend.selector,
int oldStart = this.startPosition; int oldEnd = this.endPosition; setSourceRange( importReference.sourceStart, importReference.declarationSourceEnd); this.nameEnvironment.findPackages(importName, this); setSourceRange( oldStart, oldEnd - 1, this, this.monitor); acceptTypes(null);
findFieldsAndMethodsFromMissingType( method.returnType, currentScope, parametersBindings = methodBinding.parameters; if(areParametersCompatibleWith(parametersBindings, arguments, parameters[parametersLength - 1].isVarArgs())) { findFieldsAndMethodsFromMissingType( method.returnType, currentScope,
String pkg = type.getPackageFragment().getElementName(); String name = type.getElementName(); this.acceptType(pkg.toCharArray(), name.toCharArray(), CharOperation.NO_CHAR_CHAR, type.getFlags(), null); acceptTypes(scope); checkCancel(); findPackagesInCurrentModule();
private void computeExpectedTypesForAllocationExpression( ReferenceBinding binding, Expression[] arguments, Scope scope, InvocationSite invocationSite) { MethodBinding[] methods = binding.availableMethods(); nextMethod : for (int i = 0; i < methods.length; i++) { MethodBinding method = methods[i]; if (!method.isConstructor()) continue nextMethod; if (method.isSynthetic()) continue nextMethod; if (this.options.checkVisibility && !method.canBeSeenBy(invocationSite, scope)) continue nextMethod; TypeBinding[] parameters = method.parameters; if(parameters.length < arguments.length) continue nextMethod; int length = arguments.length - 1; for (int j = 0; j < length; j++) { Expression argument = arguments[j]; TypeBinding argType = argument.resolvedType; if(argType != null && !argType.isCompatibleWith(parameters[j])) continue nextMethod; } TypeBinding expectedType = method.parameters[arguments.length - 1]; if(expectedType != null) { addExpectedType(expectedType, scope); } } } private void computeExpectedTypesForMessageSend(
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); allowingLongComputationProposals && this.assistNodeIsConstructor && (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) || !isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)); checkCancel(); findNestedTypes(token, scope.enclosingSourceType(), scope, proposeAllMemberTypes, typesFound); if(!this.assistNodeIsInterface && !this.assistNodeIsConstructor && checkCancel(); findTypeParameters(token, scope); checkCancel(); if(isForbidden(sourceType)) continue next; findSubMemberTypes( token, sourceType, if (isFailedMatch(token, sourceType.sourceName)) continue next; if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) { continue next;
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); allowingLongComputationProposals && this.assistNodeIsConstructor && (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) || !isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)); checkCancel(); if (isForbidden(sourceType)) continue; if (this.assistNodeIsClass && sourceType.isInterface()) continue; if (this.assistNodeIsInterface && sourceType.isClass()) continue; int relevance = computeBaseRelevance(); relevance += computeRelevanceForResolution(); relevance += computeRelevanceForInterestingProposal(sourceType); relevance += computeRelevanceForCaseMatching(qualifiedName, qualifiedSourceTypeName); relevance += computeRelevanceForExpectingType(sourceType); relevance += computeRelevanceForQualification(false); relevance += computeRelevanceForRestrictions(accessibility); relevance += computeRelevanceForAnnotation(); } else if (sourceType.isInterface()) { relevance += computeRelevanceForInterface(); } else if (sourceType.isClass()) { relevance += computeRelevanceForClass(); relevance += computeRelevanceForException(sourceType.sourceName); (!this.assistNodeIsConstructor ||
this.assistNodeIsConstructor = singleRef.isConstructorType; this.assistNodeIsSuperType = singleRef.isSuperType(); this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); (astNodeParent instanceof ParameterizedSingleTypeReference || astNodeParent instanceof ParameterizedQualifiedTypeReference)) { this.setSourceAndTokenRange(astNode.sourceStart, astNode.sourceStart - 1, false); findParameterizedType((TypeReference)astNodeParent, scope); } else { ObjectVector typesFound = new ObjectVector(); if (this.assistNodeIsException && astNodeParent instanceof TryStatement) { findExceptionFromTryStatement( this.completionToken, null, checkCancel(); findTypesAndPackages(this.completionToken, scope, this.assistNodeIsConstructor, false, typesFound); findMemberTypes( this.completionToken, (ReferenceBinding) qualifiedBinding,
this.assistNodeIsInterface = ref.isInterface(); this.assistNodeIsSuperType = ref.isSuperType(); this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent); this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent); setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition); (this.requestor.isAllowingRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF))) { if(ref.tokens.length == 1) { findMemberTypesFromMissingType( ref, ref.sourcePositions[0], ObjectVector typesFound = new ObjectVector(); if (this.assistNodeIsException && astNodeParent instanceof TryStatement) { findExceptionFromTryStatement( this.completionToken, (ReferenceBinding)qualifiedBinding, checkCancel(); findMemberTypes( this.completionToken, (ReferenceBinding) qualifiedBinding,
if(binding != null) { if(!(variable.initialization instanceof ArrayInitializer)) { addExpectedType(binding, scope); } else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747 addExpectedType(binding, scope); TypeBinding binding = ((Assignment)parent).lhs.resolvedType; if(binding != null) { addExpectedType(binding, scope); TypeBinding binding = methodBinding == null ? null : methodBinding.returnType; if(binding != null) { addExpectedType(binding, scope); TypeBinding binding = methodBinding == null ? null : methodBinding.returnType; if (binding != null) { addExpectedType(binding, scope); TypeBinding binding = e.resolvedType; if(binding != null){ addExpectedType(binding, scope); this.expectedTypesFilter = SUBTYPE | SUPERTYPE; computeExpectedTypesForMessageSend( binding, messageSend.selector, messageSend,