blob: b63abf0372dbc36a3741ec13010174f0828335c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*******************************************************************************
* Copyright (c) 2018 Till Brychcy and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Till Brychcy - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests;
import java.io.IOException;
import java.io.Writer;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.tools.JavaFileObject;
@SupportedAnnotationTypes("targets.AnnotationProcessorTests.Bug540090.Bug540090")
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class Bug540090Proc extends AbstractProcessor
{
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
Filer filer = processingEnv.getFiler();
if (!annotations.isEmpty()) {
try {
JavaFileObject jfo = filer.createSourceFile("gen.GenClass");
Writer writer = jfo.openWriter();
writer.write("package gen;\n");
writer.write("public class GenClass {\n");
writer.write(" int x;");
writer.write("}\n");
writer.close();
return true;
} catch (IOException e) {
return false;
}
}
return true;
}
}
|