List of usage examples for org.eclipse.jdt.core IType getAttachedJavadoc
String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException;
Returns the Javadoc as HTML source if this element has attached Javadoc, null otherwise.
This should be used only for binary elements.
From source file:com.android.ide.eclipse.adt.internal.editors.CompletionProposal.java
License:Open Source License
@Override public String getAdditionalProposalInfo() { if (mAdditionalProposalInfo == null) { if (mChoice instanceof ElementDescriptor) { String tooltip = ((ElementDescriptor) mChoice).getTooltip(); mAdditionalProposalInfo = DescriptorsUtils.formatTooltip(tooltip); } else if (mChoice instanceof TextAttributeDescriptor) { mAdditionalProposalInfo = ((TextAttributeDescriptor) mChoice).getTooltip(); } else if (mChoice instanceof String) { // Try to produce it lazily for strings like @android String value = (String) mChoice; Matcher matcher = ATTRIBUTE_PATTERN.matcher(value); if (matcher.matches()) { String attrName = matcher.group(1); AndroidTargetData data = mAssist.getEditor().getTargetData(); if (data != null) { IDescriptorProvider descriptorProvider = data .getDescriptorProvider(mAssist.getRootDescriptorId()); if (descriptorProvider != null) { ElementDescriptor[] rootElementDescriptors = descriptorProvider .getRootElementDescriptors(); for (ElementDescriptor elementDesc : rootElementDescriptors) { for (AttributeDescriptor desc : elementDesc.getAttributes()) { String name = desc.getXmlLocalName(); if (attrName.equals(name)) { IAttributeInfo attributeInfo = desc.getAttributeInfo(); if (attributeInfo != null) { return attributeInfo.getJavaDoc(); }// w w w .j a v a 2 s. com } } } } } } } else if (mChoice instanceof IType) { IType type = (IType) mChoice; try { ISourceRange javadocRange = type.getJavadocRange(); if (javadocRange != null && javadocRange.getLength() > 0) { ISourceRange sourceRange = type.getSourceRange(); if (sourceRange != null) { String source = type.getSource(); int start = javadocRange.getOffset() - sourceRange.getOffset(); int length = javadocRange.getLength(); String doc = source.substring(start, start + length); return doc; } } return type.getAttachedJavadoc(new NullProgressMonitor()); } catch (JavaModelException e) { AdtPlugin.log(e, null); } } } return mAdditionalProposalInfo; }
From source file:org.eclipse.andmore.internal.editors.CompletionProposal.java
License:Open Source License
@Override public String getAdditionalProposalInfo() { if (mAdditionalProposalInfo == null) { if (mChoice instanceof ElementDescriptor) { String tooltip = ((ElementDescriptor) mChoice).getTooltip(); mAdditionalProposalInfo = DescriptorsUtils.formatTooltip(tooltip); } else if (mChoice instanceof TextAttributeDescriptor) { mAdditionalProposalInfo = ((TextAttributeDescriptor) mChoice).getTooltip(); } else if (mChoice instanceof String) { // Try to produce it lazily for strings like @android String value = (String) mChoice; Matcher matcher = ATTRIBUTE_PATTERN.matcher(value); if (matcher.matches()) { String attrName = matcher.group(1); AndroidTargetData data = mAssist.getEditor().getTargetData(); if (data != null) { IDescriptorProvider descriptorProvider = data .getDescriptorProvider(mAssist.getRootDescriptorId()); if (descriptorProvider != null) { ElementDescriptor[] rootElementDescriptors = descriptorProvider .getRootElementDescriptors(); for (ElementDescriptor elementDesc : rootElementDescriptors) { for (AttributeDescriptor desc : elementDesc.getAttributes()) { String name = desc.getXmlLocalName(); if (attrName.equals(name)) { IAttributeInfo attributeInfo = desc.getAttributeInfo(); if (attributeInfo != null) { return attributeInfo.getJavaDoc(); }//ww w . j av a 2s . c o m } } } } } } } else if (mChoice instanceof IType) { IType type = (IType) mChoice; try { ISourceRange javadocRange = type.getJavadocRange(); if (javadocRange != null && javadocRange.getLength() > 0) { ISourceRange sourceRange = type.getSourceRange(); if (sourceRange != null) { String source = type.getSource(); int start = javadocRange.getOffset() - sourceRange.getOffset(); int length = javadocRange.getLength(); String doc = source.substring(start, start + length); return doc; } } return type.getAttachedJavadoc(new NullProgressMonitor()); } catch (JavaModelException e) { AndmoreAndroidPlugin.log(e, null); } } } return mAdditionalProposalInfo; }