/** * Returns the extension portion of the given resource. * * @param resource the resource * @return the file extension, possibily the empty string */ private String getExtensionFor(IResource resource) { String ext = resource.getFileExtension(); return ext == null ? "" : ext; //$NON-NLS-1$ }
/** * Returns the extension portion of the given resource. * * @param resource the resource * @return the file extension, possibily the empty string */ private String getExtensionFor(IResource resource) { String ext = resource.getFileExtension(); return ext == null ? "" : ext; //$NON-NLS-1$ }
@Override public String getType() { if (fResource instanceof IContainer) return ITypedElement.FOLDER_TYPE; if (fResource != null) { String s= fResource.getFileExtension(); if (s != null) return s; } return ITypedElement.UNKNOWN_TYPE; }
public String getType() { if (fResource instanceof IContainer) return ITypedElement.FOLDER_TYPE; if (fResource != null) { String s= fResource.getFileExtension(); if (s != null) return s; } return ITypedElement.UNKNOWN_TYPE; }
/** * Returns the extension portion of the given resource. * * @param resource the resource * @return the file extension, possibily the empty string */ private String getExtensionFor(IResource resource) { String ext = resource.getFileExtension(); return ext == null ? "" : ext; //$NON-NLS-1$ } }
private boolean isHTMLFile(Object fileObject) { if (!(fileObject instanceof IResource)) { return false; } String extension = ((IResource) fileObject).getFileExtension(); return "html".equals(extension) || "htm".equals(extension); }
/** * Answers whether the given resource is a class file. * The resource must be a file whose file name ends with ".class". * * @return a <code>true<code> if the given resource is a class file */ boolean isClassFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && file.getFileExtension().equalsIgnoreCase("class"); //$NON-NLS-1$ }
/** * Answers whether the given resource is a class file. * The resource must be a file whose file name ends with ".class". * * @param file the file to test * @return a <code>true<code> if the given resource is a class file */ private boolean isClassFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && file.getFileExtension().equalsIgnoreCase("class"); //$NON-NLS-1$ }
/** * Answers whether the given resource is a class file. * The resource must be a file whose file name ends with ".class". * * @param file the file to test * @return a <code>true<code> if the given resource is a class file */ private boolean isClassFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && file.getFileExtension().equalsIgnoreCase("class"); //$NON-NLS-1$ }
/** * Answers whether the given resource is a class file. * The resource must be a file whose file name ends with ".class". * * @param file the file to test * @return a <code>true<code> if the given resource is a class file */ private boolean isClassFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && file.getFileExtension().equalsIgnoreCase("class"); //$NON-NLS-1$ }
IFolder folder = IProject.getFolder("src/model"); IResource[] members = folder.members(); for(IResource member: members) { if (member instanceof IFile && member.getFileExtension().equalsIgnoreCase("model") { file = (IFile)member; break; } }
public static boolean isZenFile(IResource resource) { return resource instanceof IFile && includes(resource.getFileExtension()); }
public static IFile getProjectFile(IContainer container) { if (container != null) { try { for (IResource projResource : container.members()) { if (projResource.getFileExtension() != null && (projResource.getFileExtension().equals("csproj") //$NON-NLS-1$ || projResource.getName().equals("project.json"))) { //$NON-NLS-1$ return (IFile) projResource; } } } catch (CoreException e) { } } return null; }
/** * @since 0.22.0 */ public static boolean inResourceWithSameName(IResource resource, String typeName) throws CoreException { if (resource instanceof IFile) { return resource.getName().substring(0, resource.getName().indexOf(resource.getFileExtension()) - 1).equals(typeName); } else if (resource instanceof IFolder) { return resource.getName().equals(typeName.substring(typeName.lastIndexOf(BACK_SLASH) + 1)); } else { throw new CoreException(new Status(IStatus.ERROR, PEXCorePlugin.PLUGIN_ID, "The resource is neither a file or folder")); //$NON-NLS-1$ } } }
public boolean visit(IResource resource) throws CoreException { if (IResource.FILE == resource.getType() && expectedExtension.equals(resource.getFileExtension())) { result[0] = (IFile) resource; return false; } return IResource.FOLDER == resource.getType(); } });
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof IResource) { IResource resource = (IResource) receiver; IProject project = resource.getProject(); if (GradleProjectNature.isPresentOn(project)) { return resource instanceof IProject || "gradle".equals(resource.getFileExtension()) || "gradle.properties".equals(resource.getName()); } } return false; }
public static boolean isSonarLintFileCandidate(IResource resource) { if (!resource.exists() || resource.isDerived(IResource.CHECK_ANCESTORS) || resource.isHidden(IResource.CHECK_ANCESTORS)) { return false; } // Ignore .project, .settings, that are not considered hidden on Windows... // Also ignore .class (SLE-65) if (resource.getName().startsWith(".") || "class".equals(resource.getFileExtension())) { return false; } return true; }
/** * Answers whether the given resource is a Java file. * The resource must be a file whose file name ends with ".java", * or an extension defined as Java source. * * @param file the file to test * @return a <code>true<code> if the given resource is a Java file */ private boolean isJavaFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && JavaCore.isJavaLikeFileName(file.getName()); }
/** * Answers whether the given resource is a Java file. * The resource must be a file whose file name ends with ".java", * or an extension defined as Java source. * * @param file the file to test * @return a <code>true<code> if the given resource is a Java file */ private boolean isJavaFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && JavaCore.isJavaLikeFileName(file.getName()); }
/** * Answers whether the given resource is a Java file. * The resource must be a file whose file name ends with ".java", * or an extension defined as Java source. * * @param file the file to test * @return a <code>true<code> if the given resource is a Java file */ private boolean isJavaFile(IResource file) { return file != null && file.getType() == IResource.FILE && file.getFileExtension() != null && JavaCore.isJavaLikeFileName(file.getName()); }