All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redhat.ceylon.langtools.tools.javac.api.BasicJavacTask Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
/*
 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package com.redhat.ceylon.langtools.tools.javac.api;

import java.io.IOException;
import java.util.Collection;
import java.util.Locale;

import com.redhat.ceylon.javax.annotation.processing.Processor;
import com.redhat.ceylon.javax.lang.model.element.Element;
import com.redhat.ceylon.javax.lang.model.type.TypeMirror;
import com.redhat.ceylon.javax.lang.model.util.Elements;
import com.redhat.ceylon.javax.lang.model.util.Types;
import com.redhat.ceylon.javax.tools.JavaFileObject;

import com.redhat.ceylon.langtools.source.tree.CompilationUnitTree;
import com.redhat.ceylon.langtools.source.tree.Tree;
import com.redhat.ceylon.langtools.source.util.JavacTask;
import com.redhat.ceylon.langtools.source.util.TaskListener;
import com.redhat.ceylon.langtools.tools.javac.model.JavacElements;
import com.redhat.ceylon.langtools.tools.javac.model.JavacTypes;
import com.redhat.ceylon.langtools.tools.javac.tree.JCTree;
import com.redhat.ceylon.langtools.tools.javac.util.Context;

/**
 * Provides basic functionality for implementations of JavacTask.
 *
 * 

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own * risk. This code and its internal interfaces are subject to change * or deletion without notice.

*/ public class BasicJavacTask extends JavacTask { protected Context context; private TaskListener taskListener; public static JavacTask instance(Context context) { JavacTask instance = context.get(JavacTask.class); if (instance == null) instance = new BasicJavacTask(context, true); return instance; } public BasicJavacTask(Context c, boolean register) { context = c; if (register) context.put(JavacTask.class, this); } @Override public Iterable parse() throws IOException { throw new IllegalStateException(); } @Override public Iterable analyze() throws IOException { throw new IllegalStateException(); } @Override public Iterable generate() throws IOException { throw new IllegalStateException(); } @Override public void setTaskListener(TaskListener tl) { MultiTaskListener mtl = MultiTaskListener.instance(context); if (taskListener != null) mtl.remove(taskListener); if (tl != null) mtl.add(tl); taskListener = tl; } @Override public void addTaskListener(TaskListener taskListener) { MultiTaskListener mtl = MultiTaskListener.instance(context); mtl.add(taskListener); } @Override public void removeTaskListener(TaskListener taskListener) { MultiTaskListener mtl = MultiTaskListener.instance(context); mtl.remove(taskListener); } public Collection getTaskListeners() { MultiTaskListener mtl = MultiTaskListener.instance(context); return mtl.getTaskListeners(); } @Override public TypeMirror getTypeMirror(Iterable path) { // TODO: Should complete attribution if necessary Tree last = null; for (Tree node : path) last = node; return ((JCTree)last).type; } @Override public Elements getElements() { return JavacElements.instance(context); } @Override public Types getTypes() { return JavacTypes.instance(context); } public void setProcessors(Iterable processors) { throw new IllegalStateException(); } public void setLocale(Locale locale) { throw new IllegalStateException(); } public Boolean call() { throw new IllegalStateException(); } /** * For internal use only. This method will be * removed without warning. */ public Context getContext() { return context; } /** * For internal use only. This method will be * removed without warning. */ public void updateContext(Context newContext) { context = newContext; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy