Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7665cb518c21116c94ccb082c6ce7789eda2c2d5 (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
/*******************************************************************************
 * Copyright (c) 2005, 2007 BEA Systems, Inc.
 *
 * 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
 *******************************************************************************/
package org.eclipse.jdt.apt.tests.annotations.generic;

import java.util.Collection;

import junit.framework.AssertionFailedError;

import com.sun.mirror.apt.*;
import com.sun.mirror.declaration.*;

public abstract class AbstractGenericProcessor implements AnnotationProcessor {
	protected AnnotationProcessorEnvironment env;
	protected AnnotationTypeDeclaration genericAnnotation;
	protected Collection<Declaration> decls;
	
	public void setEnv(AnnotationProcessorEnvironment env) {
		this.env = env;
		genericAnnotation = (AnnotationTypeDeclaration) env.getTypeDeclaration(GenericAnnotation.class.getName());
		decls = env.getDeclarationsAnnotatedWith(genericAnnotation);
	}
	
	public abstract void _process();
	
	/**
	 * This method is abstract, so that subclasses need to implement
	 * _process. We'll handle catching any errant throwables
	 * and fail any junit tests.
	 */
	public final void process() {
		try {
			_process();
		}
		catch (Throwable t) {
			t.printStackTrace();
			throw new AssertionFailedError("Processor threw an exception during processing");
		}
	}
	
}

Back to the top