Examples of DeclName


Examples of org.jvnet.sorcerer.Tag.DeclName

                        // for the enum constant put the anchor around vt
                        token = gen.findTokenAfter(vt, false, vt.getName().toString());
                    }
                    // TODO: handle declarations like "String abc[]"
                    if(token!=null)
                        gen.add(new DeclName(lineMap,token));
                }
                return super.visitVariable(vt,_);
            }

            /**
             * Method declaration.
             */
            public Void visitMethod(MethodTree mt, Void _) {
                ExecutableElement e = (ExecutableElement) TreeUtil.getElement(mt);
                if(e!=null) {
                    if(e.getKind()==ElementKind.CONSTRUCTOR && e.getEnclosingElement().getSimpleName().length()==0)
                        return _; // this is a synthesized constructor for an anonymous class
                                  // TODO: I suspect we need some kind of uniform treatment for all synthesized methods

                    // mark up the method name
                    Tree prev = mt.getReturnType();
                    String name;
                    if(e.getKind()== ElementKind.CONSTRUCTOR)
                        name = e.getEnclosingElement().getSimpleName().toString();
                    else // constructor returns <init> from getName(), so we need the above code
                        name = mt.getName().toString();
                    Token token;
                    if(prev!=null)
                        token = gen.findTokenAfter(prev, true, name);
                    else
                        token = gen.findTokenAfter(mt,false,name);

                    if(token!=null)
                        gen.add(new DeclName(lineMap,token));

                    ParsedType pt = getParsedType((TypeElement) e.getEnclosingElement());

                    gen.add(new MethodDecl(cu, srcPos, mt, e,
                        pt.findOverriddenMethods(elements, e),
                        pt.findOverridingMethods(elements, e)
                        ));
                }

                return super.visitMethod(mt, _);
            }

            /**
             * Class declaration.
             */
            public Void visitClass(ClassTree ct, Void _) {
                TypeElement e = (TypeElement) TreeUtil.getElement(ct);
                if(e!=null) {
                    // put the marker on the class name portion.
                    Token token=null;
                    if(ct.getModifiers()!=null)
                        token = gen.findTokenAfter(ct.getModifiers(), true, ct.getSimpleName().toString());
                        // on enum class, like "public enum En {ABC,DEF}", the above returns null somehow.
                        // so go with the plan B if it's not found.
                        // TODO: report to javac team
                    if(token==null)
                        token = gen.findTokenAfter(ct, false, ct.getSimpleName().toString());
                    if(token!=null)
                        gen.add(new DeclName(lineMap, token));

                    List<ParsedType> descendants = getParsedType(e).descendants;

                    gen.add(new ClassDecl(cu, srcPos, ct, e, descendants));

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.