Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Annotation


    @Override
    public void visit(Tree.SpecifierStatement st) {
        TypedDeclaration d = ((Tree.SpecifierStatement) st).getDeclaration();
        //Just add shared and actual annotations to this declaration
        if (d != null) {
            Annotation ann = new Annotation();
            ann.setName("shared");
            d.getAnnotations().add(ann);
            ann = new Annotation();
            ann.setName("actual");
            d.getAnnotations().add(ann);
            if (d instanceof Method) {
                gen.encodeMethod((Method)d);
            } else if (d instanceof Value) {
                gen.encodeAttributeOrGetter((Value)d);
View Full Code Here


                gen.out(",", MetamodelGenerator.KEY_PACKED_ANNS, ":", Integer.toString(bits));
                //Remove these annotations from the list
                anns = new ArrayList<Annotation>(d.getAnnotations().size());
                anns.addAll(d.getAnnotations());
                for (Iterator<Annotation> iter = anns.iterator(); iter.hasNext();) {
                    final Annotation a = iter.next();
                    final Declaration ad = d.getUnit().getPackage().getMemberOrParameter(d.getUnit(), a.getName(), null, false);
                    final String qn = ad.getQualifiedNameString();
                    if (qn.startsWith("ceylon.language::") && MetamodelGenerator.annotationBits.contains(qn.substring(17))) {
                        iter.remove();
                    }
                }
                if (anns.isEmpty()) {
                    return;
                }
            }
            gen.out(",", MetamodelGenerator.KEY_ANNOTATIONS, ":function(){return[");
            boolean first = true;
            for (Annotation a : anns) {
                Declaration ad = d.getUnit().getPackage().getMemberOrParameter(d.getUnit(), a.getName(), null, false);
                if (ad instanceof Method) {
                    if (first) first=false; else gen.out(",");
                    final boolean isDoc = "ceylon.language::doc".equals(ad.getQualifiedNameString());
                    if (!isDoc) {
                        gen.qualify(node, ad);
                        gen.out(gen.getNames().name(ad), "(");
                    }
                    if (a.getPositionalArguments() == null) {
                        for (Parameter p : ((Method)ad).getParameterLists().get(0).getParameters()) {
                            String v = a.getNamedArguments().get(p.getName());
                            gen.out(v == null ? "undefined" : v);
                        }
                    } else {
                        if (isDoc) {
                            //Use ref if it's too long
                            final String ref = pathToModelDoc(d);
                            final String doc = a.getPositionalArguments().get(0);
                            if (ref != null && ref.length() < doc.length()) {
                                gen.out(gen.getClAlias(), "doc$($CCMM$,", ref);
                            } else {
                                gen.out(gen.getClAlias(), "doc(\"", gen.escapeStringLiteral(doc), "\"");
                            }
                        } else {
                            boolean farg = true;
                            for (String s : a.getPositionalArguments()) {
                                if (farg)farg=false; else gen.out(",");
                                gen.out("\"", gen.escapeStringLiteral(s), "\"");
                            }
                        }
                    }
                    gen.out(")");
                } else {
                    gen.out("/*MISSING DECLARATION FOR ANNOTATION ", a.getName(), "*/");
                }
            }
            gen.out("];}");
        }
View Full Code Here

    @Test
    public void testEncode() {
        final Value v = new Value();
        int b = MetamodelGenerator.encodeAnnotations(v, null);
        Assert.assertEquals(0, b);
        v.getAnnotations().add(new Annotation("shared"));
        b = MetamodelGenerator.encodeAnnotations(v, null);
        Assert.assertEquals(1, b);
        v.getAnnotations().add(new Annotation("actual"));
        b = MetamodelGenerator.encodeAnnotations(v, null);
        Assert.assertEquals(3, b);
        v.getAnnotations().add(new Annotation("default"));
        b = MetamodelGenerator.encodeAnnotations(v, null);
        Assert.assertEquals(11, b);
    }
View Full Code Here

            }
        }
        if (m == null) return;
        for (Map.Entry<String, Object> e : m.entrySet()) {
            String name = e.getKey();
            Annotation ann = new Annotation();
            ann.setName(name);
            if ("doc".equals(name) && e.getValue() instanceof Integer) {
                ann.addPositionalArgment(docs.get((Integer)e.getValue()));
            } else {
                for (String arg : (List<String>)e.getValue()) {
                    ann.addPositionalArgment(arg);
                }
            }
            d.getAnnotations().add(ann);
        }
        //This is to avoid problems with private declarations while
View Full Code Here

        }
        Value v = new Value();
        v.setName(sv.getName());
        v.setShared(true);
        v.setActual(true);
        v.getAnnotations().add(new Annotation("shared"));
        v.getAnnotations().add(new Annotation("actual"));
        v.setRefinedDeclaration(sv.getRefinedDeclaration());
        v.setUnit(that.getUnit());
        v.setContainer(c);
        v.setScope(c);
        v.setShortcutRefinement(true);
View Full Code Here

            bme.addError("method has type parameters: "
                    message(sm));
        }
        m.setShared(true);
        m.setActual(true);
        m.getAnnotations().add(new Annotation("shared"));
        m.getAnnotations().add(new Annotation("actual"));
        m.setRefinedDeclaration(sm.getRefinedDeclaration()); //Note: this is not the real root, so we set it again in ExpressionVisitor
        m.setUnit(that.getUnit());
        m.setContainer(c);
        m.setShortcutRefinement(true);
        m.setDeclaredVoid(sm.isDeclaredVoid());
View Full Code Here

    public static void buildAnnotations(Tree.AnnotationList al,
            List<Annotation> annotations) {
        if (al!=null) {
            Tree.AnonymousAnnotation aa = al.getAnonymousAnnotation();
            if (aa!=null) {
                Annotation ann = new Annotation();
                ann.setName("doc");
                ann.addPositionalArgment(aa.getStringLiteral().getText());
                annotations.add(ann);
            }
            for (Tree.Annotation a: al.getAnnotations()) {
                Annotation ann = new Annotation();
                String name = ((Tree.BaseMemberExpression)
                        a.getPrimary()).getIdentifier().getText();
                ann.setName(name);
                if (a.getNamedArgumentList()!=null) {
                    for (Tree.NamedArgument na:
                            a.getNamedArgumentList().getNamedArguments()) {
                        if (na instanceof Tree.SpecifiedArgument) {
                            Tree.SpecifierExpression sie =
                                    ((Tree.SpecifiedArgument) na).getSpecifierExpression();
                            Tree.Expression e = sie.getExpression();
                            if (e!=null) {
                                Tree.Term t = e.getTerm();
                                Parameter p =
                                        ((Tree.SpecifiedArgument) na).getParameter();
                                if (p!=null) {
                                    String text = toString(t);
                                    if (text!=null) {
                                        ann.addNamedArgument(p.getName(), text);
                                    }
                                }
                            }
                        }                   
                    }
                }
                if (a.getPositionalArgumentList()!=null) {
                    for (Tree.PositionalArgument pa:
                            a.getPositionalArgumentList().getPositionalArguments()) {
                      if (pa instanceof Tree.ListedArgument) {
                        Tree.Term t =
                                ((Tree.ListedArgument) pa).getExpression().getTerm();
                        String text = toString(t);
                        if (text!=null) {
                          ann.addPositionalArgment(text);
                        }
                      }
                    }
                }
                annotations.add(ann);
View Full Code Here

                return processPackage(docLink.getPkg());
            }
        }
       
        if (docLink != null && scope instanceof Annotated) {
            Annotation docAnnotation = getAnnotation(((Annotated) scope).getAnnotations(), "doc");
            if (docAnnotation != null) {
                ceylonDocTool.warningBrokenLink(docLinkText, docLink, scope);
            }
        }
View Full Code Here

        return wikiToHTML(getFirstLine(getRawDoc(module.getAnnotations())), linkRenderer.useScope(module));
    }
   
    public static List<String> getTags(Declaration decl) {
        List<String> tags = new ArrayList<String>();
        Annotation tagged = Util.getAnnotation(decl.getAnnotations(), "tagged");
        if (tagged != null) {
            tags.addAll(tagged.getPositionalArguments());
        }
        return tags;
    }
View Full Code Here

        }
        return text.substring(0, FIRST_LINE_MAX_SIZE-1) + "…";
    }

    private static String getRawDoc(Declaration decl) {
        Annotation a = findAnnotation(decl, "doc");
        if (a != null) {
            return a.getPositionalArguments().get(0);
        }
        return "";
    }
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.