Ported Javac 11 for Android

Wrote Language Server API for AndroidIDE
Implemented the java language server in the IDE itself
This commit is contained in:
Akash Yadav
2022-01-14 20:45:32 +05:30
parent ac26609441
commit 3a22124873
184 changed files with 9707 additions and 9776 deletions
+31
View File
@@ -1,5 +1,21 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETER" value="true" />
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="SPACE_BEFORE_METHOD_CALL_PARENTHESES" value="true" />
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<indentOptions>
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
@@ -113,5 +129,20 @@
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
<option name="CALL_PARAMETERS_WRAP" value="0" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="false" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="false" />
<option name="METHOD_PARAMETERS_WRAP" value="0" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="false" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="false" />
<option name="EXTENDS_LIST_WRAP" value="0" />
<option name="METHOD_CALL_CHAIN_WRAP" value="0" />
<option name="ASSIGNMENT_WRAP" value="0" />
<indentOptions>
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>
+1 -1
View File
@@ -1,5 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
+6 -4
View File
@@ -79,9 +79,9 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
// Annotation processors
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
@@ -120,11 +120,13 @@ dependencies {
// Local projects here
implementation project(':treeview')
implementation project(':emulatorview')
implementation project(':javapoet')
implementation project(':lsp')
implementation project(':xml-inflater')
implementation project(':lexers')
implementation project(':common')
implementation project(':lsp:api')
implementation project(':lsp:java')
// LSP4J
implementation common.lsp4j
Binary file not shown.
Binary file not shown.
@@ -104,6 +104,8 @@ import com.itsaky.androidide.views.CodeEditorView;
import com.itsaky.androidide.views.MaterialBanner;
import com.itsaky.androidide.views.SymbolInputView;
import com.itsaky.inflater.ILayoutInflater;
import com.itsaky.lsp.java.models.JavaServerConfiguration;
import com.itsaky.lsp.models.InitializeParams;
import com.itsaky.lsp.services.IDELanguageServer;
import com.itsaky.toaster.Toaster;
import com.unnamed.b.atv.model.TreeNode;
@@ -116,7 +118,10 @@ import org.eclipse.lsp4j.Range;
import org.jetbrains.annotations.Contract;
import java.io.File;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -125,6 +130,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import io.github.rosemoe.editor.widget.CodeEditor;
import me.piruin.quickaction.ActionItem;
@@ -844,13 +850,24 @@ public class EditorActivity extends StudioActivity implements FileTreeFragment.F
public void createServices () {
new TaskExecutor ().executeAsync (() -> {
List<String> cps = Objects.requireNonNull (getAndroidProject ()).getClassPaths ();
getApp ()
.getJavaLanguageServer ()
.configurationChanged (
new JavaServerConfiguration (
cps.stream ()
.map (Paths::get)
.collect (Collectors.toSet ())
)
);
IDELanguageServer javaServer = LSPProvider.getServerForLanguage (LSPProvider.LANGUAGE_JAVA);
if (javaServer == null) {
LOG.error ("Cannot create services as java language server instance is null");
return null;
}
List<String> cps = Objects.requireNonNull (getAndroidProject ()).getClassPaths ();
JsonObject settings = new JsonObject ();
JsonObject java = new JsonObject ();
JsonArray classPath = new JsonArray ();
@@ -921,7 +938,7 @@ public class EditorActivity extends StudioActivity implements FileTreeFragment.F
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
mBinding.editorContainer.addView (editor);
mBinding.editorContainer.setDisplayedChild (position);
mBinding.tabs.addTab (mBinding.tabs.newTab ().setText (file.getName ()));
@@ -1142,6 +1159,7 @@ public class EditorActivity extends StudioActivity implements FileTreeFragment.F
private void startLanguageServers () {
LSP.setActivityProvider (this);
LSP.Java.start (() -> {
getApp ().getJavaLanguageServer ().initialize (new InitializeParams (Collections.singleton (new File (Objects.requireNonNull (getAndroidProject ()).getProjectPath ()).toPath ())));
Optional<InitializeResult> result = LSP.Java.init (Objects.requireNonNull (getAndroidProject ()).getProjectPath ());
if (result.isPresent ()) {
LSP.Java.initialized ();
@@ -18,9 +18,13 @@
package com.itsaky.androidide.app;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import android.util.TypedValue;
import android.view.View;
import androidx.annotation.AttrRes;
@@ -32,6 +36,7 @@ import androidx.fragment.app.FragmentTransaction;
import com.itsaky.androidide.R;
import com.itsaky.androidide.services.builder.IDEService;
import com.itsaky.androidide.utils.Logger;
import com.itsaky.toaster.Toaster;
public abstract class StudioActivity extends AppCompatActivity {
private boolean toRequestStorage = true;
@@ -46,10 +51,16 @@ public abstract class StudioActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(bindLayout());
onSetContentView();
if (toRequestStorage && !isStoragePermissionGranted())
if (toRequestStorage && !isStoragePermissionGranted()) {
requestStorage();
else if (isStoragePermissionGranted())
}
if (isStoragePermissionGranted()) {
onStorageAlreadyGranted();
} else {
onStorageDenied ();
}
}
public boolean isStoragePermissionGranted() {
@@ -19,6 +19,8 @@ package com.itsaky.androidide.app;
import android.content.Intent;
import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ThrowableUtils;
import com.google.firebase.messaging.FirebaseMessaging;
import com.itsaky.androidide.CrashHandlerActivity;
@@ -31,6 +33,8 @@ import com.itsaky.attrinfo.AttrInfo;
import com.itsaky.inflater.ILayoutInflater;
import com.itsaky.inflater.IResourceTable;
import com.itsaky.inflater.LayoutInflaterConfiguration;
import com.itsaky.lsp.api.ILanguageServer;
import com.itsaky.lsp.java.JavaLanguageServer;
import com.itsaky.widgets.WidgetInfo;
import java.io.File;
@@ -43,6 +47,7 @@ public class StudioApp extends BaseApplication {
private static AttrInfo mAttrInfo;
private static WidgetInfo mWidgetInfo;
private final ILanguageServer mJavaLanguageServer = new JavaLanguageServer ();
private IResourceTable mResFinder;
private XMLCompletionService mXmlCompletionService;
private ILayoutInflater mLayoutInflater;
@@ -64,6 +69,11 @@ public class StudioApp extends BaseApplication {
initializeApiInformation();
}
@NonNull
public ILanguageServer getJavaLanguageServer () {
return mJavaLanguageServer;
}
private void handleCrash(Thread thread, Throwable th) {
writeException(th);
@@ -92,7 +102,7 @@ public class StudioApp extends BaseApplication {
return new LayoutInflaterConfiguration.Builder ()
.setAttrInfo(this.attrInfo())
.setWidgetInfo(this.widgetInfo())
.setResourceFinder(mResFinder == null ? mResFinder = new ProjectResourceTable () : mResFinder)
.setResourceFinder(mResFinder == null ? mResFinder = new ProjectResourceTable (resDirs) : mResFinder)
.setResourceDirectories(resDirs)
.setContextProvider(contextProvider)
.create();
@@ -17,78 +17,79 @@
**************************************************************************************/
package com.itsaky.androidide.language.java;
import com.itsaky.androidide.lsp.LSPProvider;
import com.itsaky.androidide.app.StudioApp;
import com.itsaky.androidide.utils.Logger;
import com.itsaky.lsp.services.IDELanguageServer;
import io.github.rosemoe.editor.interfaces.AutoCompleteProvider;
import io.github.rosemoe.editor.text.TextAnalyzeResult;
import com.itsaky.lsp.models.CompletionResult;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.CompletionItemKind;
import java.net.URI;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.CompletionList;
import org.eclipse.lsp4j.CompletionParams;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import com.itsaky.androidide.app.StudioApp;
import io.github.rosemoe.editor.interfaces.AutoCompleteProvider;
import io.github.rosemoe.editor.text.TextAnalyzeResult;
public class JavaAutoComplete implements AutoCompleteProvider {
private CompletableFuture<Either<List<CompletionItem>, CompletionList>> future;
private CompletableFuture<CompletionResult> future;
@Override
public List<CompletionItem> getAutoCompleteItems(CharSequence content, String fileUri, String prefix, boolean isInCodeBlock, TextAnalyzeResult colors, int index, int line, int column) throws Exception {
IDELanguageServer languageServer = LSPProvider.getServerForLanguage(LSPProvider.LANGUAGE_JAVA);
if(languageServer != null && fileUri != null) {
if(future != null && !future.isDone()) future.cancel(true);
CompletionParams params = new CompletionParams();
params.setPosition(new Position(line, column));
params.setTextDocument(new TextDocumentIdentifier(fileUri));
future = languageServer.getTextDocumentService().completion(params);
if(future.isCancelled()) {
LOG.debug ("Completion request was cancelled");
return finalizeResults(new ArrayList<CompletionItem>());
try {
if (this.future != null && !this.future.isDone ()) {
try {
this.future.cancel (true);
} catch (CancellationException e) {
// Do not pollute logs with cancellation exceptions
return new ArrayList<> ();
}
}
this.future = CompletableFuture.supplyAsync (() -> {
final var server = StudioApp.getInstance ().getJavaLanguageServer ();
final var completer = server.getCompletionProvider ();
final var params = new com.itsaky.lsp.models.CompletionParams (new com.itsaky.lsp.models.Position (line, column), Paths.get (URI.create (fileUri)));
return completer.complete (params);
});
final var result = future.get ();
final var list = new ArrayList<CompletionItem> ();
for (final var item : result.getItems ()) {
final var i = new CompletionItem ();
i.setLabel (item.getLabel ());
i.setDetail (item.getDetail ());
i.setKind (CompletionItemKind.Method);
i.setSortText (item.getSortText ());
i.setInsertText (item.getInsertText ());
list.add (i);
}
try {
Either<List<CompletionItem>, CompletionList> either = future.get();
if(either.isLeft()) {
return finalizeResults(either.getLeft());
}
if(either.isRight()) {
return finalizeResults(either.getRight().getItems());
}
} catch (Throwable th) {
LOG.error(StudioApp.getInstance().getString(com.itsaky.androidide.R.string.err_completion), th);
}
} else {
LOG.error(StudioApp.getInstance().getString(com.itsaky.androidide.R.string.err_no_server_implementation));
return finalizeResults (list);
} catch (Throwable th) {
LOG.error ("Java completion error", th);
}
return new ArrayList<CompletionItem>();
return new ArrayList<>();
}
private List<CompletionItem> finalizeResults(List<CompletionItem> items) {
Collections.sort(items, RESULT_SORTER);
items.sort (RESULT_SORTER);
return items;
}
private static final Comparator<CompletionItem> RESULT_SORTER = new Comparator<CompletionItem>(){
@Override
public int compare(CompletionItem p1, CompletionItem p2) {
String s1 = p1.getSortText() == null ? p1.getLabel() : p1.getSortText();
String s2 = p2.getSortText() == null ? p2.getLabel() : p2.getSortText();
return s1.compareTo(s2);
}
};
private static final Comparator<CompletionItem> RESULT_SORTER = (p1, p2) -> {
String s1 = p1.getSortText () == null ? p1.getLabel () : p1.getSortText ();
String s2 = p2.getSortText () == null ? p2.getLabel () : p2.getSortText ();
return s1.compareTo (s2);
};
private static final Logger LOG = Logger.instance("JavaAutoComplete");
}
@@ -55,33 +55,33 @@ public class JLSHandler implements LSPHandler {
@Override
public void start(Runnable onStarted) {
try {
final IProcessExecutor executor = ProcessExecutorFactory.commonExecutor();
final ProcessStreamsHolder holder = new ProcessStreamsHolder();
final IProcessExitListener listener = new IProcessExitListener() {
@Override
public void onExit(int code) {
LOG.info("Java Language server terminated with exit code " + code);
shutdown();
}
};
executor.execAsync(holder, listener, false, Environment.JAVA.getAbsolutePath(), "-jar", Environment.JLS_JAR.getAbsolutePath(), QUIET ? "--quiet" : "");
startReader (holder.err); // holder.in is used by LSP4J
if (!IDELanguageClientImpl.isInitialized()) {
IDELanguageClientImpl.initialize(LSP.PROVIDER);
}
IDELanguageClientImpl client = IDELanguageClientImpl.getInstance();
mLauncher = new StandardStreamsLauncher(client, holder.in, holder.out, LSPProvider.LANGUAGE_JAVA);
mLauncher.setLaunchListener(server -> onStarted.run());
mLauncher.start();
} catch (Throwable th) {
LOG.error(StudioApp.getInstance().getString(com.itsaky.androidide.R.string.err_cannot_start_server, LSPProvider.LANGUAGE_JAVA), th);
}
// try {
// final IProcessExecutor executor = ProcessExecutorFactory.commonExecutor();
// final ProcessStreamsHolder holder = new ProcessStreamsHolder();
// final IProcessExitListener listener = new IProcessExitListener() {
// @Override
// public void onExit(int code) {
// LOG.info("Java Language server terminated with exit code " + code);
// shutdown();
// }
// };
//
// executor.execAsync(holder, listener, false, Environment.JAVA.getAbsolutePath(), "-jar", Environment.JLS_JAR.getAbsolutePath(), QUIET ? "--quiet" : "");
// startReader (holder.err); // holder.in is used by LSP4J
//
// if (!IDELanguageClientImpl.isInitialized()) {
// IDELanguageClientImpl.initialize(LSP.PROVIDER);
// }
//
// IDELanguageClientImpl client = IDELanguageClientImpl.getInstance();
//
// mLauncher = new StandardStreamsLauncher(client, holder.in, holder.out, LSPProvider.LANGUAGE_JAVA);
// mLauncher.setLaunchListener(server -> onStarted.run());
// mLauncher.start();
//
// } catch (Throwable th) {
// LOG.error(StudioApp.getInstance().getString(com.itsaky.androidide.R.string.err_cannot_start_server, LSPProvider.LANGUAGE_JAVA), th);
// }
}
@Override
@@ -0,0 +1,46 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.project;
import android.os.Build;
import android.os.FileObserver;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import java.io.File;
import java.util.List;
/**
* A file observer that observer files in project directories.
* Sub classes need to provide the file extensions that they want to get
* notified about.
*
* @author Akash Yadav
*/
public abstract class ProjectFileObserver extends FileObserver {
// Cannot use constructors that accept java.io.File
// They were added in API 29
public ProjectFileObserver (String path) {
this (path, ALL_EVENTS);
}
public ProjectFileObserver (String path, int mask) {
super (path, mask);
}
}
@@ -17,10 +17,14 @@
**************************************************************************************/
package com.itsaky.androidide.project;
import android.os.FileObserver;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.itsaky.androidide.utils.Logger;
import com.itsaky.inflater.IResourceTable;
import java.io.File;
import java.io.FileFilter;
@@ -34,6 +38,17 @@ public class ProjectResourceTable implements IResourceTable {
private File[] drawables;
private File[] mipmaps;
private final FileObserver mFileObserver;
public ProjectResourceTable (@NonNull final Iterable<File> resourceDirectories) {
mFileObserver = new FileObserver (resDir) {
@Override
public void onEvent (int event, @Nullable String path) {
}
};
}
private static final Logger LOG = Logger.instance ("ProjectResourceFinder");
@Override
@@ -62,7 +77,7 @@ public class ProjectResourceTable implements IResourceTable {
public String findColor(@NonNull String name) {
return name;
}
@Override
public String[] findArray(@NonNull String name) {
return new String[] {name};
@@ -1,90 +0,0 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.utils;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;
import javax.lang.model.element.Modifier;
/**
* A utility class to generate Java source code
*/
public class ClassBuilder {
public static String createClass(String packageName, String className) {
return toJavaFile(packageName, newClassSpec(className)).toString();
}
public static String createInterface(String packageName, String className) {
return toJavaFile(packageName, newInterfaceSpec(className)).toString();
}
public static String createEnum(String packageName, String className) {
return toJavaFile(packageName, newEnumSpec(className)).toString();
}
public static String createActivity(String packageName, String className) {
MethodSpec onCreate = MethodSpec.methodBuilder("onCreate")
.addAnnotation(Override.class)
.addModifiers(Modifier.PROTECTED)
.addParameter(android.os.Bundle.class, "savedInstanceState")
.addStatement("super.onCreate(savedInstanceState)")
.build();
TypeSpec.Builder activity = newClassSpec(className)
.toBuilder()
.superclass(androidx.appcompat.app.AppCompatActivity.class)
.addMethod(onCreate);
return JavaFile.builder(packageName, activity.build())
.build()
.toString();
}
// TODO: Allow user to choose number of spaces to indent
// Most probably, get this from preferences
public static JavaFile toJavaFile(String packageName, TypeSpec type) {
return JavaFile.builder(packageName, type)
.indent(" ") // Indent 4 spaces
.build();
}
public static TypeSpec newClassSpec(String className) {
return TypeSpec.classBuilder(className)
.addModifiers(Modifier.PUBLIC)
.build();
}
public static TypeSpec newInterfaceSpec(String className) {
return TypeSpec.interfaceBuilder(className)
.addModifiers(Modifier.PUBLIC)
.build();
}
public static TypeSpec newEnumSpec(String className) {
return TypeSpec.enumBuilder(className)
.addModifiers(Modifier.PUBLIC)
.addEnumConstant("ENUM_DECLARED")
.build();
}
}
@@ -76,6 +76,8 @@ import com.itsaky.androidide.utils.Logger;
import com.itsaky.androidide.utils.Symbols;
import com.itsaky.androidide.utils.TypefaceUtils;
import com.itsaky.lsp.SemanticHighlight;
import com.itsaky.lsp.models.DocumentChangeEvent;
import com.itsaky.lsp.models.DocumentOpenEvent;
import com.itsaky.lsp.services.IDELanguageServer;
import com.itsaky.toaster.Toaster;
@@ -101,6 +103,9 @@ import io.github.rosemoe.editor.util.IntPair;
import io.github.rosemoe.editor.util.LongArrayList;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -358,15 +363,19 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
if (mLanguage != null && mLanguage instanceof AbstractEditorLanguage) {
((AbstractEditorLanguage) mLanguage).setFile (file);
}
if (mLanguageServer != null) {
TextDocumentItem item = new TextDocumentItem ();
item.setLanguageId (getLanguageIdForFile ());
item.setText (getText ().toString ());
item.setUri (file.toURI ().toString ());
item.setVersion (mFileVersion = 0);
mLanguageServer.getTextDocumentService ().didOpen (new DidOpenTextDocumentParams (item));
}
final var text = getText ().toString ();
final var javaLs = StudioApp.getInstance ().getJavaLanguageServer ();
javaLs.getDocumentHandler ().onFileOpened (new DocumentOpenEvent (file.toPath (), text, ++mFileVersion));
// if (mLanguageServer != null) {
// TextDocumentItem item = new TextDocumentItem ();
// item.setLanguageId (getLanguageIdForFile ());
// item.setText (text);
// item.setUri (file.toURI ().toString ());
// item.setVersion (mFileVersion);
// mLanguageServer.getTextDocumentService ().didOpen (new DidOpenTextDocumentParams (item));
// }
}
private String getLanguageIdForFile () {
@@ -5026,13 +5035,21 @@ public class CodeEditor extends View implements ContentListener, TextAnalyzer.Ca
}
private void notifyChanged () {
if (mLanguageServer != null) {
mLastEdited = System.currentTimeMillis ();
DidChangeTextDocumentParams p = didChangeParams ();
if (p != null) {
mLanguageServer.getTextDocumentService ().didChange (p);
}
if (getFile () == null) {
return;
}
StudioApp.getInstance ()
.getJavaLanguageServer ()
.getDocumentHandler ()
.onContentChange (
new DocumentChangeEvent (
getFile ().toPath (),
getText ().toString (),
mFileVersion + 1
)
);
}
protected DidChangeTextDocumentParams didChangeParams () {
+3 -1
View File
@@ -1,8 +1,9 @@
buildscript {
ext.kotlin_version = '1.6.10'
project.ext {
compileSdk = 31
buildTools = "31.0.0"
minSdk = 24
minSdk = 26
targetSdk = 28
versionCode = 200
versionName = "2.0-beta"
@@ -23,6 +24,7 @@ buildscript {
classpath "com.android.tools.build:gradle:7.0.4"
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -61,15 +61,14 @@ public abstract class BaseApplication extends MultiDexApplication {
@Override
public void onCreate() {
instance = this;
Environment.init ();
super.onCreate();
mPrefsManager = new PreferenceManager(this);
JavaCharacter.initMap();
ToolsManager.init(this, null);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannels();
}
createNotificationChannels();
}
@SuppressLint("NewApi")
@@ -31,36 +31,38 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
@SuppressLint("SdCardPath")
public final class Environment {
public static final File ROOT;
public static final File SYSROOT;
public static final File HOME;
public static final File JAVA_HOME;
public static final File ANDROID_HOME;
public static final File JLS_HOME;
public static final File TMP_DIR;
public static final File BIN_DIR;
public static final File LIB_DIR;
public static final File PROJECTS_DIR;
public static final File IDE_PROPS_FILE;
public static final File LIB_HOOK;
public static final File LIB_HOOK2;
public static File ROOT;
public static File SYSROOT;
public static File HOME;
public static File JAVA_HOME;
public static File ANDROID_HOME;
public static File JLS_HOME;
public static File TMP_DIR;
public static File BIN_DIR;
public static File LIB_DIR;
public static File PROJECTS_DIR;
public static File IDE_PROPS_FILE;
public static File LIB_HOOK;
public static File LIB_HOOK2;
public static final File INIT_SCRIPT;
public static final File PROJECT_DATA_FILE;
public static final File JLS_JAR;
public static File INIT_SCRIPT;
public static File PROJECT_DATA_FILE;
public static File JLS_JAR;
public static final File GRADLE_PROPS;
public static final File GRADLE_USER_HOME;
public static File GRADLE_PROPS;
public static File GRADLE_USER_HOME;
public static final File JAVA;
public static final File BUSYBOX;
public static final File SHELL;
public static final File LOGIN_SHELL;
public static File JAVA;
public static File BUSYBOX;
public static File SHELL;
public static File LOGIN_SHELL;
public static File BOOTCLASSPATH;
@@ -75,8 +77,8 @@ public final class Environment {
private static final Logger LOG = Logger.instance("Environment");
static {
final BaseApplication app = BaseApplication.getBaseInstance();
public static void init () {
final BaseApplication app = BaseApplication.getBaseInstance();
ROOT = app.getIDEDataDir();
SYSROOT = mkdirIfNotExits(new File(app.getIDEDataDir(), "sysroot"));
HOME = mkdirIfNotExits(app.getRootDir());
@@ -96,7 +98,7 @@ public final class Environment {
BOOTCLASSPATH = new File("");
GRADLE_USER_HOME = new File(HOME, ".gradle");
GRADLE_PROPS = new File(GRADLE_USER_HOME, "gradle.properties");
IDE_PROPS.putAll(readProperties());
ANDROID_HOME = new File(readProp("ANDROID_HOME", DEFAULT_ANDROID_HOME));
JAVA_HOME = new File(readProp("JAVA_HOME", DEFAULT_JAVA_HOME));
@@ -112,7 +114,21 @@ public final class Environment {
System.setProperty("user.home", HOME.getAbsolutePath());
System.setProperty("java.home", JAVA_HOME.getAbsolutePath());
}
CompletableFuture.runAsync (() -> {
try {
final var tClass = Objects.requireNonNull (Environment.class.getClassLoader ())
.loadClass ("com.itsaky.javac11.LocationsProvider");
final var method = tClass.getDeclaredMethod ("init");
if (!method.isAccessible ()) {
method.setAccessible (true);
}
method.invoke (null);
} catch (Throwable th) {
LOG.error ("Error notifying LocationsProvider about Environment init", th);
}
});
}
public static void setExecutable (@NonNull final File file) {
if (!file.setExecutable (true)) {
-85
View File
@@ -1,85 +0,0 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
-30
View File
@@ -1,30 +0,0 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.compileSdk
buildToolsVersion rootProject.ext.buildTools
defaultConfig {
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
}
compileOptions {
// Java 11 will not work here
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation google.gson
}
-17
View File
@@ -1,17 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/bogdan/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-1
View File
@@ -1 +0,0 @@
<manifest package="com.itsaky.javax.elements"/>
@@ -1,51 +0,0 @@
/*
* Copyright (c) 2006, 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 javax.annotation.processing;
/**
* A suggested {@linkplain Processor#getCompletions <em>completion</em>} for an
* annotation. A completion is text meant to be inserted into a
* program as part of an annotation.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface Completion {
/**
* Returns the text of the suggested completion.
* @return the text of the suggested completion.
*/
String getValue();
/**
* Returns an informative message about the completion.
* @return an informative message about the completion.
*/
String getMessage();
}
@@ -1,87 +0,0 @@
/*
* Copyright (c) 2006, 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 javax.annotation.processing;
/**
* Utility class for assembling {@link Completion} objects.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public class Completions {
// No instances for you.
private Completions() {}
private static class SimpleCompletion implements Completion {
private String value;
private String message;
SimpleCompletion(String value, String message) {
if (value == null || message == null)
throw new NullPointerException("Null completion strings not accepted.");
this.value = value;
this.message = message;
}
public String getValue() {
return value;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
return "[\"" + value + "\", \"" + message + "\"]";
}
// Default equals and hashCode are fine.
}
/**
* Returns a completion of the value and message.
*
* @param value the text of the completion
* @param message a message about the completion
* @return a completion of the provided value and message
*/
public static Completion of(String value, String message) {
return new SimpleCompletion(value, message);
}
/**
* Returns a completion of the value and an empty message
*
* @param value the text of the completion
* @return a completion of the value and an empty message
*/
public static Completion of(String value) {
return new SimpleCompletion(value, "");
}
}
@@ -1,52 +0,0 @@
/*
* 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 javax.annotation.processing;
import java.io.IOException;
/**
* Indicates a {@link Filer} detected an attempt to open a file that
* would violate the guarantees provided by the {@code Filer}. Those
* guarantees include not creating the same file more than once, not
* creating multiple files corresponding to the same type, and not
* creating files for types with invalid names.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public class FilerException extends IOException {
static final long serialVersionUID = 8426423106453163293L;
/**
* Constructs an exception with the specified detail message.
* @param s the detail message, which should include the name of
* the file attempting to be opened; may be {@code null}
*/
public FilerException(String s) {
super(s);
}
}
@@ -1,113 +0,0 @@
/*
* Copyright (c) 2005, 2007, 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 javax.annotation.processing;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.util.Set;
import java.lang.annotation.Annotation;
/**
* An annotation processing tool framework will {@linkplain
* Processor#process provide an annotation processor with an object
* implementing this interface} so that the processor can query for
* information about a round of annotation processing.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface RoundEnvironment {
/**
* Returns {@code true} if types generated by this round will not
* be subject to a subsequent round of annotation processing;
* returns {@code false} otherwise.
*
* @return {@code true} if types generated by this round will not
* be subject to a subsequent round of annotation processing;
* returns {@code false} otherwise
*/
boolean processingOver();
/**
* Returns {@code true} if an error was raised in the prior round
* of processing; returns {@code false} otherwise.
*
* @return {@code true} if an error was raised in the prior round
* of processing; returns {@code false} otherwise
*/
boolean errorRaised();
/**
* Returns the root elements for annotation processing generated
* by the prior round.
*
* @return the root elements for annotation processing generated
* by the prior round, or an empty set if there were none
*/
Set<? extends Element> getRootElements();
/**
* Returns the elements annotated with the given annotation type.
* The annotation may appear directly or be inherited. Only
* package elements and type elements <i>included</i> in this
* round of annotation processing, or declarations of members,
* constructors, parameters, or type parameters declared within
* those, are returned. Included type elements are {@linkplain
* #getRootElements root types} and any member types nested within
* them. Elements in a package are not considered included simply
* because a {@code package-info} file for that package was
* created.
*
* @param a annotation type being requested
* @return the elements annotated with the given annotation type,
* or an empty set if there are none
* @throws IllegalArgumentException if the argument does not
* represent an annotation type
*/
Set<? extends Element> getElementsAnnotatedWith(TypeElement a);
/**
* Returns the elements annotated with the given annotation type.
* The annotation may appear directly or be inherited. Only
* package elements and type elements <i>included</i> in this
* round of annotation processing, or declarations of members,
* constructors, parameters, or type parameters declared within
* those, are returned. Included type elements are {@linkplain
* #getRootElements root types} and any member types nested within
* them. Elements in a package are not considered included simply
* because a {@code package-info} file for that package was
* created.
*
* @param a annotation type being requested
* @return the elements annotated with the given annotation type,
* or an empty set if there are none
* @throws IllegalArgumentException if the argument does not
* represent an annotation type
*/
Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a);
}
@@ -1,55 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
/**
* An annotation used to indicate what annotation types an annotation
* processor supports. The {@link
* Processor#getSupportedAnnotationTypes} method can construct its
* result from the value of this annotation, as done by {@link
* AbstractProcessor#getSupportedAnnotationTypes}. Only {@linkplain
* Processor#getSupportedAnnotationTypes strings conforming to the
* grammar} should be used as values.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
@Documented
@Target(TYPE)
@Retention(RUNTIME)
public @interface SupportedAnnotationTypes {
/**
* Returns the names of the supported annotation types.
* @return the names of the supported annotation types
*/
String [] value();
}
@@ -1,54 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
/**
* An annotation used to indicate what options an annotation processor
* supports. The {@link Processor#getSupportedOptions} method can
* construct its result from the value of this annotation, as done by
* {@link AbstractProcessor#getSupportedOptions}. Only {@linkplain
* Processor#getSupportedOptions strings conforming to the
* grammar} should be used as values.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
@Documented
@Target(TYPE)
@Retention(RUNTIME)
public @interface SupportedOptions {
/**
* Returns the supported options.
* @return the supported options
*/
String [] value();
}
@@ -1,55 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
import javax.lang.model.SourceVersion;
/**
* An annotation used to indicate the latest source version an
* annotation processor supports. The {@link
* Processor#getSupportedSourceVersion} method can construct its
* result from the value of this annotation, as done by {@link
* AbstractProcessor#getSupportedSourceVersion}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
@Documented
@Target(TYPE)
@Retention(RUNTIME)
public @interface SupportedSourceVersion {
/**
* Returns the latest supported source version.
* @return the latest supported source version
*/
SourceVersion value();
}
@@ -1,235 +0,0 @@
/*
* Copyright (c) 2013, 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 javax.lang.model;
import java.lang.annotation.*;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Represents a construct that can be annotated.
*
* A construct is either an {@linkplain
* javax.lang.model.element.Element element} or a {@linkplain
* javax.lang.model.type.TypeMirror type}. Annotations on an element
* are on a <em>declaration</em>, whereas annotations on a type are on
* a specific <em>use</em> of a type name.
*
* The terms <em>directly present</em>, <em>present</em>,
* <em>indirectly present</em>, and <em>associated </em> are used
* throughout this interface to describe precisely which annotations
* are returned by the methods defined herein.
*
* <p>In the definitions below, an annotation <i>A</i> has an
* annotation type <i>AT</i>. If <i>AT</i> is a repeatable annotation
* type, the type of the containing annotation is <i>ATC</i>.
*
* <p>Annotation <i>A</i> is <em>directly present</em> on a construct
* <i>C</i> if either:
*
* <ul>
*
* <li><i>A</i> is explicitly or implicitly declared as applying to
* the source code representation of <i>C</i>.
*
* <p>Typically, if exactly one annotation of type <i>AT</i> appears in
* the source code of representation of <i>C</i>, then <i>A</i> is
* explicitly declared as applying to <i>C</i>.
*
* If there are multiple annotations of type <i>AT</i> present on
* <i>C</i>, then if <i>AT</i> is repeatable annotation type, an
* annotation of type <i>ATC</i> is implicitly declared on <i>C</i>.
*
* <li> A representation of <i>A</i> appears in the executable output
* for <i>C</i>, such as the {@code RuntimeVisibleAnnotations} or
* {@code RuntimeVisibleParameterAnnotations} attributes of a class
* file.
*
* </ul>
*
* <p>An annotation <i>A</i> is <em>present</em> on a
* construct <i>C</i> if either:
* <ul>
*
* <li><i>A</i> is directly present on <i>C</i>.
*
* <li>No annotation of type <i>AT</i> is directly present on
* <i>C</i>, and <i>C</i> is a class and <i>AT</i> is inheritable
* and <i>A</i> is present on the superclass of <i>C</i>.
*
* </ul>
*
* An annotation <i>A</i> is <em>indirectly present</em> on a construct
* <i>C</i> if both:
*
* <ul>
*
* <li><i>AT</i> is a repeatable annotation type with a containing
* annotation type <i>ATC</i>.
*
* <li>An annotation of type <i>ATC</i> is directly present on
* <i>C</i> and <i>A</i> is an annotation included in the result of
* calling the {@code value} method of the directly present annotation
* of type <i>ATC</i>.
*
* </ul>
*
* An annotation <i>A</i> is <em>associated</em> with a construct
* <i>C</i> if either:
*
* <ul>
*
* <li> <i>A</i> is directly or indirectly present on <i>C</i>.
*
* <li> No annotation of type <i>AT</i> is directly or indirectly
* present on <i>C</i>, and <i>C</i> is a class, and <i>AT</i> is
* inheritable, and <i>A</i> is associated with the superclass of
* <i>C</i>.
*
* </ul>
*
* @since 1.8
* @jls 9.6 Annotation Types
* @jls 9.6.3.3 @Inherited
*/
public interface AnnotatedConstruct {
/**
* Returns the annotations that are <em>directly present</em> on
* this construct.
*
* @return the annotations <em>directly present</em> on this
* construct; an empty list if there are none
*/
List<? extends AnnotationMirror> getAnnotationMirrors();
/**
* Returns this construct's annotation of the specified type if
* such an annotation is <em>present</em>, else {@code null}.
*
* <p> The annotation returned by this method could contain an element
* whose value is of type {@code Class}.
* This value cannot be returned directly: information necessary to
* locate and load a class (such as the class loader to use) is
* not available, and the class might not be loadable at all.
* Attempting to read a {@code Class} object by invoking the relevant
* method on the returned annotation
* will result in a {@link MirroredTypeException},
* from which the corresponding {@link TypeMirror} may be extracted.
* Similarly, attempting to read a {@code Class[]}-valued element
* will result in a {@link MirroredTypesException}.
*
* <blockquote>
* <i>Note:</i> This method is unlike others in this and related
* interfaces. It operates on runtime reflective information &mdash;
* representations of annotation types currently loaded into the
* VM &mdash; rather than on the representations defined by and used
* throughout these interfaces. Consequently, calling methods on
* the returned annotation object can throw many of the exceptions
* that can be thrown when calling methods on an annotation object
* returned by core reflection. This method is intended for
* callers that are written to operate on a known, fixed set of
* annotation types.
* </blockquote>
*
* @param <A> the annotation type
* @param annotationType the {@code Class} object corresponding to
* the annotation type
* @return this construct's annotation for the specified
* annotation type if present, else {@code null}
*
* @see #getAnnotationMirrors()
* @see java.lang.reflect.AnnotatedElement#getAnnotation
* @see EnumConstantNotPresentException
* @see AnnotationTypeMismatchException
* @see IncompleteAnnotationException
* @see MirroredTypeException
* @see MirroredTypesException
* @jls 9.6.1 Annotation Type Elements
*/
<A extends Annotation> A getAnnotation(Class<A> annotationType);
/**
* Returns annotations that are <em>associated</em> with this construct.
*
* If there are no annotations associated with this construct, the
* return value is an array of length 0.
*
* The order of annotations which are directly or indirectly
* present on a construct <i>C</i> is computed as if indirectly present
* annotations on <i>C</i> are directly present on <i>C</i> in place of their
* container annotation, in the order in which they appear in the
* value element of the container annotation.
*
* The difference between this method and {@link #getAnnotation(Class)}
* is that this method detects if its argument is a <em>repeatable
* annotation type</em>, and if so, attempts to find one or more
* annotations of that type by "looking through" a container annotation.
*
* <p> The annotations returned by this method could contain an element
* whose value is of type {@code Class}.
* This value cannot be returned directly: information necessary to
* locate and load a class (such as the class loader to use) is
* not available, and the class might not be loadable at all.
* Attempting to read a {@code Class} object by invoking the relevant
* method on the returned annotation
* will result in a {@link MirroredTypeException},
* from which the corresponding {@link TypeMirror} may be extracted.
* Similarly, attempting to read a {@code Class[]}-valued element
* will result in a {@link MirroredTypesException}.
*
* <blockquote>
* <i>Note:</i> This method is unlike others in this and related
* interfaces. It operates on runtime reflective information &mdash;
* representations of annotation types currently loaded into the
* VM &mdash; rather than on the representations defined by and used
* throughout these interfaces. Consequently, calling methods on
* the returned annotation object can throw many of the exceptions
* that can be thrown when calling methods on an annotation object
* returned by core reflection. This method is intended for
* callers that are written to operate on a known, fixed set of
* annotation types.
* </blockquote>
*
* @param <A> the annotation type
* @param annotationType the {@code Class} object corresponding to
* the annotation type
* @return this construct's annotations for the specified annotation
* type if present on this construct, else an empty array
*
* @see #getAnnotationMirrors()
* @see #getAnnotation(Class)
* @see java.lang.reflect.AnnotatedElement#getAnnotationsByType(Class)
* @see EnumConstantNotPresentException
* @see AnnotationTypeMismatchException
* @see IncompleteAnnotationException
* @see MirroredTypeException
* @see MirroredTypesException
* @jls 9.6 Annotation Types
* @jls 9.6.1 Annotation Type Elements
*/
<A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);
}
@@ -1,57 +0,0 @@
/*
* Copyright (c) 2009, 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 javax.lang.model;
/**
* Superclass of exceptions which indicate that an unknown kind of
* entity was encountered. This situation can occur if the language
* evolves and new kinds of constructs are introduced. Subclasses of
* this exception may be thrown by visitors to indicate that the
* visitor was created for a prior version of the language.
*
* <p>A common superclass for those exceptions allows a single catch
* block to have code handling them uniformly.
*
* @author Joseph D. Darcy
* @see javax.lang.model.element.UnknownElementException
* @see javax.lang.model.element.UnknownAnnotationValueException
* @see javax.lang.model.type.UnknownTypeException
* @since 1.7
*/
public class UnknownEntityException extends RuntimeException {
private static final long serialVersionUID = 269L;
/**
* Creates a new {@code UnknownEntityException} with the specified
* detail message.
*
* @param message the detail message
*/
protected UnknownEntityException(String message) {
super(message);
}
}
@@ -1,74 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.element;
import java.util.Map;
import javax.lang.model.type.DeclaredType;
/**
* Represents an annotation. An annotation associates a value with
* each element of an annotation type.
*
* <p> Annotations should be compared using the {@code equals}
* method. There is no guarantee that any particular annotation will
* always be represented by the same object.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface AnnotationMirror {
/**
* Returns the type of this annotation.
*
* @return the type of this annotation
*/
DeclaredType getAnnotationType();
/**
* Returns the values of this annotation's elements.
* This is returned in the form of a map that associates elements
* with their corresponding values.
* Only those elements with values explicitly present in the
* annotation are included, not those that are implicitly assuming
* their default values.
* The order of the map matches the order in which the
* values appear in the annotation's source.
*
* <p>Note that an annotation mirror of a marker annotation type
* will by definition have an empty map.
*
* <p>To fill in default values, use {@link
* javax.lang.model.util.Elements#getElementValuesWithDefaults
* getElementValuesWithDefaults}.
*
* @return the values of this annotation's elements,
* or an empty map if there are none
*/
Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues();
}
@@ -1,73 +0,0 @@
/*
* 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 javax.lang.model.element;
/**
* Represents a value of an annotation type element.
* A value is of one of the following types:
* <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
* <li> {@code String}
* <li> {@code TypeMirror}
* <li> {@code VariableElement} (representing an enum constant)
* <li> {@code AnnotationMirror}
* <li> {@code List<? extends AnnotationValue>}
* (representing the elements, in declared order, if the value is an array)
* </ul>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface AnnotationValue {
/**
* Returns the value.
*
* @return the value
*/
Object getValue();
/**
* Returns a string representation of this value.
* This is returned in a form suitable for representing this value
* in the source code of an annotation.
*
* @return a string representation of this value
*/
String toString();
/**
* Applies a visitor to this value.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this value
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(AnnotationValueVisitor<R, P> v, P p);
}
@@ -1,214 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.TypeMirror;
/**
* A visitor of the values of annotation type elements, using a
* variant of the visitor design pattern. Unlike a standard visitor
* which dispatches based on the concrete type of a member of a type
* hierarchy, this visitor dispatches based on the type of data
* stored; there are no distinct subclasses for storing, for example,
* {@code boolean} values versus {@code int} values. Classes
* implementing this interface are used to operate on a value when the
* type of that value is unknown at compile time. When a visitor is
* passed to a value's {@link AnnotationValue#accept accept} method,
* the <tt>visit<i>XYZ</i></tt> method applicable to that value is
* invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java&trade; programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* <p>Note that methods to accommodate new language constructs could
* be added in a source <em>compatible</em> way if they were added as
* <em>default methods</em>. However, default methods are only
* available on Java SE 8 and higher releases and the {@code
* javax.lang.model.*} packages bundled in Java SE 8 are required to
* also be runnable on Java SE 7. Therefore, default methods
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
* to cover Java SE 8 language features. However, default methods may
* be used in subsequent revisions of the {@code javax.lang.model.*}
* packages that are only required to run on Java SE 8 and higher
* platform versions.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface AnnotationValueVisitor<R, P> {
/**
* Visits an annotation value.
* @param av the value to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(AnnotationValue av, P p);
/**
* A convenience method equivalent to {@code v.visit(av, null)}.
* @param av the value to visit
* @return a visitor-specified result
*/
R visit(AnnotationValue av);
/**
* Visits a {@code boolean} value in an annotation.
* @param b the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitBoolean(boolean b, P p);
/**
* Visits a {@code byte} value in an annotation.
* @param b the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitByte(byte b, P p);
/**
* Visits a {@code char} value in an annotation.
* @param c the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitChar(char c, P p);
/**
* Visits a {@code double} value in an annotation.
* @param d the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitDouble(double d, P p);
/**
* Visits a {@code float} value in an annotation.
* @param f the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitFloat(float f, P p);
/**
* Visits an {@code int} value in an annotation.
* @param i the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitInt(int i, P p);
/**
* Visits a {@code long} value in an annotation.
* @param i the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitLong(long i, P p);
/**
* Visits a {@code short} value in an annotation.
* @param s the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitShort(short s, P p);
/**
* Visits a string value in an annotation.
* @param s the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitString(String s, P p);
/**
* Visits a type value in an annotation.
* @param t the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitType(TypeMirror t, P p);
/**
* Visits an {@code enum} value in an annotation.
* @param c the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitEnumConstant(VariableElement c, P p);
/**
* Visits an annotation value in an annotation.
* @param a the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitAnnotation(AnnotationMirror a, P p);
/**
* Visits an array value in an annotation.
* @param vals the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitArray(List<? extends AnnotationValue> vals, P p);
/**
* Visits an unknown kind of annotation value.
* This can occur if the language evolves and new kinds
* of value can be stored in an annotation.
* @param av the unknown value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
* @throws UnknownAnnotationValueException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(AnnotationValue av, P p);
}
@@ -1,246 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.util.List;
import java.util.Set;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
/**
* Represents a program element such as a package, class, or method.
* Each element represents a static, language-level construct
* (and not, for example, a runtime construct of the virtual machine).
*
* <p> Elements should be compared using the {@link #equals(Object)}
* method. There is no guarantee that any particular element will
* always be represented by the same object.
*
* <p> To implement operations based on the class of an {@code
* Element} object, either use a {@linkplain ElementVisitor visitor} or
* use the result of the {@link #getKind} method. Using {@code
* instanceof} is <em>not</em> necessarily a reliable idiom for
* determining the effective class of an object in this modeling
* hierarchy since an implementation may choose to have a single object
* implement multiple {@code Element} subinterfaces.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see Elements
* @see TypeMirror
* @since 1.6
*/
public interface Element extends javax.lang.model.AnnotatedConstruct {
/**
* Returns the type defined by this element.
*
* <p> A generic element defines a family of types, not just one.
* If this is a generic element, a <i>prototypical</i> type is
* returned. This is the element's invocation on the
* type variables corresponding to its own formal type parameters.
* For example,
* for the generic class element {@code C<N extends Number>},
* the parameterized type {@code C<N>} is returned.
* The {@link Types} utility interface has more general methods
* for obtaining the full range of types defined by an element.
*
* @see Types
*
* @return the type defined by this element
*/
TypeMirror asType();
/**
* Returns the {@code kind} of this element.
*
* @return the kind of this element
*/
ElementKind getKind();
/**
* Returns the modifiers of this element, excluding annotations.
* Implicit modifiers, such as the {@code public} and {@code static}
* modifiers of interface members, are included.
*
* @return the modifiers of this element, or an empty set if there are none
*/
Set<Modifier> getModifiers();
/**
* Returns the simple (unqualified) name of this element. The
* name of a generic type does not include any reference to its
* formal type parameters.
*
* For example, the simple name of the type element {@code
* java.util.Set<E>} is {@code "Set"}.
*
* If this element represents an unnamed {@linkplain
* PackageElement#getSimpleName package}, an empty name is
* returned.
*
* If it represents a {@linkplain ExecutableElement#getSimpleName
* constructor}, the name "{@code <init>}" is returned. If it
* represents a {@linkplain ExecutableElement#getSimpleName static
* initializer}, the name "{@code <clinit>}" is returned.
*
* If it represents an {@linkplain TypeElement#getSimpleName
* anonymous class} or {@linkplain ExecutableElement#getSimpleName
* instance initializer}, an empty name is returned.
*
* @return the simple name of this element
* @see PackageElement#getSimpleName
* @see ExecutableElement#getSimpleName
* @see TypeElement#getSimpleName
* @see VariableElement#getSimpleName
*/
Name getSimpleName();
/**
* Returns the innermost element
* within which this element is, loosely speaking, enclosed.
* <ul>
* <li> If this element is one whose declaration is lexically enclosed
* immediately within the declaration of another element, that other
* element is returned.
*
* <li> If this is a {@linkplain TypeElement#getEnclosingElement
* top-level type}, its package is returned.
*
* <li> If this is a {@linkplain
* PackageElement#getEnclosingElement package}, {@code null} is
* returned.
*
* <li> If this is a {@linkplain
* TypeParameterElement#getEnclosingElement type parameter},
* {@linkplain TypeParameterElement#getGenericElement the
* generic element} of the type parameter is returned.
*
* <li> If this is a {@linkplain
* VariableElement#getEnclosingElement method or constructor
* parameter}, {@linkplain ExecutableElement the executable
* element} which declares the parameter is returned.
*
* </ul>
*
* @return the enclosing element, or {@code null} if there is none
* @see Elements#getPackageOf
*/
Element getEnclosingElement();
/**
* Returns the elements that are, loosely speaking, directly
* enclosed by this element.
*
* A {@linkplain TypeElement#getEnclosedElements class or
* interface} is considered to enclose the fields, methods,
* constructors, and member types that it directly declares.
*
* A {@linkplain PackageElement#getEnclosedElements package}
* encloses the top-level classes and interfaces within it, but is
* not considered to enclose subpackages.
*
* Other kinds of elements are not currently considered to enclose
* any elements; however, that may change as this API or the
* programming language evolves.
*
* <p>Note that elements of certain kinds can be isolated using
* methods in {@link ElementFilter}.
*
* @return the enclosed elements, or an empty list if none
* @see PackageElement#getEnclosedElements
* @see TypeElement#getEnclosedElements
* @see Elements#getAllMembers
* @jls 8.8.9 Default Constructor
* @jls 8.9 Enums
*/
List<? extends Element> getEnclosedElements();
/**
* Returns {@code true} if the argument represents the same
* element as {@code this}, or {@code false} otherwise.
*
* <p>Note that the identity of an element involves implicit state
* not directly accessible from the element's methods, including
* state about the presence of unrelated types. Element objects
* created by different implementations of these interfaces should
* <i>not</i> be expected to be equal even if &quot;the same&quot;
* element is being modeled; this is analogous to the inequality
* of {@code Class} objects for the same class file loaded through
* different class loaders.
*
* @param obj the object to be compared with this element
* @return {@code true} if the specified object represents the same
* element as this
*/
@Override
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
@Override
int hashCode();
/**
* {@inheritDoc}
*
* <p> To get inherited annotations as well, use {@link
* Elements#getAllAnnotationMirrors(Element)
* getAllAnnotationMirrors}.
*
* @since 1.6
*/
@Override
List<? extends AnnotationMirror> getAnnotationMirrors();
/**
* {@inheritDoc}
* @since 1.6
*/
@Override
<A extends Annotation> A getAnnotation(Class<A> annotationType);
/**
* Applies a visitor to this element.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this element
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(ElementVisitor<R, P> v, P p);
}
@@ -1,129 +0,0 @@
/*
* Copyright (c) 2005, 2010, 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 javax.lang.model.element;
/**
* The {@code kind} of an element.
*
* <p>Note that it is possible additional element kinds will be added
* to accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see Element
* @since 1.6
*/
public enum ElementKind {
/** A package. */
PACKAGE,
// Declared types
/** An enum type. */
ENUM,
/** A class not described by a more specific kind (like {@code ENUM}). */
CLASS,
/** An annotation type. */
ANNOTATION_TYPE,
/**
* An interface not described by a more specific kind (like
* {@code ANNOTATION_TYPE}).
*/
INTERFACE,
// Variables
/** An enum constant. */
ENUM_CONSTANT,
/**
* A field not described by a more specific kind (like
* {@code ENUM_CONSTANT}).
*/
FIELD,
/** A parameter of a method or constructor. */
PARAMETER,
/** A local variable. */
LOCAL_VARIABLE,
/** A parameter of an exception handler. */
EXCEPTION_PARAMETER,
// Executables
/** A method. */
METHOD,
/** A constructor. */
CONSTRUCTOR,
/** A static initializer. */
STATIC_INIT,
/** An instance initializer. */
INSTANCE_INIT,
/** A type parameter. */
TYPE_PARAMETER,
/**
* An implementation-reserved element. This is not the element
* you are looking for.
*/
OTHER,
/**
* A resource variable.
* @since 1.7
*/
RESOURCE_VARIABLE;
/**
* Returns {@code true} if this is a kind of class:
* either {@code CLASS} or {@code ENUM}.
*
* @return {@code true} if this is a kind of class
*/
public boolean isClass() {
return this == CLASS || this == ENUM;
}
/**
* Returns {@code true} if this is a kind of interface:
* either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
*
* @return {@code true} if this is a kind of interface
*/
public boolean isInterface() {
return this == INTERFACE || this == ANNOTATION_TYPE;
}
/**
* Returns {@code true} if this is a kind of field:
* either {@code FIELD} or {@code ENUM_CONSTANT}.
*
* @return {@code true} if this is a kind of field
*/
public boolean isField() {
return this == FIELD || this == ENUM_CONSTANT;
}
}
@@ -1,148 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
import javax.lang.model.util.*;
/**
* A visitor of program elements, in the style of the visitor design
* pattern. Classes implementing this interface are used to operate
* on an element when the kind of element is unknown at compile time.
* When a visitor is passed to an element's {@link Element#accept
* accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
* to that element is invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java&trade; programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* <p>Note that methods to accommodate new language constructs could
* be added in a source <em>compatible</em> way if they were added as
* <em>default methods</em>. However, default methods are only
* available on Java SE 8 and higher releases and the {@code
* javax.lang.model.*} packages bundled in Java SE 8 are required to
* also be runnable on Java SE 7. Therefore, default methods
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
* to cover Java SE 8 language features. However, default methods may
* be used in subsequent revisions of the {@code javax.lang.model.*}
* packages that are only required to run on Java SE 8 and higher
* platform versions.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see AbstractElementVisitor6
* @see AbstractElementVisitor7
* @since 1.6
*/
public interface ElementVisitor<R, P> {
/**
* Visits an element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(Element e, P p);
/**
* A convenience method equivalent to {@code v.visit(e, null)}.
* @param e the element to visit
* @return a visitor-specified result
*/
R visit(Element e);
/**
* Visits a package element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitPackage(PackageElement e, P p);
/**
* Visits a type element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitType(TypeElement e, P p);
/**
* Visits a variable element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitVariable(VariableElement e, P p);
/**
* Visits an executable element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitExecutable(ExecutableElement e, P p);
/**
* Visits a type parameter element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitTypeParameter(TypeParameterElement e, P p);
/**
* Visits an unknown kind of element.
* This can occur if the language evolves and new kinds
* of elements are added to the {@code Element} hierarchy.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownElementException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(Element e, P p);
}
@@ -1,141 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.*;
/**
* Represents a method, constructor, or initializer (static or
* instance) of a class or interface, including annotation type
* elements.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see ExecutableType
* @since 1.6
*/
public interface ExecutableElement extends Element, Parameterizable {
/**
* Returns the formal type parameters of this executable
* in declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
/**
* Returns the return type of this executable.
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
* if this executable is not a method, or is a method that does not
* return a value.
*
* @return the return type of this executable
*/
TypeMirror getReturnType();
/**
* Returns the formal parameters of this executable.
* They are returned in declaration order.
*
* @return the formal parameters,
* or an empty list if there are none
*/
List<? extends VariableElement> getParameters();
/**
* Returns the receiver type of this executable,
* or {@link javax.lang.model.type.NoType NoType} with
* kind {@link javax.lang.model.type.TypeKind#NONE NONE}
* if the executable has no receiver type.
*
* An executable which is an instance method, or a constructor of an
* inner class, has a receiver type derived from the {@linkplain
* #getEnclosingElement declaring type}.
*
* An executable which is a static method, or a constructor of a
* non-inner class, or an initializer (static or instance), has no
* receiver type.
*
* @return the receiver type of this executable
* @since 1.8
*/
TypeMirror getReceiverType();
/**
* Returns {@code true} if this method or constructor accepts a variable
* number of arguments and returns {@code false} otherwise.
*
* @return {@code true} if this method or constructor accepts a variable
* number of arguments and {@code false} otherwise
*/
boolean isVarArgs();
/**
* Returns {@code true} if this method is a default method and
* returns {@code false} otherwise.
*
* @return {@code true} if this method is a default method and
* {@code false} otherwise
* @since 1.8
*/
boolean isDefault();
/**
* Returns the exceptions and other throwables listed in this
* method or constructor's {@code throws} clause in declaration
* order.
*
* @return the exceptions and other throwables listed in the
* {@code throws} clause, or an empty list if there are none
*/
List<? extends TypeMirror> getThrownTypes();
/**
* Returns the default value if this executable is an annotation
* type element. Returns {@code null} if this method is not an
* annotation type element, or if it is an annotation type element
* with no default value.
*
* @return the default value, or {@code null} if none
*/
AnnotationValue getDefaultValue();
/**
* Returns the simple name of a constructor, method, or
* initializer. For a constructor, the name {@code "<init>"} is
* returned, for a static initializer, the name {@code "<clinit>"}
* is returned, and for an anonymous class or instance
* initializer, an empty name is returned.
*
* @return the simple name of a constructor, method, or
* initializer
*/
@Override
Name getSimpleName();
}
@@ -1,75 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
/**
* Represents a modifier on a program element such
* as a class, method, or field.
*
* <p>Not all modifiers are applicable to all kinds of elements.
* When two or more modifiers appear in the source code of an element
* then it is customary, though not required, that they appear in the same
* order as the constants listed in the detail section below.
*
* <p>Note that it is possible additional modifiers will be added in
* future versions of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public enum Modifier {
// See JLS sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
// java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
/** The modifier {@code public} */ PUBLIC,
/** The modifier {@code protected} */ PROTECTED,
/** The modifier {@code private} */ PRIVATE,
/** The modifier {@code abstract} */ ABSTRACT,
/**
* The modifier {@code default}
* @since 1.8
*/
DEFAULT,
/** The modifier {@code static} */ STATIC,
/** The modifier {@code final} */ FINAL,
/** The modifier {@code transient} */ TRANSIENT,
/** The modifier {@code volatile} */ VOLATILE,
/** The modifier {@code synchronized} */ SYNCHRONIZED,
/** The modifier {@code native} */ NATIVE,
/** The modifier {@code strictfp} */ STRICTFP;
/**
* Returns this modifier's name in lowercase.
*/
public String toString() {
return name().toLowerCase(java.util.Locale.US);
}
}
@@ -1,89 +0,0 @@
/*
* Copyright (c) 2006, 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 javax.lang.model.element;
/**
* An immutable sequence of characters. When created by the same
* implementation, objects implementing this interface must obey the
* general {@linkplain Object#equals equals contract} when compared
* with each other. Therefore, {@code Name} objects from the same
* implementation are usable in collections while {@code Name}s from
* different implementations may not work properly in collections.
*
* <p>An empty {@code Name} has a length of zero.
*
* <p>In the context of {@linkplain
* javax.annotation.processing.ProcessingEnvironment annotation
* processing}, the guarantees for "the same" implementation must
* include contexts where the {@linkplain javax.annotation.processing
* API mediated} side effects of {@linkplain
* javax.annotation.processing.Processor processors} could be visible
* to each other, including successive annotation processing
* {@linkplain javax.annotation.processing.RoundEnvironment rounds}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see javax.lang.model.util.Elements#getName
* @since 1.6
*/
public interface Name extends CharSequence {
/**
* Returns {@code true} if the argument represents the same
* name as {@code this}, and {@code false} otherwise.
*
* <p>Note that the identity of a {@code Name} is a function both
* of its content in terms of a sequence of characters as well as
* the implementation which created it.
*
* @param obj the object to be compared with this element
* @return {@code true} if the specified object represents the same
* name as this
* @see Element#equals
*/
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
int hashCode();
/**
* Compares this name to the specified {@code CharSequence}. The result
* is {@code true} if and only if this name represents the same sequence
* of {@code char} values as the specified sequence.
*
* @return {@code true} if this name represents the same sequence
* of {@code char} values as the specified sequence, {@code false}
* otherwise
*
* @param cs The sequence to compare this name against
* @see String#contentEquals(CharSequence)
*/
boolean contentEquals(CharSequence cs);
}
@@ -1,115 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
/**
* The <i>nesting kind</i> of a type element.
* Type elements come in four varieties:
* top-level, member, local, and anonymous.
* <i>Nesting kind</i> is a non-standard term used here to denote this
* classification.
*
* <p>Note that it is possible additional nesting kinds will be added
* in future versions of the platform.
*
* <p><b>Example:</b> The classes below are annotated with their nesting kind.
* <blockquote><pre>
*
* import java.lang.annotation.*;
* import static java.lang.annotation.RetentionPolicy.*;
* import javax.lang.model.element.*;
* import static javax.lang.model.element.NestingKind.*;
*
* &#64;Nesting(TOP_LEVEL)
* public class NestingExamples {
* &#64;Nesting(MEMBER)
* static class MemberClass1{}
*
* &#64;Nesting(MEMBER)
* class MemberClass2{}
*
* public static void main(String... argv) {
* &#64;Nesting(LOCAL)
* class LocalClass{};
*
* Class&lt;?&gt;[] classes = {
* NestingExamples.class,
* MemberClass1.class,
* MemberClass2.class,
* LocalClass.class
* };
*
* for(Class&lt;?&gt; clazz : classes) {
* System.out.format("%s is %s%n",
* clazz.getName(),
* clazz.getAnnotation(Nesting.class).value());
* }
* }
* }
*
* &#64;Retention(RUNTIME)
* &#64;interface Nesting {
* NestingKind value();
* }
* </pre></blockquote>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public enum NestingKind {
/**
* A top-level type, not contained within another type.
*/
TOP_LEVEL,
/**
* A type that is a named member of another type.
*/
MEMBER,
/**
* A named type declared within a construct other than a type.
*/
LOCAL,
/**
* A type without a name.
*/
ANONYMOUS;
/**
* Does this constant correspond to a nested type element?
* A <i>nested</i> type element is any that is not top-level.
* An <i>inner</i> type element is any nested type element that
* is not {@linkplain Modifier#STATIC static}.
* @return whether or not the constant is nested
*/
public boolean isNested() {
return this != TOP_LEVEL;
}
}
@@ -1,92 +0,0 @@
/*
* 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 javax.lang.model.element;
import java.util.List;
/**
* Represents a package program element. Provides access to information
* about the package and its members.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see javax.lang.model.util.Elements#getPackageOf
* @since 1.6
*/
public interface PackageElement extends Element, QualifiedNameable {
/**
* Returns the fully qualified name of this package.
* This is also known as the package's <i>canonical</i> name.
*
* @return the fully qualified name of this package, or an
* empty name if this is an unnamed package
* @jls 6.7 Fully Qualified Names and Canonical Names
*/
Name getQualifiedName();
/**
* Returns the simple name of this package. For an unnamed
* package, an empty name is returned.
*
* @return the simple name of this package or an empty name if
* this is an unnamed package
*/
@Override
Name getSimpleName();
/**
* Returns the {@linkplain NestingKind#TOP_LEVEL top-level}
* classes and interfaces within this package. Note that
* subpackages are <em>not</em> considered to be enclosed by a
* package.
*
* @return the top-level classes and interfaces within this
* package
*/
@Override
List<? extends Element> getEnclosedElements();
/**
* Returns {@code true} is this is an unnamed package and {@code
* false} otherwise.
*
* @return {@code true} is this is an unnamed package and {@code
* false} otherwise
* @jls 7.4.2 Unnamed Packages
*/
boolean isUnnamed();
/**
* Returns {@code null} since a package is not enclosed by another
* element.
*
* @return {@code null}
*/
@Override
Element getEnclosingElement();
}
@@ -1,45 +0,0 @@
/*
* Copyright (c) 2009, 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 javax.lang.model.element;
import java.util.List;
/**
* A mixin interface for an element that has type parameters.
*
* @author Joseph D. Darcy
* @since 1.7
*/
public interface Parameterizable extends Element {
/**
* Returns the formal type parameters of the type element in
* declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
}
@@ -1,41 +0,0 @@
/*
* Copyright (c) 2009, 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 javax.lang.model.element;
/**
* A mixin interface for an element that has a qualified name.
*
* @author Joseph D. Darcy
* @since 1.7
*/
public interface QualifiedNameable extends Element {
/**
* Returns the fully qualified name of an element.
*
* @return the fully qualified name of an element
*/
Name getQualifiedName();
}
@@ -1,164 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
/**
* Represents a class or interface program element. Provides access
* to information about the type and its members. Note that an enum
* type is a kind of class and an annotation type is a kind of
* interface.
*
* <p> <a name="ELEM_VS_TYPE"></a>
* While a {@code TypeElement} represents a class or interface
* <i>element</i>, a {@link DeclaredType} represents a class
* or interface <i>type</i>, the latter being a use
* (or <i>invocation</i>) of the former.
* The distinction is most apparent with generic types,
* for which a single element can define a whole
* family of types. For example, the element
* {@code java.util.Set} corresponds to the parameterized types
* {@code java.util.Set<String>} and {@code java.util.Set<Number>}
* (and many others), and to the raw type {@code java.util.Set}.
*
* <p> Each method of this interface that returns a list of elements
* will return them in the order that is natural for the underlying
* source of program information. For example, if the underlying
* source of information is Java source code, then the elements will be
* returned in source code order.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see DeclaredType
* @since 1.6
*/
public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
/**
* Returns the fields, methods, constructors, and member types
* that are directly declared in this class or interface.
*
* This includes any (implicit) default constructor and
* the implicit {@code values} and {@code valueOf} methods of an
* enum type.
*
* <p> Note that as a particular instance of the {@linkplain
* javax.lang.model.element general accuracy requirements} and the
* ordering behavior required of this interface, the list of
* enclosed elements will be returned in the natural order for the
* originating source of information about the type. For example,
* if the information about the type is originating from a source
* file, the elements will be returned in source code order.
* (However, in that case the the ordering of synthesized
* elements, such as a default constructor, is not specified.)
*
* @return the enclosed elements in proper order, or an empty list if none
*/
@Override
List<? extends Element> getEnclosedElements();
/**
* Returns the <i>nesting kind</i> of this type element.
*
* @return the nesting kind of this type element
*/
NestingKind getNestingKind();
/**
* Returns the fully qualified name of this type element.
* More precisely, it returns the <i>canonical</i> name.
* For local and anonymous classes, which do not have canonical names,
* an empty name is returned.
*
* <p>The name of a generic type does not include any reference
* to its formal type parameters.
* For example, the fully qualified name of the interface
* {@code java.util.Set<E>} is "{@code java.util.Set}".
* Nested types use "{@code .}" as a separator, as in
* "{@code java.util.Map.Entry}".
*
* @return the fully qualified name of this class or interface, or
* an empty name if none
*
* @see Elements#getBinaryName
* @jls 6.7 Fully Qualified Names and Canonical Names
*/
Name getQualifiedName();
/**
* Returns the simple name of this type element.
*
* For an anonymous class, an empty name is returned.
*
* @return the simple name of this class or interface,
* an empty name for an anonymous class
*
*/
@Override
Name getSimpleName();
/**
* Returns the direct superclass of this type element.
* If this type element represents an interface or the class
* {@code java.lang.Object}, then a {@link NoType}
* with kind {@link TypeKind#NONE NONE} is returned.
*
* @return the direct superclass, or a {@code NoType} if there is none
*/
TypeMirror getSuperclass();
/**
* Returns the interface types directly implemented by this class
* or extended by this interface.
*
* @return the interface types directly implemented by this class
* or extended by this interface, or an empty list if there are none
*/
List<? extends TypeMirror> getInterfaces();
/**
* Returns the formal type parameters of this type element
* in declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
/**
* Returns the package of a top-level type and returns the
* immediately lexically enclosing element for a {@linkplain
* NestingKind#isNested nested} type.
*
* @return the package of a top-level type, the immediately
* lexically enclosing element for a nested type
*/
@Override
Element getEnclosingElement();
}
@@ -1,73 +0,0 @@
/*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
/**
* Represents a formal type parameter of a generic class, interface, method,
* or constructor element.
* A type parameter declares a {@link TypeVariable}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see TypeVariable
* @since 1.6
*/
public interface TypeParameterElement extends Element {
/**
* Returns the generic class, interface, method, or constructor that is
* parameterized by this type parameter.
*
* @return the generic class, interface, method, or constructor that is
* parameterized by this type parameter
*/
Element getGenericElement();
/**
* Returns the bounds of this type parameter.
* These are the types given by the {@code extends} clause
* used to declare this type parameter.
* If no explicit {@code extends} clause was used,
* then {@code java.lang.Object} is considered to be the sole bound.
*
* @return the bounds of this type parameter, or an empty list if
* there are none
*/
List<? extends TypeMirror> getBounds();
/**
* Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter.
*
* @return the generic element of this type parameter
*/
@Override
Element getEnclosingElement();
}
@@ -1,87 +0,0 @@
/*
* Copyright (c) 2005, 2009, 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 javax.lang.model.element;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of annotation value was encountered.
* This can occur if the language evolves and new kinds of annotation
* values can be stored in an annotation. May be thrown by an
* {@linkplain AnnotationValueVisitor annotation value visitor} to
* indicate that the visitor was created for a prior version of the
* language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see AnnotationValueVisitor#visitUnknown
* @since 1.6
*/
public class UnknownAnnotationValueException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient AnnotationValue av;
private transient Object parameter;
/**
* Creates a new {@code UnknownAnnotationValueException}. The
* {@code p} parameter may be used to pass in an additional
* argument with information about the context in which the
* unknown annotation value was encountered; for example, the
* visit methods of {@link AnnotationValueVisitor} may pass in
* their additional parameter.
*
* @param av the unknown annotation value, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownAnnotationValueException(AnnotationValue av, Object p) {
super("Unknown annotation value: " + av);
this.av = av;
this.parameter = p;
}
/**
* Returns the unknown annotation value.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown element, or {@code null} if unavailable
*/
public AnnotationValue getUnknownAnnotationValue() {
return av;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}
@@ -1,85 +0,0 @@
/*
* Copyright (c) 2005, 2009, 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 javax.lang.model.element;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of element was encountered. This
* can occur if the language evolves and new kinds of elements are
* added to the {@code Element} hierarchy. May be thrown by an
* {@linkplain ElementVisitor element visitor} to indicate that the
* visitor was created for a prior version of the language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see ElementVisitor#visitUnknown
* @since 1.6
*/
public class UnknownElementException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient Element element;
private transient Object parameter;
/**
* Creates a new {@code UnknownElementException}. The {@code p}
* parameter may be used to pass in an additional argument with
* information about the context in which the unknown element was
* encountered; for example, the visit methods of {@link
* ElementVisitor} may pass in their additional parameter.
*
* @param e the unknown element, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownElementException(Element e, Object p) {
super("Unknown element: " + e);
element = e;
this.parameter = p;
}
/**
* Returns the unknown element.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown element, or {@code null} if unavailable
*/
public Element getUnknownElement() {
return element;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}
@@ -1,90 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.element;
import javax.lang.model.util.Elements;
/**
* Represents a field, {@code enum} constant, method or constructor
* parameter, local variable, resource variable, or exception
* parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface VariableElement extends Element {
/**
* Returns the value of this variable if this is a {@code final}
* field initialized to a compile-time constant. Returns {@code
* null} otherwise. The value will be of a primitive type or a
* {@code String}. If the value is of a primitive type, it is
* wrapped in the appropriate wrapper class (such as {@link
* Integer}).
*
* <p>Note that not all {@code final} fields will have
* constant values. In particular, {@code enum} constants are
* <em>not</em> considered to be compile-time constants. To have a
* constant value, a field's type must be either a primitive type
* or {@code String}.
*
* @return the value of this variable if this is a {@code final}
* field initialized to a compile-time constant, or {@code null}
* otherwise
*
* @see Elements#getConstantExpression(Object)
* @jls 15.28 Constant Expression
* @jls 4.12.4 final Variables
*/
Object getConstantValue();
/**
* Returns the simple name of this variable element.
*
* <p>For method and constructor parameters, the name of each
* parameter must be distinct from the names of all other
* parameters of the same executable. If the original source
* names are not available, an implementation may synthesize names
* subject to the distinctness requirement above.
*
* @return the simple name of this variable element
*/
@Override
Name getSimpleName();
/**
* Returns the enclosing element of this variable.
*
* The enclosing element of a method or constructor parameter is
* the executable declaring the parameter.
*
* @return the enclosing element of this variable
*/
@Override
Element getEnclosingElement();
}
@@ -1,47 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents an array type.
* A multidimensional array type is represented as an array type
* whose component type is also an array type.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface ArrayType extends ReferenceType {
/**
* Returns the component type of this array type.
*
* @return the component type of this array type
*/
TypeMirror getComponentType();
}
@@ -1,89 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.type;
import java.util.List;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Types;
/**
* Represents a declared type, either a class type or an interface type.
* This includes parameterized types such as {@code java.util.Set<String>}
* as well as raw types.
*
* <p> While a {@code TypeElement} represents a class or interface
* <i>element</i>, a {@code DeclaredType} represents a class
* or interface <i>type</i>, the latter being a use
* (or <i>invocation</i>) of the former.
* See {@link TypeElement} for more on this distinction.
*
* <p> The supertypes (both class and interface types) of a declared
* type may be found using the {@link
* Types#directSupertypes(TypeMirror)} method. This returns the
* supertypes with any type arguments substituted in.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see TypeElement
* @since 1.6
*/
public interface DeclaredType extends ReferenceType {
/**
* Returns the element corresponding to this type.
*
* @return the element corresponding to this type
*/
Element asElement();
/**
* Returns the type of the innermost enclosing instance or a
* {@code NoType} of kind {@code NONE} if there is no enclosing
* instance. Only types corresponding to inner classes have an
* enclosing instance.
*
* @return a type mirror for the enclosing type
* @jls 8.1.3 Inner Classes and Enclosing Instances
* @jls 15.9.2 Determining Enclosing Instances
*/
TypeMirror getEnclosingType();
/**
* Returns the actual type arguments of this type.
* For a type nested within a parameterized type
* (such as {@code Outer<String>.Inner<Number>}), only the type
* arguments of the innermost type are included.
*
* @return the actual type arguments of this type, or an empty list
* if none
*/
List<? extends TypeMirror> getTypeArguments();
}
@@ -1,42 +0,0 @@
/*
* Copyright (c) 2005, 2008, 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 javax.lang.model.type;
/**
* Represents a class or interface type that cannot be properly modeled.
* This may be the result of a processing error,
* such as a missing class file or erroneous source code.
* Most queries for
* information derived from such a type (such as its members or its
* supertype) will not, in general, return meaningful results.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface ErrorType extends DeclaredType {
}
@@ -1,107 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.type;
import java.util.List;
import javax.lang.model.element.ExecutableElement;
/**
* Represents the type of an executable. An <i>executable</i>
* is a method, constructor, or initializer.
*
* <p> The executable is
* represented as when viewed as a method (or constructor or
* initializer) of some reference type.
* If that reference type is parameterized, then its actual
* type arguments are substituted into any types returned by the methods of
* this interface.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see ExecutableElement
* @since 1.6
*/
public interface ExecutableType extends TypeMirror {
/**
* Returns the type variables declared by the formal type parameters
* of this executable.
*
* @return the type variables declared by the formal type parameters,
* or an empty list if there are none
*/
List<? extends TypeVariable> getTypeVariables();
/**
* Returns the return type of this executable.
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
* if this executable is not a method, or is a method that does not
* return a value.
*
* @return the return type of this executable
*/
TypeMirror getReturnType();
/**
* Returns the types of this executable's formal parameters.
*
* @return the types of this executable's formal parameters,
* or an empty list if there are none
*/
List<? extends TypeMirror> getParameterTypes();
/**
* Returns the receiver type of this executable,
* or {@link javax.lang.model.type.NoType NoType} with
* kind {@link javax.lang.model.type.TypeKind#NONE NONE}
* if the executable has no receiver type.
*
* An executable which is an instance method, or a constructor of an
* inner class, has a receiver type derived from the {@linkplain
* ExecutableElement#getEnclosingElement declaring type}.
*
* An executable which is a static method, or a constructor of a
* non-inner class, or an initializer (static or instance), has no
* receiver type.
*
* @return the receiver type of this executable
* @since 1.8
*/
TypeMirror getReceiverType();
/**
* Returns the exceptions and other throwables listed in this
* executable's {@code throws} clause.
*
* @return the exceptions and other throwables listed in this
* executable's {@code throws} clause,
* or an empty list if there are none.
*/
List<? extends TypeMirror> getThrownTypes();
}
@@ -1,55 +0,0 @@
/*
* Copyright (c) 2012, 2013, 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 javax.lang.model.type;
import java.util.List;
/**
* Represents an intersection type.
*
* <p>An intersection type can be either implicitly or explicitly
* declared in a program. For example, the bound of the type parameter
* {@code <T extends Number & Runnable>} is an (implicit) intersection
* type. As of {@link javax.lang.model.SourceVersion#RELEASE_8
* RELEASE_8}, this is represented by an {@code IntersectionType} with
* {@code Number} and {@code Runnable} as its bounds.
*
* @implNote Also as of {@link
* javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8}, in the
* reference implementation an {@code IntersectionType} is used to
* model the explicit target type of a cast expression.
*
* @since 1.8
*/
public interface IntersectionType extends TypeMirror {
/**
* Return the bounds comprising this intersection type.
*
* @return the bounds of this intersection types.
*/
List<? extends TypeMirror> getBounds();
}
@@ -1,80 +0,0 @@
/*
* 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 javax.lang.model.type;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.lang.model.element.Element;
/**
* Thrown when an application attempts to access the {@link Class} object
* corresponding to a {@link TypeMirror}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see MirroredTypesException
* @see Element#getAnnotation(Class)
* @since 1.6
*/
public class MirroredTypeException extends MirroredTypesException {
private static final long serialVersionUID = 269;
private transient TypeMirror type; // cannot be serialized
/**
* Constructs a new MirroredTypeException for the specified type.
*
* @param type the type being accessed
*/
public MirroredTypeException(TypeMirror type) {
super("Attempt to access Class object for TypeMirror " + type.toString(), type);
this.type = type;
}
/**
* Returns the type mirror corresponding to the type being accessed.
* The type mirror may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the type mirror, or {@code null} if unavailable
*/
public TypeMirror getTypeMirror() {
return type;
}
/**
* Explicitly set all transient fields.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
type = null;
types = null;
}
}
@@ -1,94 +0,0 @@
/*
* 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 javax.lang.model.type;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.lang.model.element.Element;
/**
* Thrown when an application attempts to access a sequence of {@link
* Class} objects each corresponding to a {@link TypeMirror}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see MirroredTypeException
* @see Element#getAnnotation(Class)
* @since 1.6
*/
public class MirroredTypesException extends RuntimeException {
private static final long serialVersionUID = 269;
transient List<? extends TypeMirror> types; // cannot be serialized
/*
* Trusted constructor to be called by MirroredTypeException.
*/
MirroredTypesException(String message, TypeMirror type) {
super(message);
List<TypeMirror> tmp = (new ArrayList<TypeMirror>());
tmp.add(type);
types = Collections.unmodifiableList(tmp);
}
/**
* Constructs a new MirroredTypesException for the specified types.
*
* @param types the types being accessed
*/
public MirroredTypesException(List<? extends TypeMirror> types) {
super("Attempt to access Class objects for TypeMirrors " +
(types = // defensive copy
new ArrayList<TypeMirror>(types)).toString() );
this.types = Collections.unmodifiableList(types);
}
/**
* Returns the type mirrors corresponding to the types being accessed.
* The type mirrors may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the type mirrors in construction order, or {@code null} if unavailable
*/
public List<? extends TypeMirror> getTypeMirrors() {
return types;
}
/**
* Explicitly set all transient fields.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
types = null;
}
}
@@ -1,50 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
import javax.lang.model.element.ExecutableElement;
/**
* A pseudo-type used where no actual type is appropriate.
* The kinds of {@code NoType} are:
* <ul>
* <li>{@link TypeKind#VOID VOID} - corresponds to the keyword {@code void}.
* <li>{@link TypeKind#PACKAGE PACKAGE} - the pseudo-type of a package element.
* <li>{@link TypeKind#NONE NONE} - used in other cases
* where no actual type is appropriate; for example, the superclass
* of {@code java.lang.Object}.
* </ul>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see ExecutableElement#getReturnType()
* @since 1.6
*/
public interface NoType extends TypeMirror {
}
@@ -1,40 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents the null type.
* This is the type of the expression {@code null},
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface NullType extends ReferenceType {
}
@@ -1,40 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents a primitive type. These include
* {@code boolean}, {@code byte}, {@code short}, {@code int},
* {@code long}, {@code char}, {@code float}, and {@code double}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface PrimitiveType extends TypeMirror {
}
@@ -1,40 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents a reference type.
* These include class and interface types, array types, type variables,
* and the null type.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface ReferenceType extends TypeMirror {
}
@@ -1,177 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.type;
/**
* The kind of a type mirror.
*
* <p>Note that it is possible additional type kinds will be added to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see TypeMirror
* @since 1.6
*/
public enum TypeKind {
/**
* The primitive type {@code boolean}.
*/
BOOLEAN,
/**
* The primitive type {@code byte}.
*/
BYTE,
/**
* The primitive type {@code short}.
*/
SHORT,
/**
* The primitive type {@code int}.
*/
INT,
/**
* The primitive type {@code long}.
*/
LONG,
/**
* The primitive type {@code char}.
*/
CHAR,
/**
* The primitive type {@code float}.
*/
FLOAT,
/**
* The primitive type {@code double}.
*/
DOUBLE,
/**
* The pseudo-type corresponding to the keyword {@code void}.
* @see NoType
*/
VOID,
/**
* A pseudo-type used where no actual type is appropriate.
* @see NoType
*/
NONE,
/**
* The null type.
*/
NULL,
/**
* An array type.
*/
ARRAY,
/**
* A class or interface type.
*/
DECLARED,
/**
* A class or interface type that could not be resolved.
*/
ERROR,
/**
* A type variable.
*/
TYPEVAR,
/**
* A wildcard type argument.
*/
WILDCARD,
/**
* A pseudo-type corresponding to a package element.
* @see NoType
*/
PACKAGE,
/**
* A method, constructor, or initializer.
*/
EXECUTABLE,
/**
* An implementation-reserved type.
* This is not the type you are looking for.
*/
OTHER,
/**
* A union type.
*
* @since 1.7
*/
UNION,
/**
* An intersection type.
*
* @since 1.8
*/
INTERSECTION;
/**
* Returns {@code true} if this kind corresponds to a primitive
* type and {@code false} otherwise.
* @return {@code true} if this kind corresponds to a primitive type
*/
public boolean isPrimitive() {
switch(this) {
case BOOLEAN:
case BYTE:
case SHORT:
case INT:
case LONG:
case CHAR:
case FLOAT:
case DOUBLE:
return true;
default:
return false;
}
}
}
@@ -1,110 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.type;
import java.lang.annotation.Annotation;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.util.Types;
/**
* Represents a type in the Java programming language.
* Types include primitive types, declared types (class and interface types),
* array types, type variables, and the null type.
* Also represented are wildcard type arguments,
* the signature and return types of executables,
* and pseudo-types corresponding to packages and to the keyword {@code void}.
*
* <p> Types should be compared using the utility methods in {@link
* Types}. There is no guarantee that any particular type will always
* be represented by the same object.
*
* <p> To implement operations based on the class of an {@code
* TypeMirror} object, either use a {@linkplain TypeVisitor visitor}
* or use the result of the {@link #getKind} method. Using {@code
* instanceof} is <em>not</em> necessarily a reliable idiom for
* determining the effective class of an object in this modeling
* hierarchy since an implementation may choose to have a single
* object implement multiple {@code TypeMirror} subinterfaces.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see Element
* @see Types
* @since 1.6
*/
public interface TypeMirror extends javax.lang.model.AnnotatedConstruct {
/**
* Returns the {@code kind} of this type.
*
* @return the kind of this type
*/
TypeKind getKind();
/**
* Obeys the general contract of {@link Object#equals Object.equals}.
* This method does not, however, indicate whether two types represent
* the same type.
* Semantic comparisons of type equality should instead use
* {@link Types#isSameType(TypeMirror, TypeMirror)}.
* The results of {@code t1.equals(t2)} and
* {@code Types.isSameType(t1, t2)} may differ.
*
* @param obj the object to be compared with this type
* @return {@code true} if the specified object is equal to this one
*/
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
int hashCode();
/**
* Returns an informative string representation of this type. If
* possible, the string should be of a form suitable for
* representing this type in source code. Any names embedded in
* the result are qualified if possible.
*
* @return a string representation of this type
*/
String toString();
/**
* Applies a visitor to this type.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this type
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(TypeVisitor<R, P> v, P p);
}
@@ -1,83 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.type;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.util.Types;
/**
* Represents a type variable.
* A type variable may be explicitly declared by a
* {@linkplain TypeParameterElement type parameter} of a
* type, method, or constructor.
* A type variable may also be declared implicitly, as by
* the capture conversion of a wildcard type argument
* (see chapter 5 of
* <cite>The Java&trade; Language Specification</cite>).
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see TypeParameterElement
* @since 1.6
*/
public interface TypeVariable extends ReferenceType {
/**
* Returns the element corresponding to this type variable.
*
* @return the element corresponding to this type variable
*/
Element asElement();
/**
* Returns the upper bound of this type variable.
*
* <p> If this type variable was declared with no explicit
* upper bounds, the result is {@code java.lang.Object}.
* If it was declared with multiple upper bounds,
* the result is an {@linkplain IntersectionType intersection type};
* individual bounds can be found by examining the result's
* {@linkplain IntersectionType#getBounds() bounds}.
*
* @return the upper bound of this type variable
*/
TypeMirror getUpperBound();
/**
* Returns the lower bound of this type variable. While a type
* parameter cannot include an explicit lower bound declaration,
* capture conversion can produce a type variable with a
* non-trivial lower bound. Type variables otherwise have a
* lower bound of {@link NullType}.
*
* @return the lower bound of this type variable
*/
TypeMirror getLowerBound();
}
@@ -1,197 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.type;
import javax.lang.model.element.*;
/**
* A visitor of types, in the style of the
* visitor design pattern. Classes implementing this
* interface are used to operate on a type when the kind of
* type is unknown at compile time. When a visitor is passed to a
* type's {@link TypeMirror#accept accept} method, the <tt>visit<i>XYZ</i></tt>
* method most applicable to that type is invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java&trade; programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* <p>Note that methods to accommodate new language constructs could
* be added in a source <em>compatible</em> way if they were added as
* <em>default methods</em>. However, default methods are only
* available on Java SE 8 and higher releases and the {@code
* javax.lang.model.*} packages bundled in Java SE 8 are required to
* also be runnable on Java SE 7. Therefore, default methods
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
* to cover Java SE 8 language features. However, default methods may
* be used in subsequent revisions of the {@code javax.lang.model.*}
* packages that are only required to run on Java SE 8 and higher
* platform versions.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface TypeVisitor<R, P> {
/**
* Visits a type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(TypeMirror t, P p);
/**
* A convenience method equivalent to {@code v.visit(t, null)}.
* @param t the element to visit
* @return a visitor-specified result
*/
R visit(TypeMirror t);
/**
* Visits a primitive type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitPrimitive(PrimitiveType t, P p);
/**
* Visits the null type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitNull(NullType t, P p);
/**
* Visits an array type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitArray(ArrayType t, P p);
/**
* Visits a declared type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitDeclared(DeclaredType t, P p);
/**
* Visits an error type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitError(ErrorType t, P p);
/**
* Visits a type variable.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitTypeVariable(TypeVariable t, P p);
/**
* Visits a wildcard type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitWildcard(WildcardType t, P p);
/**
* Visits an executable type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitExecutable(ExecutableType t, P p);
/**
* Visits a {@link NoType} instance.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitNoType(NoType t, P p);
/**
* Visits an unknown kind of type.
* This can occur if the language evolves and new kinds
* of types are added to the {@code TypeMirror} hierarchy.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownTypeException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(TypeMirror t, P p);
/**
* Visits a union type.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @since 1.7
*/
R visitUnion(UnionType t, P p);
/**
* Visits an intersection type.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @since 1.8
*/
R visitIntersection(IntersectionType t, P p);
}
@@ -1,47 +0,0 @@
/*
* Copyright (c) 2010, 2011, 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 javax.lang.model.type;
import java.util.List;
/**
* Represents a union type.
*
* As of the {@link javax.lang.model.SourceVersion#RELEASE_7
* RELEASE_7} source version, union types can appear as the type
* of a multi-catch exception parameter.
*
* @since 1.7
*/
public interface UnionType extends TypeMirror {
/**
* Return the alternatives comprising this union type.
*
* @return the alternatives comprising this union type.
*/
List<? extends TypeMirror> getAlternatives();
}
@@ -1,85 +0,0 @@
/*
* Copyright (c) 2005, 2009, 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 javax.lang.model.type;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of type was encountered. This can
* occur if the language evolves and new kinds of types are added to
* the {@code TypeMirror} hierarchy. May be thrown by a {@linkplain
* TypeVisitor type visitor} to indicate that the visitor was created
* for a prior version of the language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see TypeVisitor#visitUnknown
* @since 1.6
*/
public class UnknownTypeException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient TypeMirror type;
private transient Object parameter;
/**
* Creates a new {@code UnknownTypeException}.The {@code p}
* parameter may be used to pass in an additional argument with
* information about the context in which the unknown type was
* encountered; for example, the visit methods of {@link
* TypeVisitor} may pass in their additional parameter.
*
* @param t the unknown type, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownTypeException(TypeMirror t, Object p) {
super("Unknown type: " + t);
type = t;
this.parameter = p;
}
/**
* Returns the unknown type.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown type, or {@code null} if unavailable
*/
public TypeMirror getUnknownType() {
return type;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}
@@ -1,65 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents a wildcard type argument.
* Examples include: <pre><tt>
* ?
* ? extends Number
* ? super T
* </tt></pre>
*
* <p> A wildcard may have its upper bound explicitly set by an
* {@code extends} clause, its lower bound explicitly set by a
* {@code super} clause, or neither (but not both).
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface WildcardType extends TypeMirror {
/**
* Returns the upper bound of this wildcard.
* If no upper bound is explicitly declared,
* {@code null} is returned.
*
* @return the upper bound of this wildcard
*/
TypeMirror getExtendsBound();
/**
* Returns the lower bound of this wildcard.
* If no lower bound is explicitly declared,
* {@code null} is returned.
*
* @return the lower bound of this wildcard
*/
TypeMirror getSuperBound();
}
@@ -1,123 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A skeletal visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see AbstractAnnotationValueVisitor7
* @see AbstractAnnotationValueVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public abstract class AbstractAnnotationValueVisitor6<R, P>
implements AnnotationValueVisitor<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractAnnotationValueVisitor6() {}
/**
* Visits an annotation value as if by passing itself to that
* value's {@link AnnotationValue#accept accept}. The invocation
* {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}.
* @param av {@inheritDoc}
* @param p {@inheritDoc}
*/
public final R visit(AnnotationValue av, P p) {
return av.accept(this, p);
}
/**
* Visits an annotation value as if by passing itself to that
* value's {@link AnnotationValue#accept accept} method passing
* {@code null} for the additional parameter. The invocation
* {@code v.visit(av)} is equivalent to {@code av.accept(v,
* null)}.
* @param av {@inheritDoc}
*/
public final R visit(AnnotationValue av) {
return av.accept(this, null);
}
/**
* {@inheritDoc}
*
* <p>The default implementation of this method in {@code
* AbstractAnnotationValueVisitor6} will always throw {@code
* UnknownAnnotationValueException}. This behavior is not
* required of a subclass.
*
* @param av {@inheritDoc}
* @param p {@inheritDoc}
*/
public R visitUnknown(AnnotationValue av, P p) {
throw new UnknownAnnotationValueException(av, p);
}
}
@@ -1,79 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A skeletal visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @see AbstractAnnotationValueVisitor6
* @see AbstractAnnotationValueVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public abstract class AbstractAnnotationValueVisitor7<R, P> extends AbstractAnnotationValueVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractAnnotationValueVisitor7() {
super();
}
}
@@ -1,79 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A skeletal visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
* source version.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @see AbstractAnnotationValueVisitor6
* @see AbstractAnnotationValueVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public abstract class AbstractAnnotationValueVisitor8<R, P> extends AbstractAnnotationValueVisitor7<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractAnnotationValueVisitor8() {
super();
}
}
@@ -1,131 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import static javax.lang.model.SourceVersion.*;
/**
* A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see AbstractElementVisitor7
* @see AbstractElementVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public abstract class AbstractElementVisitor6<R, P> implements ElementVisitor<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractElementVisitor6(){}
/**
* Visits any program element as if by passing itself to that
* element's {@link Element#accept accept} method. The invocation
* {@code v.visit(elem)} is equivalent to {@code elem.accept(v,
* p)}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
public final R visit(Element e, P p) {
return e.accept(this, p);
}
/**
* Visits any program element as if by passing itself to that
* element's {@link Element#accept accept} method and passing
* {@code null} for the additional parameter. The invocation
* {@code v.visit(elem)} is equivalent to {@code elem.accept(v,
* null)}.
*
* @param e the element to visit
* @return a visitor-specified result
*/
public final R visit(Element e) {
return e.accept(this, null);
}
/**
* {@inheritDoc}
*
* <p> The default implementation of this method in
* {@code AbstractElementVisitor6} will always throw
* {@code UnknownElementException}.
* This behavior is not required of a subclass.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownElementException
* a visitor implementation may optionally throw this exception
*/
public R visitUnknown(Element e, P p) {
throw new UnknownElementException(e, p);
}
}
@@ -1,82 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see AbstractElementVisitor6
* @see AbstractElementVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public abstract class AbstractElementVisitor7<R, P> extends AbstractElementVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractElementVisitor7(){
super();
}
}
@@ -1,82 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
* source version.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see AbstractElementVisitor6
* @see AbstractElementVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public abstract class AbstractElementVisitor8<R, P> extends AbstractElementVisitor7<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractElementVisitor8(){
super();
}
}
@@ -1,152 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see AbstractTypeVisitor7
* @see AbstractTypeVisitor8
* @since 1.6
*/
public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractTypeVisitor6() {}
/**
* Visits any type mirror as if by passing itself to that type
* mirror's {@link TypeMirror#accept accept} method. The
* invocation {@code v.visit(t, p)} is equivalent to {@code
* t.accept(v, p)}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
public final R visit(TypeMirror t, P p) {
return t.accept(this, p);
}
/**
* Visits any type mirror as if by passing itself to that type
* mirror's {@link TypeMirror#accept accept} method and passing
* {@code null} for the additional parameter. The invocation
* {@code v.visit(t)} is equivalent to {@code t.accept(v, null)}.
*
* @param t the type to visit
* @return a visitor-specified result
*/
public final R visit(TypeMirror t) {
return t.accept(this, null);
}
/**
* Visits a {@code UnionType} element by calling {@code
* visitUnknown}.
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code visitUnknown}
*
* @since 1.7
*/
public R visitUnion(UnionType t, P p) {
return visitUnknown(t, p);
}
/**
* Visits an {@code IntersectionType} element by calling {@code
* visitUnknown}.
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code visitUnknown}
*
* @since 1.8
*/
public R visitIntersection(IntersectionType t, P p) {
return visitUnknown(t, p);
}
/**
* {@inheritDoc}
*
* <p> The default implementation of this method in {@code
* AbstractTypeVisitor6} will always throw {@code
* UnknownTypeException}. This behavior is not required of a
* subclass.
*
* @param t the type to visit
* @return a visitor-specified result
* @throws UnknownTypeException
* a visitor implementation may optionally throw this exception
*/
public R visitUnknown(TypeMirror t, P p) {
throw new UnknownTypeException(t, p);
}
}
@@ -1,87 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see AbstractTypeVisitor6
* @see AbstractTypeVisitor8
* @since 1.7
*/
public abstract class AbstractTypeVisitor7<R, P> extends AbstractTypeVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractTypeVisitor7() {
super();
}
/**
* Visits a {@code UnionType} in a manner defined by a subclass.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the visit as defined by a subclass
*/
public abstract R visitUnion(UnionType t, P p);
}
@@ -1,87 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the {@link javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see AbstractTypeVisitor6
* @see AbstractTypeVisitor7
* @since 1.8
*/
public abstract class AbstractTypeVisitor8<R, P> extends AbstractTypeVisitor7<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractTypeVisitor8() {
super();
}
/**
* Visits an {@code IntersectionType} in a manner defined by a subclass.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the visit as defined by a subclass
*/
public abstract R visitIntersection(IntersectionType t, P p);
}
@@ -1,210 +0,0 @@
/*
* 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 javax.lang.model.util;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.EnumSet;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import javax.lang.model.element.*;
/**
* Filters for selecting just the elements of interest from a
* collection of elements. The returned sets and lists are new
* collections and do use the argument as a backing store. The
* methods in this class do not make any attempts to guard against
* concurrent modifications of the arguments. The returned sets and
* lists are mutable but unsafe for concurrent access. A returned set
* has the same iteration order as the argument set to a method.
*
* <p>If iterables and sets containing {@code null} are passed as
* arguments to methods in this class, a {@code NullPointerException}
* will be thrown.
*
* <p>Note that a <i>static import</i> statement can make the text of
* calls to the methods in this class more concise; for example:
*
* <blockquote><pre>
* import static javax.lang.model.util.ElementFilter.*;
* ...
* {@code List<VariableElement>} fs = fieldsIn(someClass.getEnclosedElements());
* </pre></blockquote>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @author Martin Buchholz
* @since 1.6
*/
public class ElementFilter {
private ElementFilter() {} // Do not instantiate.
private static final Set<ElementKind> CONSTRUCTOR_KIND =
Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
private static final Set<ElementKind> FIELD_KINDS =
Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
ElementKind.ENUM_CONSTANT));
private static final Set<ElementKind> METHOD_KIND =
Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
private static final Set<ElementKind> PACKAGE_KIND =
Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
private static final Set<ElementKind> TYPE_KINDS =
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
ElementKind.ENUM,
ElementKind.INTERFACE,
ElementKind.ANNOTATION_TYPE));
/**
* Returns a list of fields in {@code elements}.
* @return a list of fields in {@code elements}
* @param elements the elements to filter
*/
public static List<VariableElement>
fieldsIn(Iterable<? extends Element> elements) {
return listFilter(elements, FIELD_KINDS, VariableElement.class);
}
/**
* Returns a set of fields in {@code elements}.
* @return a set of fields in {@code elements}
* @param elements the elements to filter
*/
public static Set<VariableElement>
fieldsIn(Set<? extends Element> elements) {
return setFilter(elements, FIELD_KINDS, VariableElement.class);
}
/**
* Returns a list of constructors in {@code elements}.
* @return a list of constructors in {@code elements}
* @param elements the elements to filter
*/
public static List<ExecutableElement>
constructorsIn(Iterable<? extends Element> elements) {
return listFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
}
/**
* Returns a set of constructors in {@code elements}.
* @return a set of constructors in {@code elements}
* @param elements the elements to filter
*/
public static Set<ExecutableElement>
constructorsIn(Set<? extends Element> elements) {
return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
}
/**
* Returns a list of methods in {@code elements}.
* @return a list of methods in {@code elements}
* @param elements the elements to filter
*/
public static List<ExecutableElement>
methodsIn(Iterable<? extends Element> elements) {
return listFilter(elements, METHOD_KIND, ExecutableElement.class);
}
/**
* Returns a set of methods in {@code elements}.
* @return a set of methods in {@code elements}
* @param elements the elements to filter
*/
public static Set<ExecutableElement>
methodsIn(Set<? extends Element> elements) {
return setFilter(elements, METHOD_KIND, ExecutableElement.class);
}
/**
* Returns a list of types in {@code elements}.
* @return a list of types in {@code elements}
* @param elements the elements to filter
*/
public static List<TypeElement>
typesIn(Iterable<? extends Element> elements) {
return listFilter(elements, TYPE_KINDS, TypeElement.class);
}
/**
* Returns a set of types in {@code elements}.
* @return a set of types in {@code elements}
* @param elements the elements to filter
*/
public static Set<TypeElement>
typesIn(Set<? extends Element> elements) {
return setFilter(elements, TYPE_KINDS, TypeElement.class);
}
/**
* Returns a list of packages in {@code elements}.
* @return a list of packages in {@code elements}
* @param elements the elements to filter
*/
public static List<PackageElement>
packagesIn(Iterable<? extends Element> elements) {
return listFilter(elements, PACKAGE_KIND, PackageElement.class);
}
/**
* Returns a set of packages in {@code elements}.
* @return a set of packages in {@code elements}
* @param elements the elements to filter
*/
public static Set<PackageElement>
packagesIn(Set<? extends Element> elements) {
return setFilter(elements, PACKAGE_KIND, PackageElement.class);
}
// Assumes targetKinds and E are sensible.
private static <E extends Element> List<E> listFilter(Iterable<? extends Element> elements,
Set<ElementKind> targetKinds,
Class<E> clazz) {
List<E> list = new ArrayList<E>();
for (Element e : elements) {
if (targetKinds.contains(e.getKind()))
list.add(clazz.cast(e));
}
return list;
}
// Assumes targetKinds and E are sensible.
private static <E extends Element> Set<E> setFilter(Set<? extends Element> elements,
Set<ElementKind> targetKinds,
Class<E> clazz) {
// Return set preserving iteration order of input set.
Set<E> set = new LinkedHashSet<E>();
for (Element e : elements) {
if (targetKinds.contains(e.getKind()))
set.add(clazz.cast(e));
}
return set;
}
}
@@ -1,413 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import static javax.lang.model.element.ElementKind.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it or the
* {@code ElementKind} {@code enum} used in this case may have
* constants added to it in the future to accommodate new, currently
* unknown, language structures added to future versions of the
* Java&trade; programming language. Therefore, methods whose names
* begin with {@code "visit"} may be added to this class in the
* future; to avoid incompatibilities, classes which extend this class
* should not declare any instance methods with names beginning with
* {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element kind
* visitor class will also be introduced to correspond to the new
* language level; this visitor will have different default behavior
* for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see ElementKindVisitor7
* @see ElementKindVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class ElementKindVisitor6<R, P>
extends SimpleElementVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementKindVisitor6() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected ElementKindVisitor6(R defaultValue) {
super(defaultValue);
}
/**
* {@inheritDoc}
*
* The element argument has kind {@code PACKAGE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
public R visitPackage(PackageElement e, P p) {
assert e.getKind() == PACKAGE: "Bad kind on PackageElement";
return defaultAction(e, p);
}
/**
* Visits a type element, dispatching to the visit method for the
* specific {@linkplain ElementKind kind} of type, {@code
* ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code
* INTERFACE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitType(TypeElement e, P p) {
ElementKind k = e.getKind();
switch(k) {
case ANNOTATION_TYPE:
return visitTypeAsAnnotationType(e, p);
case CLASS:
return visitTypeAsClass(e, p);
case ENUM:
return visitTypeAsEnum(e, p);
case INTERFACE:
return visitTypeAsInterface(e, p);
default:
throw new AssertionError("Bad kind " + k + " for TypeElement" + e);
}
}
/**
* Visits an {@code ANNOTATION_TYPE} type element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsAnnotationType(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code CLASS} type element by calling {@code
* defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsClass(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code ENUM} type element by calling {@code
* defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsEnum(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code INTERFACE} type element by calling {@code
* defaultAction}.
*.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsInterface(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a variable element, dispatching to the visit method for
* the specific {@linkplain ElementKind kind} of variable, {@code
* ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
* {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitVariable(VariableElement e, P p) {
ElementKind k = e.getKind();
switch(k) {
case ENUM_CONSTANT:
return visitVariableAsEnumConstant(e, p);
case EXCEPTION_PARAMETER:
return visitVariableAsExceptionParameter(e, p);
case FIELD:
return visitVariableAsField(e, p);
case LOCAL_VARIABLE:
return visitVariableAsLocalVariable(e, p);
case PARAMETER:
return visitVariableAsParameter(e, p);
case RESOURCE_VARIABLE:
return visitVariableAsResourceVariable(e, p);
default:
throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
}
}
/**
* Visits an {@code ENUM_CONSTANT} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsEnumConstant(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code EXCEPTION_PARAMETER} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsExceptionParameter(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code FIELD} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsField(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code LOCAL_VARIABLE} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsLocalVariable(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code PARAMETER} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsParameter(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
* {@code visitUnknown}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code visitUnknown}
*
* @since 1.7
*/
public R visitVariableAsResourceVariable(VariableElement e, P p) {
return visitUnknown(e, p);
}
/**
* Visits an executable element, dispatching to the visit method
* for the specific {@linkplain ElementKind kind} of executable,
* {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
* {@code STATIC_INIT}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitExecutable(ExecutableElement e, P p) {
ElementKind k = e.getKind();
switch(k) {
case CONSTRUCTOR:
return visitExecutableAsConstructor(e, p);
case INSTANCE_INIT:
return visitExecutableAsInstanceInit(e, p);
case METHOD:
return visitExecutableAsMethod(e, p);
case STATIC_INIT:
return visitExecutableAsStaticInit(e, p);
default:
throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e);
}
}
/**
* Visits a {@code CONSTRUCTOR} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsConstructor(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code INSTANCE_INIT} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsInstanceInit(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code METHOD} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsMethod(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code STATIC_INIT} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsStaticInit(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc}
*
* The element argument has kind {@code TYPE_PARAMETER}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
public R visitTypeParameter(TypeParameterElement e, P p) {
assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement";
return defaultAction(e, p);
}
}
@@ -1,119 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import static javax.lang.model.SourceVersion.*;
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_7 RELEASE_7} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it or the
* {@code ElementKind} {@code enum} used in this case may have
* constants added to it in the future to accommodate new, currently
* unknown, language structures added to future versions of the
* Java&trade; programming language. Therefore, methods whose names
* begin with {@code "visit"} may be added to this class in the
* future; to avoid incompatibilities, classes which extend this class
* should not declare any instance methods with names beginning with
* {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element kind
* visitor class will also be introduced to correspond to the new
* language level; this visitor will have different default behavior
* for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see ElementKindVisitor6
* @see ElementKindVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class ElementKindVisitor7<R, P> extends ElementKindVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementKindVisitor7() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected ElementKindVisitor7(R defaultValue) {
super(defaultValue);
}
/**
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
* {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitVariableAsResourceVariable(VariableElement e, P p) {
return defaultAction(e, p);
}
}
@@ -1,106 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_8 RELEASE_8} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it or the
* {@code ElementKind} {@code enum} used in this case may have
* constants added to it in the future to accommodate new, currently
* unknown, language structures added to future versions of the
* Java&trade; programming language. Therefore, methods whose names
* begin with {@code "visit"} may be added to this class in the
* future; to avoid incompatibilities, classes which extend this class
* should not declare any instance methods with names beginning with
* {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element kind
* visitor class will also be introduced to correspond to the new
* language level; this visitor will have different default behavior
* for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see ElementKindVisitor6
* @see ElementKindVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public class ElementKindVisitor8<R, P> extends ElementKindVisitor7<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementKindVisitor8() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected ElementKindVisitor8(R defaultValue) {
super(defaultValue);
}
}
@@ -1,220 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
* class scan their component elements by calling {@code scan} on
* their {@linkplain Element#getEnclosedElements enclosed elements},
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
* indicated in the individual method specifications. A subclass can
* control the order elements are visited by overriding the
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
* than {@code v.visit(e, p)} on the root objects of interest.
*
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
* new method can cause the enclosed elements to be scanned in the
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
* fashion, the concrete visitor can control the ordering of traversal
* over the component elements with respect to the additional
* processing; for example, consistently calling
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
* methods will yield a preorder traversal, etc. If the component
* elements should be traversed in some other order, instead of
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
* should call {@code scan} with the elements in the desired order.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new element scanner visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see ElementScanner7
* @see ElementScanner8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* The specified default value.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementScanner6(){
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the default value
*/
protected ElementScanner6(R defaultValue){
DEFAULT_VALUE = defaultValue;
}
/**
* Iterates over the given elements and calls {@link
* #scan(Element, Object) scan(Element, P)} on each one. Returns
* the result of the last call to {@code scan} or {@code
* DEFAULT_VALUE} for an empty iterable.
*
* @param iterable the elements to scan
* @param p additional parameter
* @return the scan of the last element or {@code DEFAULT_VALUE} if no elements
*/
public final R scan(Iterable<? extends Element> iterable, P p) {
R result = DEFAULT_VALUE;
for(Element e : iterable)
result = scan(e, p);
return result;
}
/**
* Processes an element by calling {@code e.accept(this, p)};
* this method may be overridden by subclasses.
*
* @param e the element to scan
* @param p a scanner-specified parameter
* @return the result of visiting {@code e}.
*/
public R scan(Element e, P p) {
return e.accept(this, p);
}
/**
* Convenience method equivalent to {@code v.scan(e, null)}.
*
* @param e the element to scan
* @return the result of scanning {@code e}.
*/
public final R scan(Element e) {
return scan(e, null);
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitPackage(PackageElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitType(TypeElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
/**
* {@inheritDoc}
*
* This implementation scans the enclosed elements, unless the
* element is a {@code RESOURCE_VARIABLE} in which case {@code
* visitUnknown} is called.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitVariable(VariableElement e, P p) {
if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
return scan(e.getEnclosedElements(), p);
else
return visitUnknown(e, p);
}
/**
* {@inheritDoc} This implementation scans the parameters.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitExecutable(ExecutableElement e, P p) {
return scan(e.getParameters(), p);
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitTypeParameter(TypeParameterElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
}
@@ -1,122 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
* class scan their component elements by calling {@code scan} on
* their {@linkplain Element#getEnclosedElements enclosed elements},
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
* indicated in the individual method specifications. A subclass can
* control the order elements are visited by overriding the
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
* than {@code v.visit(e, p)} on the root objects of interest.
*
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
* new method can cause the enclosed elements to be scanned in the
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
* fashion, the concrete visitor can control the ordering of traversal
* over the component elements with respect to the additional
* processing; for example, consistently calling
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
* methods will yield a preorder traversal, etc. If the component
* elements should be traversed in some other order, instead of
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
* should call {@code scan} with the elements in the desired order.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new element scanner visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see ElementScanner6
* @see ElementScanner8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class ElementScanner7<R, P> extends ElementScanner6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementScanner7(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the default value
*/
protected ElementScanner7(R defaultValue){
super(defaultValue);
}
/**
* This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
@Override
public R visitVariable(VariableElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
}
@@ -1,110 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
* class scan their component elements by calling {@code scan} on
* their {@linkplain Element#getEnclosedElements enclosed elements},
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
* indicated in the individual method specifications. A subclass can
* control the order elements are visited by overriding the
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
* than {@code v.visit(e, p)} on the root objects of interest.
*
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
* new method can cause the enclosed elements to be scanned in the
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
* fashion, the concrete visitor can control the ordering of traversal
* over the component elements with respect to the additional
* processing; for example, consistently calling
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
* methods will yield a preorder traversal, etc. If the component
* elements should be traversed in some other order, instead of
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
* should call {@code scan} with the elements in the desired order.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new element scanner visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see ElementScanner6
* @see ElementScanner7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public class ElementScanner8<R, P> extends ElementScanner7<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementScanner8(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the default value
*/
protected ElementScanner8(R defaultValue){
super(defaultValue);
}
}
@@ -1,264 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import java.util.List;
import java.util.Map;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Utility methods for operating on program elements.
*
* <p><b>Compatibility Note:</b> Methods may be added to this interface
* in future releases of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see javax.annotation.processing.ProcessingEnvironment#getElementUtils
* @since 1.6
*/
public interface Elements {
/**
* Returns a package given its fully qualified name.
*
* @param name fully qualified package name, or "" for an unnamed package
* @return the named package, or {@code null} if it cannot be found
*/
PackageElement getPackageElement(CharSequence name);
/**
* Returns a type element given its canonical name.
*
* @param name the canonical name
* @return the named type element, or {@code null} if it cannot be found
*/
TypeElement getTypeElement(CharSequence name);
/**
* Returns the values of an annotation's elements, including defaults.
*
* @see AnnotationMirror#getElementValues()
* @param a annotation to examine
* @return the values of the annotation's elements, including defaults
*/
Map<? extends ExecutableElement, ? extends AnnotationValue>
getElementValuesWithDefaults(AnnotationMirror a);
/**
* Returns the text of the documentation (&quot;Javadoc&quot;)
* comment of an element.
*
* <p> A documentation comment of an element is a comment that
* begins with "{@code /**}" , ends with a separate
* "<code>*&#47;</code>", and immediately precedes the element,
* ignoring white space. Therefore, a documentation comment
* contains at least three"{@code *}" characters. The text
* returned for the documentation comment is a processed form of
* the comment as it appears in source code. The leading "{@code
* /**}" and trailing "<code>*&#47;</code>" are removed. For lines
* of the comment starting after the initial "{@code /**}",
* leading white space characters are discarded as are any
* consecutive "{@code *}" characters appearing after the white
* space or starting the line. The processed lines are then
* concatenated together (including line terminators) and
* returned.
*
* @param e the element being examined
* @return the documentation comment of the element, or {@code null}
* if there is none
* @jls 3.6 White Space
*/
String getDocComment(Element e);
/**
* Returns {@code true} if the element is deprecated, {@code false} otherwise.
*
* @param e the element being examined
* @return {@code true} if the element is deprecated, {@code false} otherwise
*/
boolean isDeprecated(Element e);
/**
* Returns the <i>binary name</i> of a type element.
*
* @param type the type element being examined
* @return the binary name
*
* @see TypeElement#getQualifiedName
* @jls 13.1 The Form of a Binary
*/
Name getBinaryName(TypeElement type);
/**
* Returns the package of an element. The package of a package is
* itself.
*
* @param type the element being examined
* @return the package of an element
*/
PackageElement getPackageOf(Element type);
/**
* Returns all members of a type element, whether inherited or
* declared directly. For a class the result also includes its
* constructors, but not local or anonymous classes.
*
* <p>Note that elements of certain kinds can be isolated using
* methods in {@link ElementFilter}.
*
* @param type the type being examined
* @return all members of the type
* @see Element#getEnclosedElements
*/
List<? extends Element> getAllMembers(TypeElement type);
/**
* Returns all annotations <i>present</i> on an element, whether
* directly present or present via inheritance.
*
* @param e the element being examined
* @return all annotations of the element
* @see Element#getAnnotationMirrors
* @see javax.lang.model.AnnotatedConstruct
*/
List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
/**
* Tests whether one type, method, or field hides another.
*
* @param hider the first element
* @param hidden the second element
* @return {@code true} if and only if the first element hides
* the second
*/
boolean hides(Element hider, Element hidden);
/**
* Tests whether one method, as a member of a given type,
* overrides another method.
* When a non-abstract method overrides an abstract one, the
* former is also said to <i>implement</i> the latter.
*
* <p> In the simplest and most typical usage, the value of the
* {@code type} parameter will simply be the class or interface
* directly enclosing {@code overrider} (the possibly-overriding
* method). For example, suppose {@code m1} represents the method
* {@code String.hashCode} and {@code m2} represents {@code
* Object.hashCode}. We can then ask whether {@code m1} overrides
* {@code m2} within the class {@code String} (it does):
*
* <blockquote>
* {@code assert elements.overrides(m1, m2,
* elements.getTypeElement("java.lang.String")); }
* </blockquote>
*
* A more interesting case can be illustrated by the following example
* in which a method in type {@code A} does not override a
* like-named method in type {@code B}:
*
* <blockquote>
* {@code class A { public void m() {} } }<br>
* {@code interface B { void m(); } }<br>
* ...<br>
* {@code m1 = ...; // A.m }<br>
* {@code m2 = ...; // B.m }<br>
* {@code assert ! elements.overrides(m1, m2,
* elements.getTypeElement("A")); }
* </blockquote>
*
* When viewed as a member of a third type {@code C}, however,
* the method in {@code A} does override the one in {@code B}:
*
* <blockquote>
* {@code class C extends A implements B {} }<br>
* ...<br>
* {@code assert elements.overrides(m1, m2,
* elements.getTypeElement("C")); }
* </blockquote>
*
* @param overrider the first method, possible overrider
* @param overridden the second method, possibly being overridden
* @param type the type of which the first method is a member
* @return {@code true} if and only if the first method overrides
* the second
* @jls 8.4.8 Inheritance, Overriding, and Hiding
* @jls 9.4.1 Inheritance and Overriding
*/
boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
TypeElement type);
/**
* Returns the text of a <i>constant expression</i> representing a
* primitive value or a string.
* The text returned is in a form suitable for representing the value
* in source code.
*
* @param value a primitive value or string
* @return the text of a constant expression
* @throws IllegalArgumentException if the argument is not a primitive
* value or string
*
* @see VariableElement#getConstantValue()
*/
String getConstantExpression(Object value);
/**
* Prints a representation of the elements to the given writer in
* the specified order. The main purpose of this method is for
* diagnostics. The exact format of the output is <em>not</em>
* specified and is subject to change.
*
* @param w the writer to print the output to
* @param elements the elements to print
*/
void printElements(java.io.Writer w, Element... elements);
/**
* Return a name with the same sequence of characters as the
* argument.
*
* @param cs the character sequence to return as a name
* @return a name with the same sequence of characters as the argument
*/
Name getName(CharSequence cs);
/**
* Returns {@code true} if the type element is a functional interface, {@code false} otherwise.
*
* @param type the type element being examined
* @return {@code true} if the element is a functional interface, {@code false} otherwise
* @jls 9.8 Functional Interfaces
* @since 1.8
*/
boolean isFunctionalInterface(TypeElement type);
}
@@ -1,272 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version. Visit methods call {@link
* #defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see SimpleAnnotationValueVisitor7
* @see SimpleAnnotationValueVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class SimpleAnnotationValueVisitor6<R, P>
extends AbstractAnnotationValueVisitor6<R, P> {
/**
* Default value to be returned; {@link #defaultAction
* defaultAction} returns this value unless the method is
* overridden.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleAnnotationValueVisitor6() {
super();
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleAnnotationValueVisitor6(R defaultValue) {
super();
DEFAULT_VALUE = defaultValue;
}
/**
* The default action for visit methods. The implementation in
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
* commonly override this method.
*
* @param o the value of the annotation
* @param p a visitor-specified parameter
* @return {@code DEFAULT_VALUE} unless overridden
*/
protected R defaultAction(Object o, P p) {
return DEFAULT_VALUE;
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param b {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitBoolean(boolean b, P p) {
return defaultAction(b, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param b {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitByte(byte b, P p) {
return defaultAction(b, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param c {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitChar(char c, P p) {
return defaultAction(c, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param d {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitDouble(double d, P p) {
return defaultAction(d, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param f {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitFloat(float f, P p) {
return defaultAction(f, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param i {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitInt(int i, P p) {
return defaultAction(i, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param i {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitLong(long i, P p) {
return defaultAction(i, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param s {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitShort(short s, P p) {
return defaultAction(s, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param s {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitString(String s, P p) {
return defaultAction(s, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitType(TypeMirror t, P p) {
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param c {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitEnumConstant(VariableElement c, P p) {
return defaultAction(c, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param a {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitAnnotation(AnnotationMirror a, P p) {
return defaultAction(a, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param vals {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitArray(List<? extends AnnotationValue> vals, P p) {
return defaultAction(vals, p);
}
}
@@ -1,96 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version. Visit methods call {@link #defaultAction
* defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @see SimpleAnnotationValueVisitor6
* @see SimpleAnnotationValueVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class SimpleAnnotationValueVisitor7<R, P> extends SimpleAnnotationValueVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleAnnotationValueVisitor7() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleAnnotationValueVisitor7(R defaultValue) {
super(defaultValue);
}
}
@@ -1,96 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
* source version. Visit methods call {@link #defaultAction
* defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @see SimpleAnnotationValueVisitor6
* @see SimpleAnnotationValueVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public class SimpleAnnotationValueVisitor8<R, P> extends SimpleAnnotationValueVisitor7<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleAnnotationValueVisitor8() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleAnnotationValueVisitor8(R defaultValue) {
super(defaultValue);
}
}
@@ -1,190 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
* constructs call {@link #defaultAction defaultAction}, passing their
* arguments to {@code defaultAction}'s corresponding parameters.
*
* For constructs introduced in {@code RELEASE_7} and later, {@code
* visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@code Void}
* for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
* for visitors that do not need an additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see SimpleElementVisitor7
* @see SimpleElementVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class SimpleElementVisitor6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* Default value to be returned; {@link #defaultAction
* defaultAction} returns this value unless the method is
* overridden.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleElementVisitor6(){
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleElementVisitor6(R defaultValue){
DEFAULT_VALUE = defaultValue;
}
/**
* The default action for visit methods. The implementation in
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
* commonly override this method.
*
* @param e the element to process
* @param p a visitor-specified parameter
* @return {@code DEFAULT_VALUE} unless overridden
*/
protected R defaultAction(Element e, P p) {
return DEFAULT_VALUE;
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitPackage(PackageElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitType(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc}
*
* This implementation calls {@code defaultAction}, unless the
* element is a {@code RESOURCE_VARIABLE} in which case {@code
* visitUnknown} is called.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction} or {@code visitUnknown}
*/
public R visitVariable(VariableElement e, P p) {
if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
return defaultAction(e, p);
else
return visitUnknown(e, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitExecutable(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitTypeParameter(TypeParameterElement e, P p) {
return defaultAction(e, p);
}
}
@@ -1,114 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@code Void}
* for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
* for visitors that do not need an additional parameter.
*
* @see SimpleElementVisitor6
* @see SimpleElementVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class SimpleElementVisitor7<R, P> extends SimpleElementVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleElementVisitor7(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleElementVisitor7(R defaultValue){
super(defaultValue);
}
/**
* This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitVariable(VariableElement e, P p) {
return defaultAction(e, p);
}
}
@@ -1,101 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
* source version.
*
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@code Void}
* for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
* for visitors that do not need an additional parameter.
*
* @see SimpleElementVisitor6
* @see SimpleElementVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public class SimpleElementVisitor8<R, P> extends SimpleElementVisitor7<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleElementVisitor8(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleElementVisitor8(R defaultValue){
super(defaultValue);
}
}
@@ -1,228 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
* constructs call {@link #defaultAction defaultAction}, passing their
* arguments to {@code defaultAction}'s corresponding parameters.
*
* For constructs introduced in {@code RELEASE_7} and later, {@code
* visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see SimpleTypeVisitor7
* @see SimpleTypeVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class SimpleTypeVisitor6<R, P> extends AbstractTypeVisitor6<R, P> {
/**
* Default value to be returned; {@link #defaultAction
* defaultAction} returns this value unless the method is
* overridden.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleTypeVisitor6(){
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleTypeVisitor6(R defaultValue){
DEFAULT_VALUE = defaultValue;
}
/**
* The default action for visit methods. The implementation in
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
* commonly override this method.
*
* @param e the type to process
* @param p a visitor-specified parameter
* @return {@code DEFAULT_VALUE} unless overridden
*/
protected R defaultAction(TypeMirror e, P p) {
return DEFAULT_VALUE;
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitPrimitive(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitNull(NullType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitArray(ArrayType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitDeclared(DeclaredType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitError(ErrorType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitTypeVariable(TypeVariable t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitWildcard(WildcardType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitExecutable(ExecutableType t, P p) {
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitNoType(NoType t, P p){
return defaultAction(t, p);
}
}
@@ -1,115 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
*
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see SimpleTypeVisitor6
* @see SimpleTypeVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class SimpleTypeVisitor7<R, P> extends SimpleTypeVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleTypeVisitor7(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleTypeVisitor7(R defaultValue){
super(defaultValue);
}
/**
* This implementation visits a {@code UnionType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitUnion(UnionType t, P p) {
return defaultAction(t, p);
}
}
@@ -1,115 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.type.IntersectionType;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
*
* Visit methods corresponding to {@code RELEASE_8} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see SimpleTypeVisitor6
* @see SimpleTypeVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public class SimpleTypeVisitor8<R, P> extends SimpleTypeVisitor7<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleTypeVisitor8(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleTypeVisitor8(R defaultValue){
super(defaultValue);
}
/**
* This implementation visits an {@code IntersectionType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitIntersection(IntersectionType t, P p){
return defaultAction(t, p);
}
}
@@ -1,310 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.type.*;
import static javax.lang.model.SourceVersion.*;
/**
* A visitor of types based on their {@linkplain TypeKind kind} with
* default behavior appropriate for the {@link SourceVersion#RELEASE_6
* RELEASE_6} source version. For {@linkplain
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new type kind visitor class
* will also be introduced to correspond to the new language level;
* this visitor will have different default behavior for the visit
* method in question. When the new visitor is introduced, all or
* portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
*
* @see TypeKindVisitor7
* @see TypeKindVisitor8
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
* for the default value.
*/
protected TypeKindVisitor6() {
super(null);
}
/**
* Constructor for concrete subclasses to call; uses the argument
* for the default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected TypeKindVisitor6(R defaultValue) {
super(defaultValue);
}
/**
* Visits a primitive type, dispatching to the visit method for
* the specific {@linkplain TypeKind kind} of primitive type:
* {@code BOOLEAN}, {@code BYTE}, etc.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitPrimitive(PrimitiveType t, P p) {
TypeKind k = t.getKind();
switch (k) {
case BOOLEAN:
return visitPrimitiveAsBoolean(t, p);
case BYTE:
return visitPrimitiveAsByte(t, p);
case SHORT:
return visitPrimitiveAsShort(t, p);
case INT:
return visitPrimitiveAsInt(t, p);
case LONG:
return visitPrimitiveAsLong(t, p);
case CHAR:
return visitPrimitiveAsChar(t, p);
case FLOAT:
return visitPrimitiveAsFloat(t, p);
case DOUBLE:
return visitPrimitiveAsDouble(t, p);
default:
throw new AssertionError("Bad kind " + k + " for PrimitiveType" + t);
}
}
/**
* Visits a {@code BOOLEAN} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsBoolean(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code BYTE} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsByte(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code SHORT} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsShort(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits an {@code INT} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsInt(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code LONG} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsLong(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code CHAR} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsChar(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code FLOAT} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsFloat(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code DOUBLE} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsDouble(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@link NoType} instance, dispatching to the visit method for
* the specific {@linkplain TypeKind kind} of pseudo-type:
* {@code VOID}, {@code PACKAGE}, or {@code NONE}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitNoType(NoType t, P p) {
TypeKind k = t.getKind();
switch (k) {
case VOID:
return visitNoTypeAsVoid(t, p);
case PACKAGE:
return visitNoTypeAsPackage(t, p);
case NONE:
return visitNoTypeAsNone(t, p);
default:
throw new AssertionError("Bad kind " + k + " for NoType" + t);
}
}
/**
* Visits a {@link TypeKind#VOID VOID} pseudo-type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitNoTypeAsVoid(NoType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@link TypeKind#PACKAGE PACKAGE} pseudo-type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitNoTypeAsPackage(NoType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@link TypeKind#NONE NONE} pseudo-type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitNoTypeAsNone(NoType t, P p) {
return defaultAction(t, p);
}
}
@@ -1,117 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of types based on their {@linkplain TypeKind kind} with
* default behavior appropriate for the {@link SourceVersion#RELEASE_7
* RELEASE_7} source version. For {@linkplain
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new type kind visitor class
* will also be introduced to correspond to the new language level;
* this visitor will have different default behavior for the visit
* method in question. When the new visitor is introduced, all or
* portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see TypeKindVisitor6
* @see TypeKindVisitor8
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class TypeKindVisitor7<R, P> extends TypeKindVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
* for the default value.
*/
protected TypeKindVisitor7() {
super(null);
}
/**
* Constructor for concrete subclasses to call; uses the argument
* for the default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected TypeKindVisitor7(R defaultValue) {
super(defaultValue);
}
/**
* This implementation visits a {@code UnionType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitUnion(UnionType t, P p) {
return defaultAction(t, p);
}
}
@@ -1,117 +0,0 @@
/*
* Copyright (c) 2011, 2013, 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 javax.lang.model.util;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.type.*;
import static javax.lang.model.SourceVersion.*;
/**
* A visitor of types based on their {@linkplain TypeKind kind} with
* default behavior appropriate for the {@link SourceVersion#RELEASE_8
* RELEASE_8} source version. For {@linkplain
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new type kind visitor class
* will also be introduced to correspond to the new language level;
* this visitor will have different default behavior for the visit
* method in question. When the new visitor is introduced, all or
* portions of this visitor may be deprecated.
*
* <p>Note that adding a default implementation of a new visit method
* in a visitor class will occur instead of adding a <em>default
* method</em> directly in the visitor interface since a Java SE 8
* language feature cannot be used to this version of the API since
* this version is required to be runnable on Java SE 7
* implementations. Future versions of the API that are only required
* to run on Java SE 8 and later may take advantage of default methods
* in this situation.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see TypeKindVisitor6
* @see TypeKindVisitor7
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
public class TypeKindVisitor8<R, P> extends TypeKindVisitor7<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
* for the default value.
*/
protected TypeKindVisitor8() {
super(null);
}
/**
* Constructor for concrete subclasses to call; uses the argument
* for the default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected TypeKindVisitor8(R defaultValue) {
super(defaultValue);
}
/**
* This implementation visits an {@code IntersectionType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitIntersection(IntersectionType t, P p) {
return defaultAction(t, p);
}
}
@@ -1,312 +0,0 @@
/*
* Copyright (c) 2005, 2013, 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 javax.lang.model.util;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Utility methods for operating on types.
*
* <p><b>Compatibility Note:</b> Methods may be added to this interface
* in future releases of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see javax.annotation.processing.ProcessingEnvironment#getTypeUtils
* @since 1.6
*/
public interface Types {
/**
* Returns the element corresponding to a type.
* The type may be a {@code DeclaredType} or {@code TypeVariable}.
* Returns {@code null} if the type is not one with a
* corresponding element.
*
* @param t the type to map to an element
* @return the element corresponding to the given type
*/
Element asElement(TypeMirror t);
/**
* Tests whether two {@code TypeMirror} objects represent the same type.
*
* <p>Caveat: if either of the arguments to this method represents a
* wildcard, this method will return false. As a consequence, a wildcard
* is not the same type as itself. This might be surprising at first,
* but makes sense once you consider that an example like this must be
* rejected by the compiler:
* <pre>
* {@code List<?> list = new ArrayList<Object>();}
* {@code list.add(list.get(0));}
* </pre>
*
* <p>Since annotations are only meta-data associated with a type,
* the set of annotations on either argument is <em>not</em> taken
* into account when computing whether or not two {@code
* TypeMirror} objects are the same type. In particular, two
* {@code TypeMirror} objects can have different annotations and
* still be considered the same.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the two types are the same
*/
boolean isSameType(TypeMirror t1, TypeMirror t2);
/**
* Tests whether one type is a subtype of another.
* Any type is considered to be a subtype of itself.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the first type is a subtype
* of the second
* @throws IllegalArgumentException if given an executable or package type
* @jls 4.10 Subtyping
*/
boolean isSubtype(TypeMirror t1, TypeMirror t2);
/**
* Tests whether one type is assignable to another.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the first type is assignable
* to the second
* @throws IllegalArgumentException if given an executable or package type
* @jls 5.2 Assignment Conversion
*/
boolean isAssignable(TypeMirror t1, TypeMirror t2);
/**
* Tests whether one type argument <i>contains</i> another.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the first type contains the second
* @throws IllegalArgumentException if given an executable or package type
* @jls 4.5.1.1 Type Argument Containment and Equivalence
*/
boolean contains(TypeMirror t1, TypeMirror t2);
/**
* Tests whether the signature of one method is a <i>subsignature</i>
* of another.
*
* @param m1 the first method
* @param m2 the second method
* @return {@code true} if and only if the first signature is a
* subsignature of the second
* @jls 8.4.2 Method Signature
*/
boolean isSubsignature(ExecutableType m1, ExecutableType m2);
/**
* Returns the direct supertypes of a type. The interface types, if any,
* will appear last in the list.
*
* @param t the type being examined
* @return the direct supertypes, or an empty list if none
* @throws IllegalArgumentException if given an executable or package type
*/
List<? extends TypeMirror> directSupertypes(TypeMirror t);
/**
* Returns the erasure of a type.
*
* @param t the type to be erased
* @return the erasure of the given type
* @throws IllegalArgumentException if given a package type
* @jls 4.6 Type Erasure
*/
TypeMirror erasure(TypeMirror t);
/**
* Returns the class of a boxed value of a given primitive type.
* That is, <i>boxing conversion</i> is applied.
*
* @param p the primitive type to be converted
* @return the class of a boxed value of type {@code p}
* @jls 5.1.7 Boxing Conversion
*/
TypeElement boxedClass(PrimitiveType p);
/**
* Returns the type (a primitive type) of unboxed values of a given type.
* That is, <i>unboxing conversion</i> is applied.
*
* @param t the type to be unboxed
* @return the type of an unboxed value of type {@code t}
* @throws IllegalArgumentException if the given type has no
* unboxing conversion
* @jls 5.1.8 Unboxing Conversion
*/
PrimitiveType unboxedType(TypeMirror t);
/**
* Applies capture conversion to a type.
*
* @param t the type to be converted
* @return the result of applying capture conversion
* @throws IllegalArgumentException if given an executable or package type
* @jls 5.1.10 Capture Conversion
*/
TypeMirror capture(TypeMirror t);
/**
* Returns a primitive type.
*
* @param kind the kind of primitive type to return
* @return a primitive type
* @throws IllegalArgumentException if {@code kind} is not a primitive kind
*/
PrimitiveType getPrimitiveType(TypeKind kind);
/**
* Returns the null type. This is the type of {@code null}.
*
* @return the null type
*/
NullType getNullType();
/**
* Returns a pseudo-type used where no actual type is appropriate.
* The kind of type to return may be either
* {@link TypeKind#VOID VOID} or {@link TypeKind#NONE NONE}.
* For packages, use
* {@link Elements#getPackageElement(CharSequence)}{@code .asType()}
* instead.
*
* @param kind the kind of type to return
* @return a pseudo-type of kind {@code VOID} or {@code NONE}
* @throws IllegalArgumentException if {@code kind} is not valid
*/
NoType getNoType(TypeKind kind);
/**
* Returns an array type with the specified component type.
*
* @param componentType the component type
* @return an array type with the specified component type.
* @throws IllegalArgumentException if the component type is not valid for
* an array
*/
ArrayType getArrayType(TypeMirror componentType);
/**
* Returns a new wildcard type argument. Either of the wildcard's
* bounds may be specified, or neither, but not both.
*
* @param extendsBound the extends (upper) bound, or {@code null} if none
* @param superBound the super (lower) bound, or {@code null} if none
* @return a new wildcard
* @throws IllegalArgumentException if bounds are not valid
*/
WildcardType getWildcardType(TypeMirror extendsBound,
TypeMirror superBound);
/**
* Returns the type corresponding to a type element and
* actual type arguments.
* Given the type element for {@code Set} and the type mirror
* for {@code String},
* for example, this method may be used to get the
* parameterized type {@code Set<String>}.
*
* <p> The number of type arguments must either equal the
* number of the type element's formal type parameters, or must be
* zero. If zero, and if the type element is generic,
* then the type element's raw type is returned.
*
* <p> If a parameterized type is being returned, its type element
* must not be contained within a generic outer class.
* The parameterized type {@code Outer<String>.Inner<Number>},
* for example, may be constructed by first using this
* method to get the type {@code Outer<String>}, and then invoking
* {@link #getDeclaredType(DeclaredType, TypeElement, TypeMirror...)}.
*
* @param typeElem the type element
* @param typeArgs the actual type arguments
* @return the type corresponding to the type element and
* actual type arguments
* @throws IllegalArgumentException if too many or too few
* type arguments are given, or if an inappropriate type
* argument or type element is provided
*/
DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs);
/**
* Returns the type corresponding to a type element
* and actual type arguments, given a
* {@linkplain DeclaredType#getEnclosingType() containing type}
* of which it is a member.
* The parameterized type {@code Outer<String>.Inner<Number>},
* for example, may be constructed by first using
* {@link #getDeclaredType(TypeElement, TypeMirror...)}
* to get the type {@code Outer<String>}, and then invoking
* this method.
*
* <p> If the containing type is a parameterized type,
* the number of type arguments must equal the
* number of {@code typeElem}'s formal type parameters.
* If it is not parameterized or if it is {@code null}, this method is
* equivalent to {@code getDeclaredType(typeElem, typeArgs)}.
*
* @param containing the containing type, or {@code null} if none
* @param typeElem the type element
* @param typeArgs the actual type arguments
* @return the type corresponding to the type element and
* actual type arguments, contained within the given type
* @throws IllegalArgumentException if too many or too few
* type arguments are given, or if an inappropriate type
* argument, type element, or containing type is provided
*/
DeclaredType getDeclaredType(DeclaredType containing,
TypeElement typeElem, TypeMirror... typeArgs);
/**
* Returns the type of an element when that element is viewed as
* a member of, or otherwise directly contained by, a given type.
* For example,
* when viewed as a member of the parameterized type {@code Set<String>},
* the {@code Set.add} method is an {@code ExecutableType}
* whose parameter is of type {@code String}.
*
* @param containing the containing type
* @param element the element
* @return the type of the element as viewed from the containing type
* @throws IllegalArgumentException if the element is not a valid one
* for the given type
*/
TypeMirror asMemberOf(DeclaredType containing, Element element);
}
@@ -1,159 +0,0 @@
/*
* Copyright (c) 2006, 2008, 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 javax.tools;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
/**
* File abstraction for tools. In this context, <em>file</em> means
* an abstraction of regular files and other sources of data. For
* example, a file object can be used to represent regular files,
* memory cache, or data in databases.
*
* <p>All methods in this interface might throw a SecurityException if
* a security exception occurs.
*
* <p>Unless explicitly allowed, all methods in this interface might
* throw a NullPointerException if given a {@code null} argument.
*
* @author Peter von der Ah&eacute;
* @author Jonathan Gibbons
* @since 1.6
*/
public interface FileObject {
/**
* Returns a URI identifying this file object.
* @return a URI
*/
URI toUri();
/**
* Gets a user-friendly name for this file object. The exact
* value returned is not specified but implementations should take
* care to preserve names as given by the user. For example, if
* the user writes the filename {@code "BobsApp\Test.java"} on
* the command line, this method should return {@code
* "BobsApp\Test.java"} whereas the {@linkplain #toUri toUri}
* method might return {@code
* file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java}.
*
* @return a user-friendly name
*/
String getName();
/**
* Gets an InputStream for this file object.
*
* @return an InputStream
* @throws IllegalStateException if this file object was
* opened for writing and does not support reading
* @throws UnsupportedOperationException if this kind of file
* object does not support byte access
* @throws IOException if an I/O error occurred
*/
InputStream openInputStream() throws IOException;
/**
* Gets an OutputStream for this file object.
*
* @return an OutputStream
* @throws IllegalStateException if this file object was
* opened for reading and does not support writing
* @throws UnsupportedOperationException if this kind of
* file object does not support byte access
* @throws IOException if an I/O error occurred
*/
OutputStream openOutputStream() throws IOException;
/**
* Gets a reader for this object. The returned reader will
* replace bytes that cannot be decoded with the default
* translation character. In addition, the reader may report a
* diagnostic unless {@code ignoreEncodingErrors} is true.
*
* @param ignoreEncodingErrors ignore encoding errors if true
* @return a Reader
* @throws IllegalStateException if this file object was
* opened for writing and does not support reading
* @throws UnsupportedOperationException if this kind of
* file object does not support character access
* @throws IOException if an I/O error occurred
*/
Reader openReader(boolean ignoreEncodingErrors) throws IOException;
/**
* Gets the character content of this file object, if available.
* Any byte that cannot be decoded will be replaced by the default
* translation character. In addition, a diagnostic may be
* reported unless {@code ignoreEncodingErrors} is true.
*
* @param ignoreEncodingErrors ignore encoding errors if true
* @return a CharSequence if available; {@code null} otherwise
* @throws IllegalStateException if this file object was
* opened for writing and does not support reading
* @throws UnsupportedOperationException if this kind of
* file object does not support character access
* @throws IOException if an I/O error occurred
*/
CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException;
/**
* Gets a Writer for this file object.
*
* @return a Writer
* @throws IllegalStateException if this file object was
* opened for reading and does not support writing
* @throws UnsupportedOperationException if this kind of
* file object does not support character access
* @throws IOException if an I/O error occurred
*/
Writer openWriter() throws IOException;
/**
* Gets the time this file object was last modified. The time is
* measured in milliseconds since the epoch (00:00:00 GMT, January
* 1, 1970).
*
* @return the time this file object was last modified; or 0 if
* the file object does not exist, if an I/O error occurred, or if
* the operation is not supported
*/
long getLastModified();
/**
* Deletes this file object. In case of errors, returns false.
* @return true if and only if this file object is successfully
* deleted; false otherwise
*/
boolean delete();
}
@@ -1,130 +0,0 @@
/*
* 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 javax.tools;
import javax.lang.model.element.NestingKind;
import javax.lang.model.element.Modifier;
/**
* File abstraction for tools operating on Java&trade; programming language
* source and class files.
*
* <p>All methods in this interface might throw a SecurityException if
* a security exception occurs.
*
* <p>Unless explicitly allowed, all methods in this interface might
* throw a NullPointerException if given a {@code null} argument.
*
* @author Peter von der Ah&eacute;
* @author Jonathan Gibbons
* @see JavaFileManager
* @since 1.6
*/
public interface JavaFileObject extends FileObject {
/**
* Kinds of JavaFileObjects.
*/
enum Kind {
/**
* Source files written in the Java programming language. For
* example, regular files ending with {@code .java}.
*/
SOURCE(".java"),
/**
* Class files for the Java Virtual Machine. For example,
* regular files ending with {@code .class}.
*/
CLASS(".class"),
/**
* HTML files. For example, regular files ending with {@code
* .html}.
*/
HTML(".html"),
/**
* Any other kind.
*/
OTHER("");
/**
* The extension which (by convention) is normally used for
* this kind of file object. If no convention exists, the
* empty string ({@code ""}) is used.
*/
public final String extension;
private Kind(String extension) {
extension.getClass(); // null check
this.extension = extension;
}
};
/**
* Gets the kind of this file object.
*
* @return the kind
*/
Kind getKind();
/**
* Checks if this file object is compatible with the specified
* simple name and kind. A simple name is a single identifier
* (not qualified) as defined in
* <cite>The Java&trade; Language Specification</cite>,
* section 6.2 "Names and Identifiers".
*
* @param simpleName a simple name of a class
* @param kind a kind
* @return {@code true} if this file object is compatible; false
* otherwise
*/
boolean isNameCompatible(String simpleName, Kind kind);
/**
* Provides a hint about the nesting level of the class
* represented by this file object. This method may return
* {@link NestingKind#MEMBER} to mean
* {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.
* If the nesting level is not known or this file object does not
* represent a class file this method returns {@code null}.
*
* @return the nesting kind, or {@code null} if the nesting kind
* is not known
*/
NestingKind getNestingKind();
/**
* Provides a hint about the access level of the class represented
* by this file object. If the access level is not known or if
* this file object does not represent a class file this method
* returns {@code null}.
*
* @return the access level
*/
Modifier getAccessLevel();
}
@@ -1,216 +0,0 @@
/*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.io.*;
import java.net.URI;
import java.nio.CharBuffer;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject.Kind;
/**
* Provides simple implementations for most methods in JavaFileObject.
* This class is designed to be subclassed and used as a basis for
* JavaFileObject implementations. Subclasses can override the
* implementation and specification of any method of this class as
* long as the general contract of JavaFileObject is obeyed.
*
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public class SimpleJavaFileObject implements JavaFileObject {
/**
* A URI for this file object.
*/
protected final URI uri;
/**
* The kind of this file object.
*/
protected final Kind kind;
/**
* Construct a SimpleJavaFileObject of the given kind and with the
* given URI.
*
* @param uri the URI for this file object
* @param kind the kind of this file object
*/
protected SimpleJavaFileObject(URI uri, Kind kind) {
// null checks
uri.getClass();
kind.getClass();
if (uri.getPath() == null)
throw new IllegalArgumentException("URI must have a path: " + uri);
this.uri = uri;
this.kind = kind;
}
public URI toUri() {
return uri;
}
public String getName() {
return toUri().getPath();
}
/**
* This implementation always throws {@linkplain
* UnsupportedOperationException}. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*/
public InputStream openInputStream() throws IOException {
throw new UnsupportedOperationException();
}
/**
* This implementation always throws {@linkplain
* UnsupportedOperationException}. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*/
public OutputStream openOutputStream() throws IOException {
throw new UnsupportedOperationException();
}
/**
* Wraps the result of {@linkplain #getCharContent} in a Reader.
* Subclasses can change this behavior as long as the contract of
* {@link FileObject} is obeyed.
*
* @param ignoreEncodingErrors {@inheritDoc}
* @return a Reader wrapping the result of getCharContent
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
CharSequence charContent = getCharContent(ignoreEncodingErrors);
if (charContent == null)
throw new UnsupportedOperationException();
if (charContent instanceof CharBuffer) {
CharBuffer buffer = (CharBuffer)charContent;
if (buffer.hasArray())
return new CharArrayReader(buffer.array());
}
return new StringReader(charContent.toString());
}
/**
* This implementation always throws {@linkplain
* UnsupportedOperationException}. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*/
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
throw new UnsupportedOperationException();
}
/**
* Wraps the result of openOutputStream in a Writer. Subclasses
* can change this behavior as long as the contract of {@link
* FileObject} is obeyed.
*
* @return a Writer wrapping the result of openOutputStream
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Writer openWriter() throws IOException {
return new OutputStreamWriter(openOutputStream());
}
/**
* This implementation returns {@code 0L}. Subclasses can change
* this behavior as long as the contract of {@link FileObject} is
* obeyed.
*
* @return {@code 0L}
*/
public long getLastModified() {
return 0L;
}
/**
* This implementation does nothing. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*
* @return {@code false}
*/
public boolean delete() {
return false;
}
/**
* @return {@code this.kind}
*/
public Kind getKind() {
return kind;
}
/**
* This implementation compares the path of its URI to the given
* simple name. This method returns true if the given kind is
* equal to the kind of this object, and if the path is equal to
* {@code simpleName + kind.extension} or if it ends with {@code
* "/" + simpleName + kind.extension}.
*
* <p>This method calls {@link #getKind} and {@link #toUri} and
* does not access the fields {@link #uri} and {@link #kind}
* directly.
*
* <p>Subclasses can change this behavior as long as the contract
* of {@link JavaFileObject} is obeyed.
*/
public boolean isNameCompatible(String simpleName, Kind kind) {
String baseName = simpleName + kind.extension;
return kind.equals(getKind())
&& (baseName.equals(toUri().getPath())
|| toUri().getPath().endsWith("/" + baseName));
}
/**
* This implementation returns {@code null}. Subclasses can
* change this behavior as long as the contract of
* {@link JavaFileObject} is obeyed.
*/
public NestingKind getNestingKind() { return null; }
/**
* This implementation returns {@code null}. Subclasses can
* change this behavior as long as the contract of
* {@link JavaFileObject} is obeyed.
*/
public Modifier getAccessLevel() { return null; }
@Override
public String toString() {
return getClass().getName() + "[" + toUri() + "]";
}
}
+1
View File
@@ -0,0 +1 @@
/build

Some files were not shown because too many files have changed in this diff Show More