use of net.vtst.ow.eclipse.js.closure.editor.JSElementInfo in project ow by vtst.
the class ClosureCompletionProposalCollector method collectProposalsFromType.
/**
* Collect the completion proposal for a type.
* @param map The map in which completion proposals are inserted.
* @param prefix The last segment of the prefix.
* @param alternateType The type to analyze.
* @param type The union type which {@code alternateType} belongs to.
*/
private void collectProposalsFromType(Map<String, ClosureCompletionProposal> map, String prefix, JSType alternateType) {
if (alternateType instanceof ObjectType) {
ObjectType alternateObjectType = (ObjectType) alternateType;
for (String propertyName : alternateObjectType.getPropertyNames()) {
if (isValidForPrefix(propertyName, prefix) && isVisibleName(propertyName)) {
ClosureCompletionProposal proposal = map.get(propertyName);
if (proposal == null) {
// This is slightly unefficient, because we build the elementInfo before
// checking that the node is concrete. But I'm not sure it is useful to
// complicate the code for this particular case.
JSElementInfo elementInfo = JSElementInfo.makeFromProperty(context.getCompilerRun(), alternateObjectType, propertyName);
if (isConcreteNode(elementInfo.getNode())) {
proposal = new ClosureCompletionProposal(context, propertyName, elementInfo);
map.put(propertyName, proposal);
}
}
if (proposal != null) {
proposal.addVisibility(getVisibilityOfProperty(alternateObjectType, propertyName));
}
}
}
}
}
use of net.vtst.ow.eclipse.js.closure.editor.JSElementInfo in project ow by vtst.
the class ClosureTextHover method getHoverHTML.
/* (non-Javadoc)
* @see net.vtst.ow.eclipse.js.closure.editor.hover.AbstractTextHover#getHoverHTML(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
*/
@Override
protected String getHoverHTML(ITextViewer viewer, IRegion region) {
CompilableJSUnit unit = getJSUnit();
if (unit == null)
return null;
CompilerRun run = getCompilerRun(unit);
if (run == null)
return null;
Node node = run.getNode(unit, region.getOffset());
if (node == null)
return null;
JSElementInfo info = getElementInfo(run, node);
if (info == null)
return null;
return info.getHTMLStringForHover();
}
Aggregations