Package com.sun.tools.javac.model

Examples of com.sun.tools.javac.model.JavacElements


    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                      Element e, AnnotationMirror a, AnnotationValue v) {
        JavaFileObject oldSource = null;
        JavaFileObject newSource = null;
        JCDiagnostic.DiagnosticPosition pos = null;
        JavacElements elemUtils = processingEnv.getElementUtils();
        Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
        if (treeTop != null) {
            newSource = treeTop.snd.sourcefile;
            if (newSource != null) {
                // save the old version and reinstate it later
                oldSource = log.useSource(newSource);
View Full Code Here


        if (annotation != null) {
            // Выбираем все элементы, у которых стоит наша аннотация
            final Set<? extends Element> methods = roundEnv.getElementsAnnotatedWith(annotation);

            JavacElements utils = javacProcessingEnv.getElementUtils();

            processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, methods.toString());

            for (final Element m : methods) {
                Time time = m.getAnnotation(Time.class);
                if (time != null) {
                    JCTree blockNode = utils.getTree(m);
                    // Нам нужны только описания методов
                    if (blockNode instanceof JCMethodDecl) {
                        // Получаем содержимое метода
                        final List<JCStatement> statements = ((JCMethodDecl) blockNode).body.stats;
View Full Code Here

        final TypeElement annotation = javacProcessingEnv.getElementUtils().getTypeElement(ANNOTATION_TYPE);

        if (annotation != null) {
            final Set<? extends Element> classes = roundEnv.getElementsAnnotatedWith(annotation);
            JavacElements utils = javacProcessingEnv.getElementUtils();

            for (final Element e : classes) {
                JCTree classNode = utils.getTree(e);

                JCTree.JCClassDecl classDecl = (JCTree.JCClassDecl)classNode;

                JCTree.JCExpression serializableInterface = maker.Ident(utils.getName("java"));
                serializableInterface = maker.Select(serializableInterface, utils.getName("io"));
                serializableInterface = maker.Select(serializableInterface, utils.getName("Externalizable"));

                JCTree.JCExpression ioExceptionClass = maker.Ident(utils.getName("java"));
                ioExceptionClass = maker.Select(ioExceptionClass, utils.getName("io"));
                ioExceptionClass = maker.Select(ioExceptionClass, utils.getName("IOException"));

                JCTree.JCExpression classNotFoundExceptionClass = maker.Ident(utils.getName("java"));
                classNotFoundExceptionClass = maker.Select(classNotFoundExceptionClass, utils.getName("lang"));
                classNotFoundExceptionClass = maker.Select(classNotFoundExceptionClass, utils.getName("ClassNotFoundException"));

                classDecl.implementing = classDecl.implementing.append(serializableInterface);

                JCTree.JCAnnotation overrideAnnotaion = maker.Annotation(maker.Ident(utils.getName("Override")), List.<JCTree.JCExpression>nil());
                JCTree.JCModifiers methodModifiers = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotaion));

                JCTree.JCExpression objectOutputClass = maker.Ident(utils.getName("java"));
                objectOutputClass = maker.Select(objectOutputClass, utils.getName("io"));
                objectOutputClass = maker.Select(objectOutputClass, utils.getName("ObjectOutput"));

                JCTree.JCExpression objectInputClass = maker.Ident(utils.getName("java"));
                objectInputClass = maker.Select(objectInputClass, utils.getName("io"));
                objectInputClass = maker.Select(objectInputClass, utils.getName("ObjectInput"));

                JCTree.JCBlock writeExternalBlock = maker.Block(0, List.<JCTree.JCStatement>nil());

                JCTree.JCMethodDecl writeExternalMethod = maker.MethodDef(
                        methodModifiers,
                        utils.getName("writeExternal"),
                        maker.TypeIdent(TypeTags.VOID),
                        List.<JCTree.JCTypeParameter>nil(),
                        List.of(maker.VarDef(maker.Modifiers(0), utils.getName("out"), objectOutputClass, null)),
                        List.of(ioExceptionClass),
                        writeExternalBlock,
                        null
                );

                JCTree.JCBlock readExternalBlock = maker.Block(0, List.<JCTree.JCStatement>nil());

                JCTree.JCMethodDecl readExternalMethod = maker.MethodDef(
                        methodModifiers,
                        utils.getName("readExternal"),
                        maker.TypeIdent(TypeTags.VOID),
                        List.<JCTree.JCTypeParameter>nil(),
                        List.of(maker.VarDef(maker.Modifiers(0), utils.getName("in"), objectInputClass, null)),
                        List.of(ioExceptionClass, classNotFoundExceptionClass),
                        readExternalBlock,
                        null
                );
View Full Code Here

        final TypeElement annotation = javacProcessingEnv.getElementUtils().getTypeElement(ANNOTATION_TYPE);

        if (annotation != null) {
            final Set<? extends Element> classes = roundEnv.getElementsAnnotatedWith(annotation);
            JavacElements utils = javacProcessingEnv.getElementUtils();

            for (final Element e : classes) {
                if (!(e instanceof JCTree.JCClassDecl))
                    processSerializableVarDef(utils, e);

                JCTree classNode = utils.getTree(e);

                JCTree.JCClassDecl classDecl = (JCTree.JCClassDecl) classNode;

                JCTree.JCExpression serializableInterface = maker.Ident(utils.getName("java"));
                serializableInterface = maker.Select(serializableInterface, utils.getName("io"));
                serializableInterface = maker.Select(serializableInterface, utils.getName("Externalizable"));

                JCTree.JCExpression ioExceptionClass = maker.Ident(utils.getName("java"));
                ioExceptionClass = maker.Select(ioExceptionClass, utils.getName("io"));
                ioExceptionClass = maker.Select(ioExceptionClass, utils.getName("IOException"));

                JCTree.JCExpression classNotFoundExceptionClass = maker.Ident(utils.getName("java"));
                classNotFoundExceptionClass = maker.Select(classNotFoundExceptionClass, utils.getName("lang"));
                classNotFoundExceptionClass = maker.Select(classNotFoundExceptionClass, utils.getName("ClassNotFoundException"));

                classDecl.implementing = classDecl.implementing.append(serializableInterface);

                JCTree.JCAnnotation overrideAnnotaion = maker.Annotation(maker.Ident(utils.getName("Override")), List.<JCTree.JCExpression>nil());
                JCTree.JCModifiers methodModifiers = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotaion));

                JCTree.JCExpression objectOutputClass = maker.Ident(utils.getName("java"));
                objectOutputClass = maker.Select(objectOutputClass, utils.getName("io"));
                objectOutputClass = maker.Select(objectOutputClass, utils.getName("ObjectOutput"));

                JCTree.JCExpression objectInputClass = maker.Ident(utils.getName("java"));
                objectInputClass = maker.Select(objectInputClass, utils.getName("io"));
                objectInputClass = maker.Select(objectInputClass, utils.getName("ObjectInput"));

                MethodBlockBuilder methodBlockBuilder = new MethodBlockBuilder(maker, utils, classDecl);
                JCTree.JCBlock writeExternalBlock = methodBlockBuilder.writeExternalBlock();

                JCTree.JCMethodDecl writeExternalMethod = getWriteExternalMethod(utils, ioExceptionClass,
View Full Code Here

        // Initialize services before any processors are initialzied
        // in case processors use them.
        filer = new JavacFiler(context);
        messager = new JavacMessager(context, this);
        elementUtils = new JavacElements(context);
        typeUtils = new JavacTypes(context);
        processorOptions = initProcessorOptions(context);
        unmatchedProcessorOptions = initUnmatchedProcessorOptions();
        initProcessorIterator(context, processors);
    }
View Full Code Here

    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                      Element e, AnnotationMirror a, AnnotationValue v) {
        JavaFileObject oldSource = null;
        JavaFileObject newSource = null;
        JCDiagnostic.DiagnosticPosition pos = null;
        JavacElements elemUtils = processingEnv.getElementUtils();
        Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
        if (treeTop != null) {
            newSource = treeTop.snd.sourcefile;
            if (newSource != null) {
                oldSource = log.useSource(newSource);
                pos = treeTop.fst.pos();
View Full Code Here

        // Initialize services before any processors are initialzied
        // in case processors use them.
        filer = new JavacFiler(context);
        messager = new JavacMessager(context, this);
        elementUtils = new JavacElements(context);
        typeUtils = new JavacTypes(context);
        processorOptions = initProcessorOptions(context);
        unmatchedProcessorOptions = initUnmatchedProcessorOptions();
        initProcessorIterator(context, processors);
    }
View Full Code Here

    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                      Element e, AnnotationMirror a, AnnotationValue v) {
        JavaFileObject oldSource = null;
        JavaFileObject newSource = null;
        JCDiagnostic.DiagnosticPosition pos = null;
        JavacElements elemUtils = processingEnv.getElementUtils();
        Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
        if (treeTop != null) {
            newSource = treeTop.snd.sourcefile;
            if (newSource != null) {
                oldSource = log.useSource(newSource);
                pos = treeTop.fst.pos();
View Full Code Here

        // Initialize services before any processors are initialzied
        // in case processors use them.
        filer = new JavacFiler(context);
        messager = new JavacMessager(context, this);
        elementUtils = new JavacElements(context);
        typeUtils = new JavacTypes(context);
        processorOptions = initProcessorOptions(context);
        unmatchedProcessorOptions = initUnmatchedProcessorOptions();
        initProcessorIterator(context, processors);
        DEBUG.P(0,this,"JavacProcessingEnvironment(2)");
View Full Code Here

    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
          Element e, AnnotationMirror a, AnnotationValue v) {
  JavaFileObject oldSource = null;
  JavaFileObject newSource = null;
  JCDiagnostic.DiagnosticPosition pos = null;
  JavacElements elemUtils = processingEnv.getElementUtils();
  Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
  if (treeTop != null) {
      newSource = treeTop.snd.sourcefile;
      if (newSource != null) {
    oldSource = log.useSource(newSource);
    pos = treeTop.fst.pos();
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.model.JavacElements

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.