List of usage examples for org.eclipse.jdt.internal.core JavaModel getWorkspaceTarget
public static IResource getWorkspaceTarget(IPath path)
null if no such resource exists. From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
/** * Creates a class path entry of the specified kind with the given path. *///from w ww . j ava 2 s .c om public ClasspathEntry(int contentKind, int entryKind, IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath specificOutputLocation, IClasspathEntry referencingEntry, boolean isExported, IAccessRule[] accessRules, boolean combineAccessRules, IClasspathAttribute[] extraAttributes) { this.contentKind = contentKind; this.entryKind = entryKind; this.path = path; this.inclusionPatterns = inclusionPatterns; this.exclusionPatterns = exclusionPatterns; this.referencingEntry = referencingEntry; int length; if (accessRules != null && (length = accessRules.length) > 0) { AccessRule[] rules = new AccessRule[length]; System.arraycopy(accessRules, 0, rules, 0, length); byte classpathEntryType; String classpathEntryName; JavaModelManager manager = JavaModelManager.getJavaModelManager(); if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling classpathEntryType = AccessRestriction.PROJECT; classpathEntryName = manager.intern(getPath().segment(0)); } else { classpathEntryType = AccessRestriction.LIBRARY; Object target = JavaModel.getWorkspaceTarget(path); if (target == null) { classpathEntryName = manager.intern(path.toOSString()); } else { classpathEntryName = manager.intern(path.makeRelative().toString()); } } this.accessRuleSet = new AccessRuleSet(rules, classpathEntryType, classpathEntryName); } // else { -- implicit! // this.accessRuleSet = null; // } this.combineAccessRules = combineAccessRules; this.extraAttributes = extraAttributes; if (inclusionPatterns != INCLUDE_ALL && inclusionPatterns.length > 0) { this.fullInclusionPatternChars = UNINIT_PATTERNS; } if (exclusionPatterns.length > 0) { this.fullExclusionPatternChars = UNINIT_PATTERNS; } this.sourceAttachmentPath = sourceAttachmentPath; this.sourceAttachmentRootPath = sourceAttachmentRootPath; this.specificOutputLocation = specificOutputLocation; this.isExported = isExported; }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.JavaSearchScope.java
License:Open Source License
public String toString() { StringBuffer result = new StringBuffer("JavaSearchScope on "); //$NON-NLS-1$ if (this.elements != null) { result.append("["); //$NON-NLS-1$ for (int i = 0, length = this.elements.size(); i < length; i++) { JavaElement element = (JavaElement) this.elements.get(i); result.append("\n\t"); //$NON-NLS-1$ result.append(element.toStringWithAncestors()); }//from w ww .j a v a 2 s. c om result.append("\n]"); //$NON-NLS-1$ } else { if (this.pathsCount == 0) { result.append("[empty scope]"); //$NON-NLS-1$ } else { result.append("["); //$NON-NLS-1$ String[] paths = new String[this.relativePaths.length]; int index = 0; for (int i = 0; i < this.relativePaths.length; i++) { String path = this.relativePaths[i]; if (path == null) continue; String containerPath; if (ExternalFoldersManager.isInternalPathForExternalFolder(new Path(this.containerPaths[i]))) { Object target = JavaModel.getWorkspaceTarget(new Path(this.containerPaths[i])); containerPath = ((IFolder) target).getLocation().toOSString(); } else { containerPath = this.containerPaths[i]; } if (path.length() > 0) { paths[index++] = containerPath + '/' + path; } else { paths[index++] = containerPath; } } System.arraycopy(paths, 0, paths = new String[index], 0, index); Util.sort(paths); for (int i = 0; i < index; i++) { result.append("\n\t"); //$NON-NLS-1$ result.append(paths[i]); } result.append("\n]"); //$NON-NLS-1$ } } return result.toString(); }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.JavaWorkspaceScope.java
License:Open Source License
/** * @see org.eclipse.jdt.internal.core.search.AbstractJavaSearchScope#packageFragmentRoot(String, int, String) *///from w w w . ja v a 2 s. co m public IPackageFragmentRoot packageFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPath) { HashMap rootInfos = JavaModelManager.getDeltaState().roots; DeltaProcessor.RootInfo rootInfo = null; if (jarPath != null) { IPath path = new Path(jarPath); rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path); } else { IPath path = new Path(resourcePathString); if (ExternalFoldersManager.isInternalPathForExternalFolder(path)) { IResource resource = JavaModel.getWorkspaceTarget( path.uptoSegment(2/*linked folders for external folders are always of size 2*/)); if (resource != null) rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(resource.getLocation()); } else { rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path); while (rootInfo == null && path.segmentCount() > 0) { path = path.removeLastSegments(1); rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path); } } } if (rootInfo == null) return null; return rootInfo.getPackageFragmentRoot(null/*no resource hint*/); }
From source file:org.eclipse.che.jdt.internal.core.search.JavaSearchScope.java
License:Open Source License
public String toString() { StringBuffer result = new StringBuffer("JavaSearchScope on "); //$NON-NLS-1$ if (this.elements != null) { result.append("["); //$NON-NLS-1$ for (int i = 0, length = this.elements.size(); i < length; i++) { JavaElement element = (JavaElement) this.elements.get(i); result.append("\n\t"); //$NON-NLS-1$ result.append(element.toStringWithAncestors()); }/*w ww . j a va 2 s .c om*/ result.append("\n]"); //$NON-NLS-1$ } else { if (this.pathsCount == 0) { result.append("[empty scope]"); //$NON-NLS-1$ } else { result.append("["); //$NON-NLS-1$ String[] paths = new String[this.relativePaths.length]; int index = 0; for (int i = 0; i < this.relativePaths.length; i++) { String path = this.relativePaths[i]; if (path == null) continue; String containerPath; if (ExternalFoldersManager.isInternalPathForExternalFolder(new Path(this.containerPaths[i]))) { Object target = JavaModel.getWorkspaceTarget(new Path(this.containerPaths[i])); containerPath = ((IFolder) target).getLocation().toOSString(); } else { containerPath = this.containerPaths[i]; } if (path.length() > 0) { paths[index++] = containerPath + '/' + path; } else { paths[index++] = containerPath; } } System.arraycopy(paths, 0, paths = new String[index], 0, index); org.eclipse.jdt.internal.core.util.Util.sort(paths); for (int i = 0; i < index; i++) { result.append("\n\t"); //$NON-NLS-1$ result.append(paths[i]); } result.append("\n]"); //$NON-NLS-1$ } } return result.toString(); }