📄 preprocessedprojectclasspathcontainer.java
字号:
/**
* Copyright (c) 2003-2006 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.internal.preprocessor;
import java.util.ArrayList;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import eclipseme.core.internal.EclipseMECorePlugin;
/**
* An implementation of the {@link IClasspathContainer} that provides a reference
* to the classpath of the project that is providing the preprocessing.
* <p />
* Copyright (c) 2003-2006 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.2 $
* <br>
* $Date: 2006/11/12 01:11:00 $
* <br>
* @author Craig Setera
*/
public class PreprocessedProjectClasspathContainer implements IClasspathContainer
{
private IProject project;
private IJavaProject javaProject;
/**
* Construct a classpath container for the specified project.
*
* @param project
*/
public PreprocessedProjectClasspathContainer(IJavaProject javaProject) {
super();
this.project = javaProject.getProject();
this.javaProject = javaProject;
}
/**
* @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
*/
public IClasspathEntry[] getClasspathEntries() {
ArrayList entries = new ArrayList();
try {
IClasspathEntry[] srcEntries = javaProject.getResolvedClasspath(true);
// Filter out all of the source entries
for (int i = 0; i < srcEntries.length; i++) {
if (srcEntries[i].getEntryKind() != IClasspathEntry.CPE_SOURCE) {
entries.add(srcEntries[i]);
}
}
} catch (CoreException e) {
EclipseMECorePlugin.log(IStatus.ERROR, e.getMessage(), e);
}
return (IClasspathEntry[]) entries.toArray(new IClasspathEntry[entries.size()]);
}
/**
* @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
*/
public String getDescription() {
return "Preprocessed Project [ " + project.getName() + " ]";
}
/**
* @see org.eclipse.jdt.core.IClasspathContainer#getKind()
*/
public int getKind() {
return K_APPLICATION;
}
/**
* @see org.eclipse.jdt.core.IClasspathContainer#getPath()
*/
public IPath getPath() {
return project.getFullPath();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -