本文整理汇总了Java中org.eclipse.jdt.internal.compiler.batch.FileSystem类的典型用法代码示例。如果您正苦于以下问题:Java FileSystem类的具体用法?Java FileSystem怎么用?Java FileSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileSystem类属于org.eclipse.jdt.internal.compiler.batch包,在下文中一共展示了FileSystem类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFileSystem
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
private FileSystem createFileSystem(File file) {
List<String> classpath = new ArrayList<String>();
classpath.addAll(Arrays.asList(System.getProperty("sun.boot.class.path").split(File.pathSeparator)));
for (Iterator<String> i = classpath.iterator(); i.hasNext();) {
if (FileSystem.getClasspath(i.next(), "UTF-8", null) == null) {
i.remove();
}
}
classpath.add("bin");
classpath.add("dist/lombok.jar");
classpath.add("lib/test/commons-logging-commons-logging.jar");
classpath.add("lib/test/org.slf4j-slf4j-api.jar");
classpath.add("lib/test/org.slf4j-slf4j-ext.jar");
classpath.add("lib/test/log4j-log4j.jar");
classpath.add("lib/test/org.apache.logging.log4j-log4j-api.jar");
classpath.add("lib/test/com.google.guava-guava.jar");
classpath.add("lib/test/com.google.code.findbugs-findbugs.jar");
return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8");
}
示例2: getEnclosedElements
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
@Override
public List<? extends Element> getEnclosedElements() {
PackageBinding binding = (PackageBinding)_binding;
LookupEnvironment environment = binding.environment;
char[][][] typeNames = null;
INameEnvironment nameEnvironment = binding.environment.nameEnvironment;
if (nameEnvironment instanceof FileSystem) {
typeNames = ((FileSystem) nameEnvironment).findTypeNames(binding.compoundName);
}
HashSet<Element> set = new HashSet<Element>();
if (typeNames != null) {
for (char[][] typeName : typeNames) {
ReferenceBinding type = environment.getType(typeName);
if (type != null && type.isValidBinding()) {
set.add(_env.getFactory().newElement(type));
}
}
}
ArrayList<Element> list = new ArrayList<Element>(set.size());
list.addAll(set);
return Collections.unmodifiableList(list);
}
示例3: createFileSystem
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
private FileSystem createFileSystem(File file) {
List<String> classpath = new ArrayList<String>();
classpath.addAll(Arrays.asList(System.getProperty("sun.boot.class.path").split(File.pathSeparator)));
for (Iterator<String> i = classpath.iterator(); i.hasNext();) {
if (FileSystem.getClasspath(i.next(), "UTF-8", null) == null) {
i.remove();
}
}
classpath.add("dist/lombok.jar");
classpath.add("lib/test/commons-logging-commons-logging.jar");
classpath.add("lib/test/org.slf4j-slf4j-api.jar");
classpath.add("lib/test/org.slf4j-slf4j-ext.jar");
classpath.add("lib/test/log4j-log4j.jar");
classpath.add("lib/test/org.apache.logging.log4j-log4j-api.jar");
return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8");
}
示例4: initNameEnvironment
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
private void initNameEnvironment() {
ArrayList<String> fileNames = new ArrayList<String>();
for (URL u : getURLs()) {
try {
fileNames.add(new File(u.toURI()).getAbsolutePath());
} catch (URISyntaxException e) {
logger.error(null, e);
}
}
for (String s : getCompilerClassPath()) {
if (!fileNames.contains(s)) {
fileNames.add(s);
}
}
environment = new FileSystem(
fileNames.toArray(new String[fileNames.size()]),
new String[] { }, null);
}
示例5: getPathsFrom
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
private Iterable<? extends File> getPathsFrom(String path) {
ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
ArrayList<File> files = new ArrayList<File>();
try {
this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
} catch (IllegalArgumentException e) {
return null;
}
for (FileSystem.Classpath classpath : paths) {
files.add(new File(classpath.getPath()));
}
return files;
}
示例6: getEndorsedDirsFrom
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
private Iterable<? extends File> getEndorsedDirsFrom(String path) {
ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
ArrayList<File> files = new ArrayList<File>();
try {
this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
} catch (IllegalArgumentException e) {
return null;
}
for (FileSystem.Classpath classpath : paths) {
files.add(new File(classpath.getPath()));
}
return files;
}
示例7: getExtdirsFrom
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
private Iterable<? extends File> getExtdirsFrom(String path) {
ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
ArrayList<File> files = new ArrayList<File>();
try {
this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
} catch (IllegalArgumentException e) {
return null;
}
for (FileSystem.Classpath classpath : paths) {
files.add(new File(classpath.getPath()));
}
return files;
}
示例8: NameEnv
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
public NameEnv(Map<String, String> files, Map<String, byte[]> classpath) {
this.files = files;
this.classpath = classpath;
packagesCache = new HashSet<String>();
Set<String> allFiles = new HashSet<String>();
allFiles.addAll(files.keySet());
allFiles.addAll(classpath.keySet());
for (String path : allFiles) {
while (!path.isEmpty()) {
path = FilenameUtils.getPath(path).replaceFirst("/$", "");
String pkg = path.replace("/", ".");
if (packagesCache.contains(pkg)) {
break;
} else {
packagesCache.add(pkg);
}
}
}
ArrayList<FileSystem.Classpath> cp = new ArrayList<FileSystem.Classpath>();
ArrayList<String> cps = new ArrayList<String>();
collectRunningVMBootclasspath(cp);
for (FileSystem.Classpath classpath1 : cp) {
cps.add(classpath1.getPath());
}
fileSystem = new FileSystem(cps.toArray(new String[cps.size()]), null, null);
}
示例9: DSpotJDTBatchCompiler
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
public DSpotJDTBatchCompiler(JDTBasedSpoonCompiler jdtCompiler, FileSystem environment ) {
super(jdtCompiler);
this.environment = environment;
}
示例10: getEnvironment
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
public FileSystem getEnvironment() {
return environment;
}
示例11: parse
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
/** Parse the given source units and class path and store it into the given output map */
public static INameEnvironment parse(
CompilerOptions options,
@NonNull List<ICompilationUnit> sourceUnits,
@NonNull List<String> classPath,
@NonNull Map<ICompilationUnit, CompilationUnitDeclaration> outputMap,
@Nullable LintClient client) {
INameEnvironment environment = new FileSystem(
classPath.toArray(new String[classPath.size()]), new String[0],
options.defaultEncoding);
IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
// Not used; we need the corresponding CompilationUnitDeclaration for the source
// units (the AST parsed from source) which we don't get access to here, so we
// instead subclass AST to get our hands on them.
}
};
NonGeneratingCompiler compiler = new NonGeneratingCompiler(environment, policy, options,
requestor, problemFactory, outputMap);
try {
compiler.compile(sourceUnits.toArray(new ICompilationUnit[sourceUnits.size()]));
} catch (OutOfMemoryError e) {
environment.cleanup();
// Since we're running out of memory, if it's all still held we could potentially
// fail attempting to log the failure. Actively get rid of the large ECJ data
// structure references first so minimize the chance of that
//noinspection UnusedAssignment
compiler = null;
//noinspection UnusedAssignment
environment = null;
//noinspection UnusedAssignment
requestor = null;
//noinspection UnusedAssignment
problemFactory = null;
//noinspection UnusedAssignment
policy = null;
String msg = "Ran out of memory analyzing .java sources with ECJ: Some lint checks "
+ "may not be accurate (missing type information from the compiler)";
if (client != null) {
// Don't log exception too; this isn't a compiler error per se where we
// need to pin point the exact unlucky code that asked for memory when it
// had already run out
client.log(null, msg);
} else {
System.out.println(msg);
}
} catch (Throwable t) {
if (client != null) {
CompilationUnitDeclaration currentUnit = compiler.getCurrentUnit();
if (currentUnit == null || currentUnit.getFileName() == null) {
client.log(t, "ECJ compiler crashed");
} else {
client.log(t, "ECJ compiler crashed processing %1$s",
new String(currentUnit.getFileName()));
}
} else {
t.printStackTrace();
}
environment.cleanup();
environment = null;
}
return environment;
}
示例12: collectRunningVMBootclasspath
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
public static void collectRunningVMBootclasspath(List bootclasspaths) {
/* no bootclasspath specified
* we can try to retrieve the default librairies of the VM used to run
* the batch compiler
*/
String javaversion = System.getProperty("java.version");//$NON-NLS-1$
if (javaversion != null && javaversion.equalsIgnoreCase("1.1.8")) { //$NON-NLS-1$
throw new IllegalStateException();
}
/*
* Handle >= JDK 1.2.2 settings: retrieve the bootclasspath
*/
// check bootclasspath properties for Sun, JRockit and Harmony VMs
String bootclasspathProperty = System.getProperty("sun.boot.class.path"); //$NON-NLS-1$
if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
// IBM J9 VMs
bootclasspathProperty = System.getProperty("vm.boot.class.path"); //$NON-NLS-1$
if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
// Harmony using IBM VME
bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path"); //$NON-NLS-1$
}
}
if ((bootclasspathProperty != null) && (bootclasspathProperty.length() != 0)) {
StringTokenizer tokenizer = new StringTokenizer(bootclasspathProperty, File.pathSeparator);
String token;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
FileSystem.Classpath currentClasspath = FileSystem.getClasspath(token, null, null);
if (currentClasspath != null) {
bootclasspaths.add(currentClasspath);
}
}
} else {
// try to get all jars inside the lib folder of the java home
final File javaHome = getJavaHome();
if (javaHome != null) {
File[] directoriesToCheck = null;
if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
directoriesToCheck = new File[] {
new File(javaHome, "../Classes"), //$NON-NLS-1$
};
} else {
// fall back to try to retrieve them out of the lib directory
directoriesToCheck = new File[] {
new File(javaHome, "lib") //$NON-NLS-1$
};
}
File[][] systemLibrariesJars = Main.getLibrariesFiles(directoriesToCheck);
if (systemLibrariesJars != null) {
for (int i = 0, max = systemLibrariesJars.length; i < max; i++) {
File[] current = systemLibrariesJars[i];
if (current != null) {
for (int j = 0, max2 = current.length; j < max2; j++) {
FileSystem.Classpath classpath =
FileSystem.getClasspath(current[j].getAbsolutePath(),
null, false, null, null);
if (classpath != null) {
bootclasspaths.add(classpath);
}
}
}
}
}
}
}
}
示例13: MainCompiler
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
public MainCompiler(JDTBasedSpoonCompiler jdtCompiler, FileSystem environment ) {
super(jdtCompiler);
this.environment = environment;
}
示例14: collectRunningVMBootclasspath
import org.eclipse.jdt.internal.compiler.batch.FileSystem; //导入依赖的package包/类
public static void collectRunningVMBootclasspath(List bootclasspaths) {
/* no bootclasspath specified
* we can try to retrieve the default librairies of the VM used to run
* the batch compiler
*/
String javaversion = System.getProperty("java.version");//$NON-NLS-1$
if (javaversion != null && javaversion.equalsIgnoreCase("1.1.8")) { //$NON-NLS-1$
throw new IllegalStateException();
}
/*
* Handle >= JDK 1.2.2 settings: retrieve the bootclasspath
*/
// check bootclasspath properties for Sun, JRockit and Harmony VMs
String bootclasspathProperty = System.getProperty("sun.boot.class.path"); //$NON-NLS-1$
if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
// IBM J9 VMs
bootclasspathProperty = System.getProperty("vm.boot.class.path"); //$NON-NLS-1$
if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
// Harmony using IBM VME
bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path"); //$NON-NLS-1$
}
}
if ((bootclasspathProperty != null) && (bootclasspathProperty.length() != 0)) {
StringTokenizer tokenizer = new StringTokenizer(bootclasspathProperty, File.pathSeparator);
String token;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
FileSystem.Classpath currentClasspath = FileSystem.getClasspath(token, null, null);
if (currentClasspath != null) {
bootclasspaths.add(currentClasspath);
}
}
} else {
// try to get all jars inside the lib folder of the java home
final File javaHome = getJavaHome();
if (javaHome != null) {
File[] directoriesToCheck = null;
if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
directoriesToCheck = new File[]{
new File(javaHome, "../Classes"), //$NON-NLS-1$
};
} else {
// fall back to try to retrieve them out of the lib directory
directoriesToCheck = new File[]{
new File(javaHome, "lib") //$NON-NLS-1$
};
}
File[][] systemLibrariesJars = Main.getLibrariesFiles(directoriesToCheck);
if (systemLibrariesJars != null) {
for (int i = 0, max = systemLibrariesJars.length; i < max; i++) {
File[] current = systemLibrariesJars[i];
if (current != null) {
for (int j = 0, max2 = current.length; j < max2; j++) {
FileSystem.Classpath classpath =
FileSystem.getClasspath(current[j].getAbsolutePath(),
null, false, null, null);
if (classpath != null) {
bootclasspaths.add(classpath);
}
}
}
}
}
}
}
}