Search in sources :

Example 6 with KindedName

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

the class PartialFunctionTest method assertHasFunction.

private FunctionDecl assertHasFunction(Model model, String regex) {
    FunctionDecl result = getFunction(model, Pattern.compile(regex));
    String errorMessage = "No expanded function with name " + regex + " created" + " (functions: " + getFunctions(model) + ")";
    assertNotNull(errorMessage, result);
    Decl decl = model.lookup(new KindedName(Kind.FUN, result.getName()));
    assertFalse("Could not lookup function " + result.getName(), decl.isUnknown());
    return result;
}
Also used : PartialFunctionDecl(abs.frontend.ast.PartialFunctionDecl) FunctionDecl(abs.frontend.ast.FunctionDecl) Decl(abs.frontend.ast.Decl) KindedName(abs.frontend.typechecker.KindedName) PartialFunctionDecl(abs.frontend.ast.PartialFunctionDecl) FunctionDecl(abs.frontend.ast.FunctionDecl)

Example 7 with KindedName

use of abs.frontend.typechecker.KindedName 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)7 FrontendTest (abs.frontend.FrontendTest)2 ClassDecl (abs.frontend.ast.ClassDecl)2 Model (abs.frontend.ast.Model)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 Test (org.junit.Test)2 TypeError (abs.frontend.analyser.TypeError)1 Annotation (abs.frontend.ast.Annotation)1 Decl (abs.frontend.ast.Decl)1 FieldDecl (abs.frontend.ast.FieldDecl)1 FunctionDecl (abs.frontend.ast.FunctionDecl)1 PartialFunctionDecl (abs.frontend.ast.PartialFunctionDecl)1 ReturnStmt (abs.frontend.ast.ReturnStmt)1 TypeCheckerException (abs.frontend.typechecker.TypeCheckerException)1