Java Code Examples for org.eclipse.jdt.core.dom.QualifiedName#QUALIFIER_PROPERTY

The following examples show how to use org.eclipse.jdt.core.dom.QualifiedName#QUALIFIER_PROPERTY . 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: ASTResolving.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static ITypeBinding guessBindingForTypeReference(ASTNode node) {
  	StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
  	if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) {
  		return null; // can't guess type for X.A
  	}
if (locationInParent == SimpleType.NAME_PROPERTY ||
		locationInParent == NameQualifiedType.NAME_PROPERTY) {
  		node= node.getParent();
  	}
  	ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node));
  	if (binding != null) {
  		if (binding.isWildcardType()) {
  			return normalizeWildcardType(binding, true, node.getAST());
  		}
  	}
  	return binding;
  }
 
Example 2
Source File: NLSKeyHyperlinkDetector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
	ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
	if (region == null || textEditor == null)
		return null;

	IEditorSite site= textEditor.getEditorSite();
	if (site == null)
		return null;

	ITypeRoot javaElement= getInputJavaElement(textEditor);
	if (javaElement == null)
		return null;

	CompilationUnit ast= SharedASTProvider.getAST(javaElement, SharedASTProvider.WAIT_NO, null);
	if (ast == null)
		return null;

	ASTNode node= NodeFinder.perform(ast, region.getOffset(), 1);
	if (!(node instanceof StringLiteral)  && !(node instanceof SimpleName))
		return null;

	if (node.getLocationInParent() == QualifiedName.QUALIFIER_PROPERTY)
		return null;

	IRegion nlsKeyRegion= new Region(node.getStartPosition(), node.getLength());
	AccessorClassReference ref= NLSHintHelper.getAccessorClassReference(ast, nlsKeyRegion);
	if (ref == null)
		return null;
	String keyName= null;
	if (node instanceof StringLiteral) {
		keyName= ((StringLiteral)node).getLiteralValue();
	} else {
		keyName= ((SimpleName)node).getIdentifier();
	}
	if (keyName != null)
		return new IHyperlink[] {new NLSKeyHyperlink(nlsKeyRegion, keyName, ref, textEditor)};

	return null;
}