List of usage examples for org.eclipse.jdt.internal.core OpenableElementInfo setChildren
public void setChildren(IJavaElement[] children)
From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFile.java
License:Open Source License
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable/*from ww w .jav a 2s. c o m*/ * @see org.eclipse.jdt.core.Signature */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, File underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo(/*underlyingResource*/ null); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(new IJavaElement[] {}); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] { type }); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; }
From source file:com.codenvy.ide.ext.java.server.internal.core.PackageFragment.java
License:Open Source License
/** * @see Openable//from w ww . j a v a 2 s. co m */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, File underlyingResource) throws JavaModelException { // add compilation units/class files from resources HashSet vChildren = new HashSet(); int kind = getKind(); PackageFragmentRoot root = getPackageFragmentRoot(); char[][] inclusionPatterns = root.fullInclusionPatternChars(); char[][] exclusionPatterns = root.fullExclusionPatternChars(); File[] members = underlyingResource.listFiles(); { 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++) { File child = members[i]; if (child.isFile() && !Util.isExcluded(new Path(child.getAbsolutePath()), inclusionPatterns, exclusionPatterns, false)) { IJavaElement childElement; if (kind == IPackageFragmentRoot.K_SOURCE && Util.isValidCompilationUnitName(child.getName(), sourceLevel, complianceLevel)) { childElement = new CompilationUnit(this, manager, 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); } } } } } 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; }
From source file:org.eclipse.che.jdt.internal.core.JavaProject.java
License:Open Source License
@Override protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, File underlyingResource) throws JavaModelException { // cannot refresh cp markers on opening (emulate cp check on startup) since can create deadlocks (see bug 37274) IClasspathEntry[] resolvedClasspath = getResolvedClasspath(); // compute the pkg fragment roots info.setChildren(computePackageFragmentRoots(resolvedClasspath, false, null /*no reverse map*/)); return true;/*from w ww . java 2 s. c om*/ }
From source file:org.eclipse.che.jdt.internal.core.PackageFragmentRoot.java
License:Open Source License
/** * Compute the package fragment children of this package fragment root. * * @throws JavaModelException/*from w w w.j a va 2 s .c o m*/ * The resource associated with this package fragment root does not exist */ protected boolean computeChildren(OpenableElementInfo info, File underlyingResource) throws JavaModelException { // Note the children are not opened (so not added to newElements) for a regular package fragment root // However they are opened for a Jar package fragment root (see JarPackageFragmentRoot#computeChildren) try { // the underlying resource may be a folder or a project (in the case that the project folder // is actually the package fragment root) if (underlyingResource.isDirectory() || underlyingResource.isFile()) { ArrayList vChildren = new ArrayList(5); // IContainer rootFolder = (IContainer) underlyingResource; char[][] inclusionPatterns = fullInclusionPatternChars(); char[][] exclusionPatterns = fullExclusionPatternChars(); computeFolderChildren(underlyingResource, !Util.isExcluded(new Path(underlyingResource.getAbsolutePath()), inclusionPatterns, exclusionPatterns, true), CharOperation.NO_STRINGS, vChildren, inclusionPatterns, exclusionPatterns); IJavaElement[] children = new IJavaElement[vChildren.size()]; vChildren.toArray(children); info.setChildren(children); } } catch (JavaModelException e) { //problem resolving children; structure remains unknown info.setChildren(new IJavaElement[] {}); throw e; } return true; }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
/** * @see Openable//from w w w . j av a2 s. c om */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { // cannot refresh cp markers on opening (emulate cp check on startup) since can create deadlocks (see bug 37274) IClasspathEntry[] resolvedClasspath = getResolvedClasspath(); // compute the pkg fragment roots info.setChildren(computePackageFragmentRoots(resolvedClasspath, false, null /*no reverse map*/)); return true; }
From source file:org.eclipse.jdt.internal.core.PackageFragment.java
License:Open Source License
/** * @see Openable/* w w w. j a va 2s. c o m*/ */ 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)) { // GROOVY start /* old { childElement = new CompilationUnit(this, child.getName(), DefaultWorkingCopyOwner.PRIMARY); } new */ childElement = LanguageSupportFactory.newCompilationUnit(this, child.getName(), DefaultWorkingCopyOwner.PRIMARY); // GROOVY end 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; }
From source file:org.jboss.tools.seam.internal.core.project.facet.WtpUtils.java
License:Open Source License
public static void reconfigure(IProject project, IProgressMonitor monitor) throws CoreException { if (project == null || !project.exists() || !project.isOpen() || !project.hasNature(JavaCore.NATURE_ID)) { return;/*from www .j a va 2 s .c om*/ } project.refreshLocal(IResource.DEPTH_INFINITE, monitor); IJavaProject javaProject = JavaCore.create(project); if (javaProject != null && javaProject.exists() && javaProject.isOpen() && javaProject instanceof JavaProject) { Object object = ((JavaProject) javaProject).getElementInfo(); if (object instanceof OpenableElementInfo) { // copied from JavaProject.buildStructure(...) OpenableElementInfo info = (OpenableElementInfo) object; IClasspathEntry[] resolvedClasspath = ((JavaProject) javaProject).getResolvedClasspath(); IPackageFragmentRoot[] children = ((JavaProject) javaProject) .computePackageFragmentRoots(resolvedClasspath, false, null /* no reverse map */); info.setChildren(children); ((JavaProject) javaProject).getPerProjectInfo().rememberExternalLibTimestamps(); } } }