Java Code Examples for org.eclipse.jdt.internal.compiler.batch.FileSystem#Classpath

The following examples show how to use org.eclipse.jdt.internal.compiler.batch.FileSystem#Classpath . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 2
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
protected void addNewEntry(ArrayList paths, String currentClasspathName,
		ArrayList currentRuleSpecs, String customEncoding,
		String destPath, boolean isSourceOnly,
		boolean rejectDestinationPathOnJars) {

	int rulesSpecsSize = currentRuleSpecs.size();
	AccessRuleSet accessRuleSet = null;
	if (rulesSpecsSize != 0) {
		AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
		boolean rulesOK = true;
		Iterator i = currentRuleSpecs.iterator();
		int j = 0;
		while (i.hasNext()) {
			String ruleSpec = (String) i.next();
			char key = ruleSpec.charAt(0);
			String pattern = ruleSpec.substring(1);
			if (pattern.length() > 0) {
				switch (key) {
					case '+':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(), 0);
						break;
					case '~':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.DiscouragedReference);
						break;
					case '-':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference);
						break;
					case '?':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
						break;
					default:
						rulesOK = false;
				}
			} else {
				rulesOK = false;
			}
		}
		if (rulesOK) {
    		accessRuleSet = new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
		} else {
			return;
		}
	}
	if (Main.NONE.equals(destPath)) {
		destPath = Main.NONE; // keep == comparison valid
	}
	if (rejectDestinationPathOnJars && destPath != null &&
			(currentClasspathName.endsWith(".jar") || //$NON-NLS-1$
				currentClasspathName.endsWith(".zip"))) { //$NON-NLS-1$
		throw new IllegalArgumentException(
				this.bind("configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$
							currentClasspathName));
		}
	FileSystem.Classpath currentClasspath = FileSystem.getClasspath(
			currentClasspathName,
			customEncoding,
			isSourceOnly,
			accessRuleSet,
			destPath);
	if (currentClasspath != null) {
		paths.add(currentClasspath);
	}
}
 
Example 8
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
protected void addNewEntry(ArrayList paths, String currentClasspathName,
		ArrayList currentRuleSpecs, String customEncoding,
		String destPath, boolean isSourceOnly,
		boolean rejectDestinationPathOnJars) {

	int rulesSpecsSize = currentRuleSpecs.size();
	AccessRuleSet accessRuleSet = null;
	if (rulesSpecsSize != 0) {
		AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
		boolean rulesOK = true;
		Iterator i = currentRuleSpecs.iterator();
		int j = 0;
		while (i.hasNext()) {
			String ruleSpec = (String) i.next();
			char key = ruleSpec.charAt(0);
			String pattern = ruleSpec.substring(1);
			if (pattern.length() > 0) {
				switch (key) {
					case '+':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(), 0);
						break;
					case '~':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.DiscouragedReference);
						break;
					case '-':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference);
						break;
					case '?':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
						break;
					default:
						rulesOK = false;
				}
			} else {
				rulesOK = false;
			}
		}
		if (rulesOK) {
    		accessRuleSet = new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
		} else {
			return;
		}
	}
	if (Main.NONE.equals(destPath)) {
		destPath = Main.NONE; // keep == comparison valid
	}
	if (rejectDestinationPathOnJars && destPath != null &&
			(currentClasspathName.endsWith(".jar") || //$NON-NLS-1$
				currentClasspathName.endsWith(".zip"))) { //$NON-NLS-1$
		throw new IllegalArgumentException(
				this.bind("configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$
							currentClasspathName));
		}
	FileSystem.Classpath currentClasspath = FileSystem.getClasspath(
			currentClasspathName,
			customEncoding,
			isSourceOnly,
			accessRuleSet,
			destPath);
	if (currentClasspath != null) {
		paths.add(currentClasspath);
	}
}
 
Example 9
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
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);
							}
						}
					}
				}
			}
		}
	}
}