Java Code Examples for org.eclipse.jdt.internal.compiler.lookup.Binding#isValidBinding()

The following examples show how to use org.eclipse.jdt.internal.compiler.lookup.Binding#isValidBinding() . 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: SelectionOnQualifiedTypeReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected TypeBinding getTypeBinding(Scope scope) {
	// it can be a package, type or member type
	Binding binding = scope.getTypeOrPackage(this.tokens);
	if (!binding.isValidBinding()) {
		// tolerate some error cases
		if (binding.problemId() == ProblemReasons.NotVisible){
			throw new SelectionNodeFound(binding);
		}

		if (binding instanceof TypeBinding) {
			scope.problemReporter().invalidType(this, (TypeBinding) binding);
		} else if (binding instanceof PackageBinding) {
			ProblemReferenceBinding problemBinding = new ProblemReferenceBinding(((PackageBinding)binding).compoundName, null, binding.problemId());
			scope.problemReporter().invalidType(this, problemBinding);
		}

		throw new SelectionNodeFound();
	}

	throw new SelectionNodeFound(binding);
}
 
Example 2
Source File: SelectionOnSingleTypeReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected TypeBinding getTypeBinding(Scope scope) {
	// it can be a package, type or member type
	Binding binding = scope.getTypeOrPackage(new char[][] {this.token});
	if (!binding.isValidBinding()) {
		if (binding instanceof TypeBinding) {
			scope.problemReporter().invalidType(this, (TypeBinding) binding);
		} else if (binding instanceof PackageBinding) {
			ProblemReferenceBinding problemBinding = new ProblemReferenceBinding(((PackageBinding)binding).compoundName, null, binding.problemId());
			scope.problemReporter().invalidType(this, problemBinding);
		}
		throw new SelectionNodeFound();
	}
	throw new SelectionNodeFound(binding);
}
 
Example 3
Source File: CompletionOnMarkerAnnotationName.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public TypeBinding resolveType(BlockScope scope) {
	if(this.type instanceof QualifiedTypeReference) {
		QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) this.type;
		Binding binding = scope.parent.getTypeOrPackage(qualifiedTypeReference.tokens); // step up from the ClassScope
		if (!binding.isValidBinding()) {
			scope.problemReporter().invalidType(this, (TypeBinding) binding);
			throw new CompletionNodeFound();
		}
		throw new CompletionNodeFound(this, binding, scope);
	}
	throw new CompletionNodeFound(this, null, scope);
}
 
Example 4
Source File: DefaultBindingResolver.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
synchronized IPackageBinding resolvePackage(PackageDeclaration pkg) {
	if (this.scope == null) return null;
	try {
		org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(pkg);
		if (node instanceof ImportReference) {
			ImportReference importReference = (ImportReference) node;
			Binding binding = this.scope.getOnlyPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
			if ((binding != null) && (binding.isValidBinding())) {
				if (binding instanceof ReferenceBinding) {
					// this only happens if a type name has the same name as its package
					ReferenceBinding referenceBinding = (ReferenceBinding) binding;
					binding = referenceBinding.fPackage;
				}
				if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
					IPackageBinding packageBinding = getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
					if (packageBinding == null) {
						return null;
					}
					this.bindingsToAstNodes.put(packageBinding, pkg);
					String key = packageBinding.getKey();
					if (key != null) {
						this.bindingTables.bindingKeysToBindings.put(key, packageBinding);
					}
					return packageBinding;
				}
			}
		}
	} catch (AbortCompilation e) {
		// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
		// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
		// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
	}
	return null;
}
 
Example 5
Source File: TypeParameter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void internalResolve(Scope scope, boolean staticContext) {
    // detect variable/type name collisions
	if (this.binding != null) {
		Binding existingType = scope.parent.getBinding(this.name, Binding.TYPE, this, false/*do not resolve hidden field*/);
		if (existingType != null
				&& this.binding != existingType
				&& existingType.isValidBinding()
				&& (existingType.kind() != Binding.TYPE_PARAMETER || !staticContext)) {
			scope.problemReporter().typeHiding(this, existingType);
		}
	}
	if (this.annotations != null) {
		resolveAnnotations(scope);
	}
}