use of org.eclipse.jface.text.contentassist.CompletionProposal in project abstools by abstools.
the class ProposalFactory method addClassProposals.
/**
* add the classes in the current module
* @param node the node under the cursor
*/
private void addClassProposals(ASTNode<?> node) {
ProposalComparator comp = new ProposalComparator();
ArrayList<ICompletionProposal> tempNonqual = new ArrayList<ICompletionProposal>();
ArrayList<ICompletionProposal> tempQual = new ArrayList<ICompletionProposal>();
ModuleDecl moddecl = node.getModuleDecl();
// Only crash when debugging:
assert moddecl != null : "Node is not in a Module!";
if (moddecl == null)
return;
Map<KindedName, ResolvedName> visibleNames = moddecl.getVisibleNames();
for (Entry<KindedName, ResolvedName> kentry : visibleNames.entrySet()) {
KindedName kname = kentry.getKey();
if (qualifierIsPrefixOf(kname.getName()) && kname.getKind() == Kind.CLASS) {
CompletionProposal proposal = makeVisibleNameProposal(kentry.getValue(), kname);
if (kname.isQualified()) {
tempQual.add(proposal);
} else {
tempNonqual.add(proposal);
}
}
}
Collections.sort(tempNonqual, comp);
proposals.addAll(0, tempNonqual);
Collections.sort(tempQual, comp);
proposals.addAll(0, tempQual);
}
use of org.eclipse.jface.text.contentassist.CompletionProposal in project eclipse-cs by checkstyle.
the class PropertiesContentAssistProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
List<CompletionProposal> proposals = new ArrayList<>();
// $NON-NLS-1$
String basedir = "${basedir}";
// $NON-NLS-1$
String projectLoc = "${project_loc}";
// $NON-NLS-1$
String workspaceLoc = "${workspace_loc}";
// $NON-NLS-1$
String configLoc = "${config_loc}";
// $NON-NLS-1$
String samedir = "${samedir}";
// TODO translate the descriptions
proposals.add(new CompletionProposal(basedir, documentOffset, 0, basedir.length(), null, basedir, null, Messages.PropertiesContentAssistProcessor_basedir));
proposals.add(new CompletionProposal(projectLoc, documentOffset, 0, projectLoc.length(), null, projectLoc, null, Messages.PropertiesContentAssistProcessor_projectLoc));
proposals.add(new CompletionProposal(workspaceLoc, documentOffset, 0, workspaceLoc.length(), null, workspaceLoc, null, Messages.PropertiesContentAssistProcessor_workspaceLoc));
proposals.add(new CompletionProposal(configLoc, documentOffset, 0, configLoc.length(), null, configLoc, null, Messages.PropertiesContentAssistProcessor_configLoc));
proposals.add(new CompletionProposal(samedir, documentOffset, 0, samedir.length(), null, samedir, null, Messages.PropertiesContentAssistProcessor_samedir));
return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
use of org.eclipse.jface.text.contentassist.CompletionProposal in project bndtools by bndtools.
the class BundleClassCompletionProposalComputer method computeCompletionProposals.
@Override
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
List<ICompletionProposal> result = new LinkedList<ICompletionProposal>();
if (!(context instanceof JavaContentAssistInvocationContext)) {
return Collections.emptyList();
}
try {
int offset = context.getInvocationOffset();
CharSequence prefix = context.computeIdentifierPrefix();
result.add(new CompletionProposal("foobar", offset - prefix.length(), prefix.length(), offset - prefix.length() + 6));
result.add(new CompletionProposal("fizzbuzz", offset - prefix.length(), prefix.length(), offset - prefix.length() + 8));
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
use of org.eclipse.jface.text.contentassist.CompletionProposal in project jbosstools-hibernate by jbosstools.
the class CFGXMLContentAssistProcessor method getAttributeValueProposals.
protected List getAttributeValueProposals(String attributeName, String matchString, int offset, ContentAssistRequest contentAssistRequest) {
String nodeName = contentAssistRequest.getNode().getNodeName();
if ("property".equals(nodeName) && "name".equals(attributeName)) {
// $NON-NLS-1$ //$NON-NLS-2$
List types = this.extractor.findMatchingPropertyTypes(matchString);
List proposals = new ArrayList(types.size());
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String element = (String) iter.next();
proposals.add(new CompletionProposal(element, offset, matchString.length(), element.length(), null, null, null, null));
}
return proposals;
}
if ("property".equals(nodeName) && "value".equals(attributeName)) {
// $NON-NLS-1$//$NON-NLS-2$
List types = this.extractor.findMatchingPropertyValues(matchString, contentAssistRequest.getNode());
List proposals = new ArrayList(types.size());
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String element = (String) iter.next();
proposals.add(new CompletionProposal(element, offset, matchString.length(), element.length(), null, null, null, null));
}
return proposals;
}
if ("mapping".equals(nodeName) && "resource".equals(attributeName)) {
// $NON-NLS-1$ //$NON-NLS-2$
}
return Collections.EMPTY_LIST;
}
use of org.eclipse.jface.text.contentassist.CompletionProposal in project jbosstools-hibernate by jbosstools.
the class PropertyAccessHandler method attributeCompletionProposals.
public ICompletionProposal[] attributeCompletionProposals(IJavaProject project, Node node, String attributeName, String start, int offset) {
List types = this.extractor.findMatchingAccessMethods(start);
List proposals = new ArrayList(types.size());
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
HibernateTypeDescriptor element = (HibernateTypeDescriptor) iter.next();
String extendedinfo = MapperMessages.PropertyAccessHandler_access_method + element.getName();
if (element.getReturnClass() != null) {
extendedinfo += MapperMessages.PropertyAccessHandler_description + element.getReturnClass();
}
proposals.add(new CompletionProposal(element.getName(), offset, start.length(), element.getName().length(), null, null, null, extendedinfo));
}
try {
// $NON-NLS-1$
IType typeInterface = project.findType("org.hibernate.property.PropertyAccessor");
Set alreadyFound = new HashSet();
if (typeInterface != null) {
ITypeHierarchy hier = typeInterface.newTypeHierarchy(project, new NullProgressMonitor());
// TODO: cache these results ?
IType[] classes = hier.getAllSubtypes(typeInterface);
// $NON-NLS-1$
this.extractor.generateTypeProposals(start, offset, proposals, alreadyFound, classes, "org.hibernate.property");
}
} catch (CoreException e) {
// TODO: log as error!
throw new RuntimeException(e);
}
ICompletionProposal[] result = (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
return result;
}
Aggregations