Search in sources :

Example 1 with ResolvedName

use of abs.frontend.typechecker.ResolvedName in project abstools by abstools.

the class ProposalFactory method addToplevelProposals.

/**
 * add proposals for all visible names.
 * @param node the node under the cursor
 */
private void addToplevelProposals(ASTNode<?> node) {
    ProposalComparator comp = new ProposalComparator();
    ArrayList<ICompletionProposal> tempNonqual = new ArrayList<ICompletionProposal>();
    ArrayList<ICompletionProposal> tempQual = new ArrayList<ICompletionProposal>();
    ModuleDecl moddecl = node.getModuleDecl();
    if (moddecl == null) {
        return;
    }
    try {
        Map<KindedName, ResolvedName> visibleNames = moddecl.getVisibleNames();
        for (Entry<KindedName, ResolvedName> kentry : visibleNames.entrySet()) {
            KindedName kname = kentry.getKey();
            if (qualifierIsPrefixOf(kname.getName())) {
                CompletionProposal proposal = makeVisibleNameProposal(kentry.getValue(), kname);
                if (kname.isQualified()) {
                    tempQual.add(proposal);
                } else {
                    tempNonqual.add(proposal);
                }
            }
        }
        Collections.sort(tempNonqual, comp);
        proposals.addAll(tempNonqual);
        Collections.sort(tempQual, comp);
        proposals.addAll(tempQual);
    } catch (TypeCheckerException e) {
    // ignore all type check exceptions
    }
}
Also used : TypeCheckerException(abs.frontend.typechecker.TypeCheckerException) CompletionProposal(org.eclipse.jface.text.contentassist.CompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) ResolvedName(abs.frontend.typechecker.ResolvedName) KindedName(abs.frontend.typechecker.KindedName)

Example 2 with ResolvedName

use of abs.frontend.typechecker.ResolvedName 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);
}
Also used : CompletionProposal(org.eclipse.jface.text.contentassist.CompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) ResolvedName(abs.frontend.typechecker.ResolvedName) KindedName(abs.frontend.typechecker.KindedName)

Aggregations

KindedName (abs.frontend.typechecker.KindedName)2 ResolvedName (abs.frontend.typechecker.ResolvedName)2 ArrayList (java.util.ArrayList)2 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 TypeCheckerException (abs.frontend.typechecker.TypeCheckerException)1