本文整理汇总了Java中org.eclipse.jdt.internal.core.util.Util.isExcluded方法的典型用法代码示例。如果您正苦于以下问题:Java Util.isExcluded方法的具体用法?Java Util.isExcluded怎么用?Java Util.isExcluded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.core.util.Util
的用法示例。
在下文中一共展示了Util.isExcluded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateExistence
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
protected IStatus validateExistence(IResource underlyingResource) {
// check that the name of the package is valid (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=108456)
if (!isValidPackageName())
return newDoesNotExistStatus();
// check whether this pkg can be opened
if (underlyingResource != null && !resourceExists(underlyingResource))
return newDoesNotExistStatus();
// check that it is not excluded (https://bugs.eclipse.org/bugs/show_bug.cgi?id=138577)
int kind;
try {
kind = getKind();
} catch (JavaModelException e) {
return e.getStatus();
}
if (kind == IPackageFragmentRoot.K_SOURCE && Util.isExcluded(this))
return newDoesNotExistStatus();
return JavaModelStatus.VERIFIED_OK;
}
示例2: prepareDeltas
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* Sets the deltas to register the changes resulting from this operation
* for this source element and its destination.
* If the operation is a cross project operation<ul>
* <li>On a copy, the delta should be rooted in the dest project
* <li>On a move, two deltas are generated<ul>
* <li>one rooted in the source project
* <li>one rooted in the destination project
* <li> When a CU is being overwritten, the delta on the destination will be of type F_CONTENT </ul></ul>
* If the operation is rooted in a single project, the delta is rooted in that project
*
*/
protected void prepareDeltas(IJavaElement sourceElement, IJavaElement destinationElement, boolean isMove, boolean overWriteCU) {
if (Util.isExcluded(sourceElement) || Util.isExcluded(destinationElement)) return;
IJavaProject destProject = destinationElement.getJavaProject();
if (isMove) {
IJavaProject sourceProject = sourceElement.getJavaProject();
getDeltaFor(sourceProject).movedFrom(sourceElement, destinationElement);
if (!overWriteCU) {
getDeltaFor(destProject).movedTo(destinationElement, sourceElement);
return;
}
} else {
if (!overWriteCU) {
getDeltaFor(destProject).added(destinationElement);
return;
}
}
getDeltaFor(destinationElement.getJavaProject()).changed(destinationElement, IJavaElementDelta.F_CONTENT);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:32,代码来源:CopyResourceElementsOperation.java
示例3: getPkgFragmentRoot
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* Returns the package fragment root that contains the given resource path.
*/
private PackageFragmentRoot getPkgFragmentRoot(String pathString) {
IPath path= new Path(pathString);
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i= 0, max= projects.length; i < max; i++) {
try {
IProject project = projects[i];
if (!project.isAccessible()
|| !project.hasNature(JavaCore.NATURE_ID)) continue;
IJavaProject javaProject= this.javaModel.getJavaProject(project);
IPackageFragmentRoot[] roots= javaProject.getPackageFragmentRoots();
for (int j= 0, rootCount= roots.length; j < rootCount; j++) {
PackageFragmentRoot root= (PackageFragmentRoot)roots[j];
if (root.internalPath().isPrefixOf(path) && !Util.isExcluded(path, root.fullInclusionPatternChars(), root.fullExclusionPatternChars(), false)) {
return root;
}
}
} catch (CoreException e) {
// CoreException from hasNature - should not happen since we check that the project is accessible
// JavaModelException from getPackageFragmentRoots - a problem occured while accessing project: nothing we can do, ignore
}
}
return null;
}
示例4: isOnClasspathEntry
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private boolean isOnClasspathEntry(IPath elementPath, boolean isFolderPath, boolean isPackageFragmentRoot, IClasspathEntry entry) {
IPath entryPath = entry.getPath();
if (isPackageFragmentRoot) {
// package fragment roots must match exactly entry pathes (no exclusion there)
if (entryPath.equals(elementPath))
return true;
} else {
if (entryPath.isPrefixOf(elementPath)
&& !Util.isExcluded(elementPath, ((ClasspathEntry)entry).fullInclusionPatternChars(), ((ClasspathEntry)entry).fullExclusionPatternChars(), isFolderPath))
return true;
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=276373
if (entryPath.isAbsolute()
&& entryPath.equals(ResourcesPlugin.getWorkspace().getRoot().getLocation().append(elementPath))) {
return true;
}
return false;
}
示例5: findSourceFile
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
protected SourceFile findSourceFile(IFile file, boolean mustExist) {
if (mustExist && !file.exists()) return null;
// assumes the file exists in at least one of the source folders & is not excluded
ClasspathMultiDirectory md = this.sourceLocations[0];
if (this.sourceLocations.length > 1) {
IPath sourceFileFullPath = file.getFullPath();
for (int j = 0, m = this.sourceLocations.length; j < m; j++) {
if (this.sourceLocations[j].sourceFolder.getFullPath().isPrefixOf(sourceFileFullPath)) {
md = this.sourceLocations[j];
if (md.exclusionPatterns == null && md.inclusionPatterns == null)
break;
if (!Util.isExcluded(file, md.inclusionPatterns, md.exclusionPatterns))
break;
}
}
}
return new SourceFile(file, md);
}
示例6: getCompilationUnits
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* @see IPackageFragment#getCompilationUnits(WorkingCopyOwner)
*/
public ICompilationUnit[] getCompilationUnits(WorkingCopyOwner owner) {
ICompilationUnit[] workingCopies = JavaModelManager.getJavaModelManager().getWorkingCopies(owner, false/*don't add primary*/);
if (workingCopies == null) return JavaModelManager.NO_WORKING_COPY;
int length = workingCopies.length;
ICompilationUnit[] result = new ICompilationUnit[length];
int index = 0;
for (int i = 0; i < length; i++) {
ICompilationUnit wc = workingCopies[i];
if (equals(wc.getParent()) && !Util.isExcluded(wc)) { // 59933 - excluded wc shouldn't be answered back
result[index++] = wc;
}
}
if (index != length) {
System.arraycopy(result, 0, result = new ICompilationUnit[index], 0, index);
}
return result;
}
示例7: execute
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public boolean execute(IProgressMonitor progressMonitor) {
if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
/* ensure no concurrent write access to index */
Index index = this.manager.getIndex(this.containerPath, true, /*reuse index file*/ false /*create if none*/);
if (index == null) return true;
ReadWriteMonitor monitor = index.monitor;
if (monitor == null) return true; // index got deleted since acquired
try {
monitor.enterRead(); // ask permission to read
String containerRelativePath = Util.relativePath(this.folderPath, this.containerPath.segmentCount());
String[] paths = index.queryDocumentNames(containerRelativePath);
// all file names belonging to the folder or its subfolders and that are not excluded (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32607)
if (paths != null) {
if (this.exclusionPatterns == null && this.inclusionPatterns == null) {
for (int i = 0, max = paths.length; i < max; i++) {
this.manager.remove(paths[i], this.containerPath); // write lock will be acquired by the remove operation
}
} else {
for (int i = 0, max = paths.length; i < max; i++) {
String documentPath = this.containerPath.toString() + '/' + paths[i];
if (!Util.isExcluded(new Path(documentPath), this.inclusionPatterns, this.exclusionPatterns, false))
this.manager.remove(paths[i], this.containerPath); // write lock will be acquired by the remove operation
}
}
}
} catch (IOException e) {
if (JobManager.VERBOSE) {
Util.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
return false;
} finally {
monitor.exitRead(); // free read lock
}
return true;
}
示例8: checkForClassFileChanges
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
protected boolean checkForClassFileChanges(IResourceDelta binaryDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException {
IResource resource = binaryDelta.getResource();
// remember that if inclusion & exclusion patterns change then a full build is done
boolean isExcluded = (md.exclusionPatterns != null || md.inclusionPatterns != null)
&& Util.isExcluded(resource, md.inclusionPatterns, md.exclusionPatterns);
switch(resource.getType()) {
case IResource.FOLDER :
if (isExcluded && md.inclusionPatterns == null)
return true; // no need to go further with this delta since its children cannot be included
IResourceDelta[] children = binaryDelta.getAffectedChildren();
for (int i = 0, l = children.length; i < l; i++)
if (!checkForClassFileChanges(children[i], md, segmentCount))
return false;
return true;
case IResource.FILE :
if (!isExcluded && org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(resource.getName())) {
// perform full build if a managed class file has been changed
IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
if (this.newState.isKnownType(typePath.toString())) {
if (JavaBuilder.DEBUG)
System.out.println("MUST DO FULL BUILD. Found change to class file " + typePath); //$NON-NLS-1$
return false;
}
return true;
}
}
return true;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:30,代码来源:IncrementalImageBuilder.java
示例9: exists
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public boolean exists() {
// super.exist() only checks for the parent and the resource existence
// so also ensure that:
// - the package is not excluded (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138577)
// - its name is valide (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=108456)
return super.exists() && !Util.isExcluded(this) && isValidPackageName();
}
示例10: determineAffectedPackageFragments
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private ArrayList determineAffectedPackageFragments(IPath location) throws JavaModelException {
ArrayList fragments = new ArrayList();
// see if this will cause any package fragments to be affected
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource resource = null;
if (location != null) {
resource = workspace.getRoot().findMember(location);
}
if (resource != null && resource.getType() == IResource.FOLDER) {
IFolder folder = (IFolder) resource;
// only changes if it actually existed
IClasspathEntry[] classpath = this.project.getExpandedClasspath();
for (int i = 0; i < classpath.length; i++) {
IClasspathEntry entry = classpath[i];
IPath path = classpath[i].getPath();
if (entry.getEntryKind() != IClasspathEntry.CPE_PROJECT && path.isPrefixOf(location) && !path.equals(location)) {
IPackageFragmentRoot[] roots = this.project.computePackageFragmentRoots(classpath[i]);
PackageFragmentRoot root = (PackageFragmentRoot) roots[0];
// now the output location becomes a package fragment - along with any subfolders
ArrayList folders = new ArrayList();
folders.add(folder);
collectAllSubfolders(folder, folders);
Iterator elements = folders.iterator();
int segments = path.segmentCount();
while (elements.hasNext()) {
IFolder f = (IFolder) elements.next();
IPath relativePath = f.getFullPath().removeFirstSegments(segments);
String[] pkgName = relativePath.segments();
IPackageFragment pkg = root.getPackageFragment(pkgName);
if (!Util.isExcluded(pkg))
fragments.add(pkg);
}
}
}
}
return fragments;
}
示例11: executeOperation
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* Creates a compilation unit.
*
* @exception JavaModelException if unable to create the compilation unit.
*/
protected void executeOperation() throws JavaModelException {
try {
beginTask(Messages.operation_createUnitProgress, 2);
JavaElementDelta delta = newJavaElementDelta();
ICompilationUnit unit = getCompilationUnit();
IPackageFragment pkg = (IPackageFragment) getParentElement();
IContainer folder = (IContainer) pkg.getResource();
worked(1);
IFile compilationUnitFile = folder.getFile(new Path(this.name));
if (compilationUnitFile.exists()) {
// update the contents of the existing unit if fForce is true
if (this.force) {
IBuffer buffer = unit.getBuffer();
if (buffer == null) return;
buffer.setContents(this.source);
unit.save(new NullProgressMonitor(), false);
this.resultElements = new IJavaElement[] {unit};
if (!Util.isExcluded(unit)
&& unit.getParent().exists()) {
for (int i = 0; i < this.resultElements.length; i++) {
delta.changed(this.resultElements[i], IJavaElementDelta.F_CONTENT);
}
addDelta(delta);
}
} else {
throw new JavaModelException(new JavaModelStatus(
IJavaModelStatusConstants.NAME_COLLISION,
Messages.bind(Messages.status_nameCollision, compilationUnitFile.getFullPath().toString())));
}
} else {
try {
String encoding = null;
try {
encoding = folder.getDefaultCharset(); // get folder encoding as file is not accessible
}
catch (CoreException ce) {
// use no encoding
}
InputStream stream = new ByteArrayInputStream(encoding == null ? this.source.getBytes() : this.source.getBytes(encoding));
createFile(folder, unit.getElementName(), stream, this.force);
this.resultElements = new IJavaElement[] {unit};
if (!Util.isExcluded(unit)
&& unit.getParent().exists()) {
for (int i = 0; i < this.resultElements.length; i++) {
delta.added(this.resultElements[i]);
}
addDelta(delta);
}
} catch (IOException e) {
throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
}
}
worked(1);
} finally {
done();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:63,代码来源:CreateCompilationUnitOperation.java
示例12: determineIfOnClasspath
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* Returns the package fragment root represented by the resource, or
* the package fragment the given resource is located in, or <code>null</code>
* if the given resource is not on the classpath of the given project.
*/
public static IJavaElement determineIfOnClasspath(IResource resource, IJavaProject project) {
IPath resourcePath = resource.getFullPath();
boolean isExternal = ExternalFoldersManager.isInternalPathForExternalFolder(resourcePath);
if (isExternal)
resourcePath = resource.getLocation();
try {
JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
boolean isJavaLike = org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment());
IClasspathEntry[] entries = isJavaLike ? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
: ((JavaProject)project).getResolvedClasspath();
int length = entries.length;
if (length > 0) {
String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
for (int i = 0; i < length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
IPath rootPath = entry.getPath();
if (rootPath.equals(resourcePath)) {
if (isJavaLike)
return null;
return project.getPackageFragmentRoot(resource);
} else if (rootPath.isPrefixOf(resourcePath)) {
// allow creation of package fragment if it contains a .java file that is included
if (!Util.isExcluded(resource, ((ClasspathEntry)entry).fullInclusionPatternChars(), ((ClasspathEntry)entry).fullExclusionPatternChars())) {
// given we have a resource child of the root, it cannot be a JAR pkg root
PackageFragmentRoot root =
isExternal ?
new ExternalPackageFragmentRoot(rootPath, (JavaProject) project) :
(PackageFragmentRoot) ((JavaProject) project).getFolderPackageFragmentRoot(rootPath);
if (root == null) return null;
IPath pkgPath = resourcePath.removeFirstSegments(rootPath.segmentCount());
if (resource.getType() == IResource.FILE) {
// if the resource is a file, then remove the last segment which
// is the file name in the package
pkgPath = pkgPath.removeLastSegments(1);
}
String[] pkgName = pkgPath.segments();
// if package name is in the cache, then it has already been validated
// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141)
if (allPkgFragmentsCache != null && allPkgFragmentsCache.containsKey(pkgName))
return root.getPackageFragment(pkgName);
if (pkgName.length != 0 && JavaConventions.validatePackageName(Util.packageName(pkgPath, sourceLevel, complianceLevel), sourceLevel, complianceLevel).getSeverity() == IStatus.ERROR) {
return null;
}
return root.getPackageFragment(pkgName);
}
}
}
}
} catch (JavaModelException npe) {
return null;
}
return null;
}
示例13: isExcluded
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
protected boolean isExcluded(IResource resource) {
if (this.exclusionPatterns != null || this.inclusionPatterns != null)
if (this.sourceFolder.equals(this.binaryFolder))
return Util.isExcluded(resource, this.inclusionPatterns, this.exclusionPatterns);
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:7,代码来源:ClasspathMultiDirectory.java
示例14: executeOperation
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* Execute the operation - creates the new package fragment and any
* side effect package fragments.
*
* @exception JavaModelException if the operation is unable to complete
*/
protected void executeOperation() throws JavaModelException {
try {
JavaElementDelta delta = null;
PackageFragmentRoot root = (PackageFragmentRoot) getParentElement();
beginTask(Messages.operation_createPackageFragmentProgress, this.pkgName.length);
IContainer parentFolder = (IContainer) root.resource();
String[] sideEffectPackageName = CharOperation.NO_STRINGS;
ArrayList results = new ArrayList(this.pkgName.length);
char[][] inclusionPatterns = root.fullInclusionPatternChars();
char[][] exclusionPatterns = root.fullExclusionPatternChars();
int i;
for (i = 0; i < this.pkgName.length; i++) {
String subFolderName = this.pkgName[i];
sideEffectPackageName = Util.arrayConcat(sideEffectPackageName, subFolderName);
IResource subFolder = parentFolder.findMember(subFolderName);
if (subFolder == null) {
createFolder(parentFolder, subFolderName, this.force);
parentFolder = parentFolder.getFolder(new Path(subFolderName));
IPackageFragment addedFrag = root.getPackageFragment(sideEffectPackageName);
if (!Util.isExcluded(parentFolder, inclusionPatterns, exclusionPatterns)) {
if (delta == null) {
delta = newJavaElementDelta();
}
delta.added(addedFrag);
}
results.add(addedFrag);
} else {
parentFolder = (IContainer) subFolder;
}
worked(1);
}
if (results.size() > 0) {
this.resultElements = new IJavaElement[results.size()];
results.toArray(this.resultElements);
if (delta != null) {
addDelta(delta);
}
}
} finally {
done();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:CreatePackageFragmentOperation.java
示例15: buildStructure
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
* @see Openable
*/
protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
// add compilation units/class files from resources
HashSet vChildren = new HashSet();
int kind = getKind();
try {
PackageFragmentRoot root = getPackageFragmentRoot();
char[][] inclusionPatterns = root.fullInclusionPatternChars();
char[][] exclusionPatterns = root.fullExclusionPatternChars();
IResource[] members = ((IContainer) underlyingResource).members();
int length = members.length;
if (length > 0) {
IJavaProject project = getJavaProject();
String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
for (int i = 0; i < length; i++) {
IResource child = members[i];
if (child.getType() != IResource.FOLDER
&& !Util.isExcluded(child, inclusionPatterns, exclusionPatterns)) {
IJavaElement childElement;
if (kind == IPackageFragmentRoot.K_SOURCE && Util.isValidCompilationUnitName(child.getName(), sourceLevel, complianceLevel)) {
childElement = new CompilationUnit(this, child.getName(), DefaultWorkingCopyOwner.PRIMARY);
vChildren.add(childElement);
} else if (kind == IPackageFragmentRoot.K_BINARY && Util.isValidClassFileName(child.getName(), sourceLevel, complianceLevel)) {
childElement = getClassFile(child.getName());
vChildren.add(childElement);
}
}
}
}
} catch (CoreException e) {
throw new JavaModelException(e);
}
if (kind == IPackageFragmentRoot.K_SOURCE) {
// add primary compilation units
ICompilationUnit[] primaryCompilationUnits = getCompilationUnits(DefaultWorkingCopyOwner.PRIMARY);
for (int i = 0, length = primaryCompilationUnits.length; i < length; i++) {
ICompilationUnit primary = primaryCompilationUnits[i];
vChildren.add(primary);
}
}
IJavaElement[] children = new IJavaElement[vChildren.size()];
vChildren.toArray(children);
info.setChildren(children);
return true;
}