protected IJavaElement getInitialJavaElement(IStructuredSelection selection) { IJavaElement jelem = null; if (selection != null && !selection.isEmpty()) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) selectedElement; jelem = (IJavaElement) adaptable.getAdapter(IJavaElement.class); if (jelem == null || !jelem.exists()) { jelem = null; IResource resource = (IResource) adaptable.getAdapter(IResource.class); if (resource != null && resource.getType() != IResource.ROOT) { while (jelem == null && resource.getType() != IResource.PROJECT) { resource = resource.getParent(); jelem = (IJavaElement) resource.getAdapter(IJavaElement.class); } if (jelem == null) { jelem = JavaCore.create(resource); // java project } } } } } return jelem; }
@Override public boolean select(Viewer viewer, Object parent, Object element) { IResource eRes = (IResource) element; if (eRes.getType() == IResource.PROJECT) { return this.projectName.equals(eRes.getName()); } if (eRes.getType() == IResource.FILE) { return false; } if (eRes.getType() == IResource.FOLDER) { IProject project = eRes.getProject(); if (!this.projectName.equals(project.getName())) { return false; } if (eRes.getParent().getType() == IResource.PROJECT) { try { String backupDir = VistACorePrefs.getServerBackupDirectory(project); return !eRes.getName().equals(backupDir); } catch (CoreException coreException) { StatusManager.getManager().handle(coreException.getStatus(), StatusManager.LOG); return false; } } else { return true; } } return true; }
/** * Returns the total number of java files in the project by recursively visiting directories. * * @param resource The location to start counting from. This could be a project, folder or file * @return The total number of files with java-like extensions found. */ private int countTotalJavaFiles(IResource resource) { if (resource == null) { return 0; } int size = 0; try { if (resource.getType() == IResource.FOLDER) { IFolder folder = (IFolder) resource; for (IResource file : folder.members()) { size += countTotalJavaFiles(file); } } else if (resource.getType() == IResource.PROJECT) { IProject proj = (IProject) resource; for (IResource file : proj.members()) { size += countTotalJavaFiles(file); } } } catch (CoreException e) { eLog.logException(e); } if (resource.getType() == IResource.FILE && JavaCore.isJavaLikeFileName(resource.getName())) size++; return size; }
/** * Retrieves all .class files from the output path * * @return The .class files list */ protected void getAllClassFiles( final IContainer aContainer, final List<IResource> aClassFileList) { if (aContainer == null) { return; } IResource[] members; try { members = aContainer.members(); } catch (final CoreException e) { Activator.logError( aContainer.getProject(), MessageFormat.format( "Error listing members in : {0}", aContainer.getFullPath().toOSString()), e); return; } for (final IResource member : members) { if (member.getType() == IResource.FOLDER) { getAllClassFiles((IContainer) member, aClassFileList); } else if (member.getType() == IResource.FILE && member.getName().endsWith(".class")) { aClassFileList.add(member); } } }
private String composeAllFileContents(IFolder folder) { String contents = ""; try { int lineNumber = 0; for (IResource member : folder.members()) { if (member.getType() == IResource.FILE && DeltajComposer.FILE_EXT.equals("." + member.getFileExtension())) { DeltajFile file = new DeltajFile((IFile) member, lineNumber, 0); InputStream source = null; source = ((IFile) member).getContents(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source)); StringBuilder stringBuilder = new StringBuilder(); String line = null; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line + "\n"); lineNumber++; } bufferedReader.close(); contents += stringBuilder.toString() + "\n"; file.setEndLine(lineNumber++); this.deltajFiles.add(file); } else if (member.getType() == IResource.FOLDER) { contents += composeAllFileContents((IFolder) member); } } } catch (CoreException e) { DeltajCorePlugin.getDefault().logError(e); } catch (IOException e) { DeltajCorePlugin.getDefault().logError(e); } return contents; }
/** * Utility method to inspect a selection to find a Java element. * * @param selection the selection to be inspected * @return a Java element to be used as the initial selection, or <code>null</code>, if no Java * element exists in the given selection */ protected IJavaElement getInitialJavaElement(IStructuredSelection selection) { IJavaElement jelem = null; if (selection != null && !selection.isEmpty()) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) selectedElement; jelem = adaptable.getAdapter(IJavaElement.class); if (jelem == null || !jelem.exists()) { jelem = null; IResource resource = adaptable.getAdapter(IResource.class); if (resource != null && resource.getType() != IResource.ROOT) { while (jelem == null && resource.getType() != IResource.PROJECT) { resource = resource.getParent(); jelem = resource.getAdapter(IJavaElement.class); } if (jelem == null) { jelem = JavaCore.create(resource); // java project } } } } } if (jelem == null) { IWorkbenchPart part = JavaPlugin.getActivePage().getActivePart(); if (part instanceof ContentOutline) { part = JavaPlugin.getActivePage().getActiveEditor(); } if (part instanceof IViewPartInputProvider) { Object elem = ((IViewPartInputProvider) part).getViewPartInput(); if (elem instanceof IJavaElement) { jelem = (IJavaElement) elem; } } } if (jelem == null || jelem.getElementType() == IJavaElement.JAVA_MODEL) { try { IJavaProject[] projects = JavaCore.create(getWorkspaceRoot()).getJavaProjects(); if (projects.length == 1) { IClasspathEntry[] rawClasspath = projects[0].getRawClasspath(); for (int i = 0; i < rawClasspath.length; i++) { if (rawClasspath[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { // add only if the project contains a source folder jelem = projects[0]; break; } } } } catch (JavaModelException e) { JavaPlugin.log(e); } } return jelem; }
/** {@inheritDoc} */ public boolean visit(IResourceDelta delta) throws CoreException { boolean visitChildren = true; IResource res = delta.getResource(); if (res.getType() == IResource.PROJECT) { visitChildren = visitProject(delta, (IProject) res); } else if (res.getType() == IResource.FILE) { visitChildren = visitFile(delta, (IFile) res); } return visitChildren; }
// find current ClassFile's corresponding eclipse file from source folder public IFile getFileInSourceFolder() { String[] eglSourceFolders = org.eclipse.edt.ide.core.internal.model.util.Util.getEGLSourceFolders( new File(this.getEGLProject().getProject().getLocation().toString())); for (String eglSourceFolder : eglSourceFolders) { IResource sourceFolder = this.getEGLProject().getProject().findMember(eglSourceFolder); if (sourceFolder != null && sourceFolder.exists() && sourceFolder.getType() == IResource.FOLDER) { // source folder exists String pkgPath = ""; IResource fullPkgFolder = null; try { ClassFileElementInfo elementInfo = ((ClassFileElementInfo) this.getElementInfo()); String[] pkgs = elementInfo.getCaseSensitivePackageName(); if (pkgs != null && pkgs.length > 0) { for (int i = 0; i < pkgs.length - 1; i++) { pkgPath += pkgs[i]; pkgPath += File.separator; } pkgPath += pkgs[pkgs.length - 1]; fullPkgFolder = ((IFolder) sourceFolder).findMember(pkgPath); } else { fullPkgFolder = sourceFolder; } if (fullPkgFolder != null && fullPkgFolder.exists() && fullPkgFolder.getType() == IResource.FOLDER) { // package matches String srcName = elementInfo .getEglFileName(); // srcName should represent the source file name eliminating // package name int index = srcName.lastIndexOf("/"); if (index != -1) { srcName = srcName.substring(index); } IResource sourceFile = ((IFolder) fullPkgFolder).findMember(srcName); if (sourceFile != null && sourceFile.exists() && sourceFile.getType() == IResource.FILE) { // egl source matches return (IFile) sourceFile; } } } catch (EGLModelException e) { e.printStackTrace(); } } } return null; }
/** * Create the resource variant for the given local resource from the given bytes. The bytes are * those that were previously returned from a call to <code>IResourceVariant#asBytes()</code>. * This means it's already been fetched, so we should be able to create enough nfo about it to * rebuild it to a minimally useable form for synchronization. * * @param resource the local resource * @param bytes the bytes that identify a variant of the resource * @return the resouce variant handle recreated from the bytes */ public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) { // in this case, asBytes() will return the revision string, so we create // the variant resource with this minimal info. if (bytes == null) return null; if (resource.getType() == IResource.FILE) { return new RemoteFile(resource, bytes); } else if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) { return new RemoteFolder(resource, bytes); } else { return null; } }
/** * Set up the selection values for the resources and put them in the selectionMap. If a resource * is a file see if it matches one of the selected extensions. If not then check the children. */ private void setupSelectionsBasedOnSelectedTypes(Map selectionMap, IContainer parent) { List selections = new ArrayList(); IResource[] resources; boolean hasFiles = false; try { resources = parent.members(); } catch (CoreException exception) { // Just return if we can't get any info return; } for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; if (resource.getType() == IResource.FILE) { if (hasExportableExtension(resource.getName())) { hasFiles = true; selections.add(resource); } } else { setupSelectionsBasedOnSelectedTypes(selectionMap, (IContainer) resource); } } // Only add it to the list if there are files in this folder if (hasFiles) { selectionMap.put(parent, selections); } }
/** * Makes the given resources committable. Committable means that all resources are writeable and * that the content of the resources hasn't changed by calling <code>validateEdit</code> for a * given file on <tt>IWorkspace</tt>. * * @param resources the resources to be checked * @param context the context passed to <code>validateEdit</code> * @return IStatus status describing the method's result. If <code>status. * isOK()</code> returns <code>true</code> then the add resources are committable * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], * java.lang.Object) */ public static IStatus makeCommittable(IResource[] resources, Object context) { List readOnlyFiles = new ArrayList(); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; if (resource.getType() == IResource.FILE && isReadOnly(resource)) readOnlyFiles.add(resource); } if (readOnlyFiles.size() == 0) return new Status(IStatus.OK, DLTKUIPlugin.PLUGIN_ID, IStatus.OK, "", null); // $NON-NLS-1$ Map oldTimeStamps = createModificationStampMap(readOnlyFiles); IStatus status = ResourcesPlugin.getWorkspace() .validateEdit( (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context); if (!status.isOK()) return status; IStatus modified = null; Map newTimeStamps = createModificationStampMap(readOnlyFiles); for (Iterator iter = oldTimeStamps.keySet().iterator(); iter.hasNext(); ) { IFile file = (IFile) iter.next(); if (!oldTimeStamps.get(file).equals(newTimeStamps.get(file))) modified = addModified(modified, file); } if (modified != null) return modified; return new Status(IStatus.OK, DLTKUIPlugin.PLUGIN_ID, IStatus.OK, "", null); // $NON-NLS-1$ }
/** * Returns the active Model project associated with the specified resource, or <code>null</code> * if no Model project yet exists for the resource. * * @exception IllegalArgumentException if the given resource is not one of an IProject, IFolder, * IRoot or IFile. * @see ModelWorkspace */ @Override public ModelProject getModelProject(final IResource resource) { IProject project = resource.getProject(); if (project == null || !project.isOpen()) return null; if (!DotProjectUtils.isModelerProject(project)) { return null; } // Only if the modelling project is open, is a partner model project created ModelProject modelProject = findModelProject(resource); if (modelProject == null) { switch (resource.getType()) { case IResource.FOLDER: case IResource.FILE: case IResource.PROJECT: return new ModelProjectImpl(project, this); case IResource.ROOT: return null; default: throw new IllegalArgumentException( ModelerCore.Util.getString( "ModelWorkspaceImpl.Invalid_resource_for_ModelProject", resource, this)); //$NON-NLS-1$ } } return modelProject; }
private static void addRemoveProps( IPath deltaPath, IResource deltaResource, ZipOutputStream zip, Map<ZipEntry, String> deleteEntries, String deletePrefix) throws IOException { String archive = removeArchive(deltaPath.toPortableString()); ZipEntry zipEntry = null; // check to see if we already have an entry for this archive for (ZipEntry entry : deleteEntries.keySet()) { if (entry.getName().startsWith(archive)) { zipEntry = entry; } } if (zipEntry == null) { zipEntry = new ZipEntry(archive + "META-INF/" + deletePrefix + "-partialapp-delete.props"); } String existingFiles = deleteEntries.get(zipEntry); // String file = encodeRemovedPath(deltaPath.toPortableString().substring(archive.length())); String file = deltaPath.toPortableString().substring(archive.length()); if (deltaResource.getType() == IResource.FOLDER) { file += "/.*"; } deleteEntries.put(zipEntry, (existingFiles != null ? existingFiles : "") + (file + "\n")); }
/** {@inheritDoc} */ public void setElement(IAdaptable element) { super.setElement(element); IProject project = null; try { // // Get the project. // IResource resource = (IResource) element; if (resource.getType() == IResource.PROJECT) { project = (IProject) resource; } IProjectConfiguration projectConfig = ProjectConfigurationFactory.getConfiguration(project); mProjectConfig = new ProjectConfigurationWorkingCopy(projectConfig); mCheckstyleInitiallyActivated = project.hasNature(CheckstyleNature.NATURE_ID); } catch (CoreException e) { handleConfigFileError(e, project); } catch (CheckstylePluginException e) { handleConfigFileError(e, project); } }
private void dialogChanged() { IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName())); if (getUserName().length() == 0) { updateStatus("Username must be specified"); return; } if (getPassword().length() == 0) { updateStatus("Password must be specified"); return; } if (getVCTText().length() == 0) { updateStatus("VCT name must be specified"); return; } if (getContainerName().length() == 0) { updateStatus("File container must be specified"); return; } if (container == null || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { updateStatus("File container must exist"); return; } if (!container.isAccessible()) { updateStatus("Project must be writable"); return; } updateStatus(null); }
private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) { IResource resource = delta.getResource(); int type = resource.getType(); int index = result.indexOf(resource); int kind = delta.getKind(); int flags = delta.getFlags(); if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) { if ((flags & IResourceDelta.OPEN) != 0) { result.set(index, resource); } } if (index != -1 && kind == IResourceDelta.REMOVED) { if ((flags & IResourceDelta.MOVED_TO) != 0) { result.set( index, ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath())); } else { result.remove(index); } } // Don't dive into closed or opened projects if (projectGotClosedOrOpened(resource, kind, flags)) { return; } IResourceDelta[] children = delta.getAffectedChildren(); for (int i = 0; i < children.length; i++) { processResourceDelta(result, children[i]); } }
private String formatFileName(String fileName) { String formatFile = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(fileName); if (resource == null) { return fileName; } basePath = getBasePath(resource.getProject()); if (basePath == null && resource.getProject() != null) basePath = resource.getProject().getName(); else if (basePath == null && resource.getProject() == null) { basePath = ""; // $NON-NLS-1$ } int type = resource.getType(); if (type == IResource.FILE || type == IResource.FOLDER) { formatFile = basePath + "/" //$NON-NLS-1$ + resource.getFullPath().removeFirstSegments(1).toString(); } else { formatFile = basePath + "/"; // $NON-NLS-1$ } if (!formatFile.startsWith("/")) { // $NON-NLS-1$ formatFile = basePath + "/" + formatFile; // $NON-NLS-1$ } return formatFile; }
public Image decorateImage(Image baseImage, Object object) { IResource objectResource = (IResource) object; if (objectResource == null) { return null; } if (objectResource.getType() != IResource.PROJECT) { // Only projects are decorated return null; } IProject project = (IProject) objectResource; boolean isJava = false; try { if (project.hasNature(X10DTCorePlugin.X10_CPP_PRJ_NATURE_ID)) { isJava = false; } else if (project.hasNature(X10DTCorePlugin.X10_PRJ_JAVA_NATURE_ID)) { isJava = true; } else { return null; } } catch (CoreException e) { X10DTUIPlugin.getInstance().getLog().log(e.getStatus()); } // Overlay custom image over base image ImageDescriptor[] desc = new ImageDescriptor[5]; desc[1] = X10PluginImages.DESC_OVR_X10; // This is the X10 project decoration. if (isJava) desc[0] = X10PluginImages.DESC_OVR_JAVA; DecorationOverlayIcon overlayIcon = new DecorationOverlayIcon(baseImage, desc); return overlayIcon.createImage(); }
public boolean visit(IResource resource) throws CoreException { if (IResource.FILE == resource.getType()) { files.add((IFile) resource); return false; } return true; }
private boolean initPath(IResource selection) { if (!WebAppUtilities.isWebApp(hostPageProject)) { return false; } IFolder container = null; try { IFolder warFolder = WebAppUtilities.getWarSrc(hostPageProject); // If the selection was a subfolder of war, initialize to that if (selection.getType() == IResource.FOLDER) { if (warFolder.getFullPath().isPrefixOf(selection.getFullPath())) { container = (IFolder) selection; return true; } } // Otherwise, use the war folder as the default path if (warFolder.exists()) { container = warFolder; return true; } return false; } finally { if (container != null) { pathField.setText(container.getFullPath().removeFirstSegments(1).toString()); } } }
@Override public boolean visit(final IResourceDelta delta) throws CoreException { IResource source = delta.getResource(); switch (source.getType()) { case IResource.ROOT: case IResource.PROJECT: case IResource.FOLDER: return true; case IResource.FILE: final IFile file = (IFile) source; if (isDiagramFile(file)) { updateModel(file); new UIJob("Update Process Model in CommonViewer") { // $NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (getStructuredViewer() != null && !getStructuredViewer().getControl().isDisposed()) { getStructuredViewer().refresh(file); } return Status.OK_STATUS; } }.schedule(); } return false; } return false; }
/** Ensures that both text fields are set. */ private void dialogChanged() { IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName())); String fileName = getFileName(); if (getContainerName().length() == 0) { updateStatus("File container must be specified"); return; } if (container == null || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { updateStatus("File container must exist"); return; } if (!container.isAccessible()) { updateStatus("Project must be writable"); return; } if (fileName.length() == 0) { updateStatus("File name must be specified"); return; } if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { updateStatus("File name must be valid"); return; } // int dotLoc = fileName.lastIndexOf('.'); // if (dotLoc != -1) { // String ext = fileName.substring(dotLoc + 1); // if (ext.equalsIgnoreCase("vtdl") == false) { // updateStatus("File extension must be \"vtdl\""); // return; // } // } updateStatus(null); }
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; }
/** * Possible failures: * * <ul> * <li>NO_ELEMENTS_TO_PROCESS - the root supplied to the operation is <code>null</code>. * <li>INVALID_NAME - the name provided to the operation is <code>null</code> or is not a valid * script folder name. * <li>READ_ONLY - the root provided to this operation is read only. * <li>NAME_COLLISION - there is a pre-existing resource (file) with the same name as a folder * in the script folder's hierarchy. * <li>ELEMENT_NOT_PRESENT - the underlying resource for the root is missing * </ul> * * @see IScriptModelStatus * @see ScriptConventions */ @Override public IModelStatus verify() { if (getParentElement() == null) { return new ModelStatus(IModelStatusConstants.NO_ELEMENTS_TO_PROCESS); } IPath packageName = this.pkgName == null ? null : this.pkgName.append("."); // $NON-NLS-1$ String packageNameValue = null; if (packageName != null) { packageNameValue = packageName.toOSString(); } if (this.pkgName == null || (this.pkgName.segmentCount() > 0 && !Util.isValidFolderNameForPackage( (IContainer) getParentElement().getResource(), packageName.toString()))) { return new ModelStatus(IModelStatusConstants.INVALID_NAME, packageNameValue); } IProjectFragment root = (IProjectFragment) getParentElement(); if (root.isReadOnly()) { return new ModelStatus(IModelStatusConstants.READ_ONLY, root); } IContainer parentFolder = (IContainer) root.getResource(); int i; for (i = 0; i < this.pkgName.segmentCount(); i++) { IResource subFolder = parentFolder.findMember(this.pkgName.segment(i)); if (subFolder != null) { if (subFolder.getType() != IResource.FOLDER) { return new ModelStatus( IModelStatusConstants.NAME_COLLISION, Messages.bind(Messages.status_nameCollision, subFolder.getFullPath().toString())); } parentFolder = (IContainer) subFolder; } } return ModelStatus.VERIFIED_OK; }
/** Ensures that both text fields are set. */ private void dialogChanged() { IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName())); String fileName = getFileName(); if (getContainerName().length() == 0) { updateStatus("Project must be specified"); return; } if (container == null || (container.getType() & (IResource.PROJECT /* | IResource.FOLDER*/)) == 0) { updateStatus("Specify existing project, without subfolder(s)"); return; } if (!container.isAccessible()) { updateStatus("Project must be writable"); return; } if (fileName.length() == 0) { updateStatus("File name must be specified"); return; } if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { updateStatus("File name must be valid"); return; } if (!fileName.matches("[A-Z][A-Za-z0-9]*")) { updateStatus("Use alphanumeric (a-z, A-Z, 0-9) only, starting with uppercase character"); return; } updateStatus(null); }
public static void addEGLPathToJavaPathIfNecessary( IJavaProject javaProject, IProject currProject, Set<IProject> seen, List<String> classpath) { if (seen.contains(currProject)) { return; } seen.add(currProject); try { if (currProject.hasNature(EGLCore.NATURE_ID)) { IEGLProject eglProject = EGLCore.create(currProject); for (IEGLPathEntry pathEntry : eglProject.getResolvedEGLPath(true)) { if (pathEntry.getEntryKind() == IEGLPathEntry.CPE_PROJECT) { IPath path = pathEntry.getPath(); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); try { if (resource != null && resource.getType() == IResource.PROJECT && !seen.contains(resource) && ((IProject) resource).hasNature(JavaCore.NATURE_ID) && !javaProject.isOnClasspath(resource)) { classpath.add(getWorkspaceProjectClasspathEntry(resource.getName())); addEGLPathToJavaPathIfNecessary(javaProject, (IProject) resource, seen, classpath); } } catch (CoreException ce) { } } } } } catch (EGLModelException e) { } catch (CoreException e) { } }
public boolean visit(IResource resource) throws CoreException { if (resource.isDerived()) { return false; } handler.handleResourceStart(resource); if (resource.getType() == IResource.FILE && ContentTypeUtils.isGroovyLikeFileName(resource.getName())) { if (Util.isExcluded(resource, includes, excludes)) { return false; } GroovyCompilationUnit unit = (GroovyCompilationUnit) JavaCore.create((IFile) resource); if (unit != null && unit.isOnBuildPath()) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } monitor.subTask(resource.getName()); handler.setResource((IFile) resource); Map<Integer, String> commentsMap = findComments(unit); StaticTypeCheckerRequestor requestor = new StaticTypeCheckerRequestor(handler, commentsMap, onlyAssertions); TypeInferencingVisitorWithRequestor visitor = new TypeInferencingVisitorFactory().createVisitor(unit); try { unit.becomeWorkingCopy(monitor); visitor.visitCompilationUnit(requestor); } finally { unit.discardWorkingCopy(); } } } return true; }
@Test public void shouldKeepLookingIfResourceIsNotAFile() throws CoreException { when(resource.isDerived()).thenReturn(false); when(resource.getType()).thenReturn(IResource.FOLDER); assertTrue(deltaVisitor.visit(resourceDelta(CONTENT))); assertFalse(deltaVisitor.savedResourceFound()); }
@Test public void shouldIgnoreMarkerOnlyChanges() throws CoreException { when(resource.getType()).thenReturn(IResource.FILE); when(resource.isDerived()).thenReturn(false); assertFalse(deltaVisitor.visit(resourceDelta(MARKERS))); assertFalse(deltaVisitor.savedResourceFound()); }
public boolean visit(IResource r) throws CoreException { if (r.getType() != IResource.FILE) return true; IFile file = (IFile) r; String ext = file.getFullPath().getFileExtension(); if (ext == null) return false; if (KonohaUtil.search(ext, exts)) list.add(file); return false; }