blob: f2e7417bf6ce12cd2536c96a7cee4330f6edb38f [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2007 BEA Systems, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* mkaufman@bea.com - initial API and implementation
*
*******************************************************************************/
package org.eclipse.jdt.apt.core.env;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.dom.CompilationUnit;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
public class EnvironmentFactory {
/**
* Return a processor environment for use outside of building or reconciling.
* Note that this environment does <b>NOT</b> support the Filer or Messager API,
* as it is to be used to perform type system navigation, not building.<p>
*
* If either getFiler() or getMessager() are called, this environment
* will throw an UnsupportedOperationException.
*
* @param compilationUnit the working copy for which the Environment object is to be created
* @param javaProject the java project that the working copy is in.
* @return the created environment.
*/
public static AnnotationProcessorEnvironment getEnvironment(ICompilationUnit compilationUnit, IJavaProject javaProject )
{
CompilationUnit node = BaseProcessorEnv.createAST( javaProject, compilationUnit);
BaseProcessorEnv env = new BaseProcessorEnv(
node,
(IFile)compilationUnit.getResource(),
javaProject,
Phase.OTHER
);
return env;
}
}