core/src/main/java/org/apidesign/bck2brwsr/core/impl/JavaScriptProcesor.java
brancharithmetic
changeset 774 42bc1e89134d
parent 755 5652acd48509
parent 773 406faa8bc64f
child 778 6f8683517f1f
     1.1 --- a/core/src/main/java/org/apidesign/bck2brwsr/core/impl/JavaScriptProcesor.java	Mon Feb 25 19:00:08 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,94 +0,0 @@
     1.4 -/**
     1.5 - * Back 2 Browser Bytecode Translator
     1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 - *
     1.8 - * This program is free software: you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License as published by
    1.10 - * the Free Software Foundation, version 2 of the License.
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program. Look for COPYING file in the top folder.
    1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    1.20 - */
    1.21 -package org.apidesign.bck2brwsr.core.impl;
    1.22 -
    1.23 -import java.util.Collections;
    1.24 -import java.util.HashSet;
    1.25 -import java.util.List;
    1.26 -import java.util.Set;
    1.27 -import javax.annotation.processing.AbstractProcessor;
    1.28 -import javax.annotation.processing.Completion;
    1.29 -import javax.annotation.processing.Completions;
    1.30 -import javax.annotation.processing.Processor;
    1.31 -import javax.annotation.processing.RoundEnvironment;
    1.32 -import javax.lang.model.element.AnnotationMirror;
    1.33 -import javax.lang.model.element.Element;
    1.34 -import javax.lang.model.element.ElementKind;
    1.35 -import javax.lang.model.element.ExecutableElement;
    1.36 -import javax.lang.model.element.TypeElement;
    1.37 -import javax.lang.model.element.VariableElement;
    1.38 -import javax.tools.Diagnostic;
    1.39 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
    1.40 -import org.openide.util.lookup.ServiceProvider;
    1.41 -
    1.42 -/**
    1.43 - *
    1.44 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.45 - */
    1.46 -@ServiceProvider(service = Processor.class)
    1.47 -public final class JavaScriptProcesor extends AbstractProcessor {
    1.48 -    @Override
    1.49 -    public Set<String> getSupportedAnnotationTypes() {
    1.50 -        Set<String> set = new HashSet<>();
    1.51 -        set.add(JavaScriptBody.class.getName());
    1.52 -        return set;
    1.53 -    }
    1.54 -    
    1.55 -    @Override
    1.56 -    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    1.57 -        for (Element e : roundEnv.getElementsAnnotatedWith(JavaScriptBody.class)) {
    1.58 -            if (e.getKind() != ElementKind.METHOD && e.getKind() != ElementKind.CONSTRUCTOR) {
    1.59 -                continue;
    1.60 -            }
    1.61 -            ExecutableElement ee = (ExecutableElement)e;
    1.62 -            List<? extends VariableElement> params = ee.getParameters();
    1.63 -            
    1.64 -            JavaScriptBody jsb = e.getAnnotation(JavaScriptBody.class);
    1.65 -            if (jsb == null) {
    1.66 -                continue;
    1.67 -            }
    1.68 -            String[] arr = jsb.args();
    1.69 -            if (params.size() != arr.length) {
    1.70 -                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Number of args arguments does not match real arguments!", e);
    1.71 -            }
    1.72 -        }
    1.73 -        return true;
    1.74 -    }
    1.75 -
    1.76 -    @Override
    1.77 -    public Iterable<? extends Completion> getCompletions(Element e, 
    1.78 -        AnnotationMirror annotation, ExecutableElement member, String userText
    1.79 -    ) {
    1.80 -        StringBuilder sb = new StringBuilder();
    1.81 -        if (e.getKind() == ElementKind.METHOD && member.getSimpleName().contentEquals("args")) {
    1.82 -            ExecutableElement ee = (ExecutableElement) e;
    1.83 -            String sep = "";
    1.84 -            sb.append("{ ");
    1.85 -            for (VariableElement ve : ee.getParameters()) {
    1.86 -                sb.append(sep).append('"').append(ve.getSimpleName())
    1.87 -                    .append('"');
    1.88 -                sep = ", ";
    1.89 -            }
    1.90 -            sb.append(" }");
    1.91 -            return Collections.nCopies(1, Completions.of(sb.toString()));
    1.92 -        }
    1.93 -        return null;
    1.94 -    }
    1.95 -
    1.96 -    
    1.97 -}