Added conversion to long for JavaScript implementation of System.currentTimeMillis
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.bck2brwsr.core.impl;
20 import java.util.Collections;
21 import java.util.HashSet;
22 import java.util.List;
24 import javax.annotation.processing.AbstractProcessor;
25 import javax.annotation.processing.Completion;
26 import javax.annotation.processing.Completions;
27 import javax.annotation.processing.Processor;
28 import javax.annotation.processing.RoundEnvironment;
29 import javax.lang.model.element.AnnotationMirror;
30 import javax.lang.model.element.Element;
31 import javax.lang.model.element.ElementKind;
32 import javax.lang.model.element.ExecutableElement;
33 import javax.lang.model.element.TypeElement;
34 import javax.lang.model.element.VariableElement;
35 import javax.tools.Diagnostic;
36 import org.apidesign.bck2brwsr.core.JavaScriptBody;
37 import org.openide.util.lookup.ServiceProvider;
41 * @author Jaroslav Tulach <jtulach@netbeans.org>
43 @ServiceProvider(service = Processor.class)
44 public final class JavaScriptProcesor extends AbstractProcessor {
46 public Set<String> getSupportedAnnotationTypes() {
47 Set<String> set = new HashSet<>();
48 set.add(JavaScriptBody.class.getName());
53 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
54 for (Element e : roundEnv.getElementsAnnotatedWith(JavaScriptBody.class)) {
55 if (e.getKind() != ElementKind.METHOD && e.getKind() != ElementKind.CONSTRUCTOR) {
58 ExecutableElement ee = (ExecutableElement)e;
59 List<? extends VariableElement> params = ee.getParameters();
61 JavaScriptBody jsb = e.getAnnotation(JavaScriptBody.class);
65 String[] arr = jsb.args();
66 if (params.size() != arr.length) {
67 processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Number of args arguments does not match real arguments!", e);
74 public Iterable<? extends Completion> getCompletions(Element e,
75 AnnotationMirror annotation, ExecutableElement member, String userText
77 StringBuilder sb = new StringBuilder();
78 if (e.getKind() == ElementKind.METHOD && member.getSimpleName().contentEquals("args")) {
79 ExecutableElement ee = (ExecutableElement) e;
82 for (VariableElement ve : ee.getParameters()) {
83 sb.append(sep).append('"').append(ve.getSimpleName())
88 return Collections.nCopies(1, Completions.of(sb.toString()));