private static Object[] findDependsOnMethodsOrGroups(IType[] types) { List<IResource> resources = new ArrayList<>(types.length); for(int i= 0; i < types.length; i++) { resources.add(types[i].getResource()); } return findDependenciesBySearch(resources, "@Test\\(.*\\s*(dependsOnGroups)|(dependsOnMethods)\\s*=.*"); }
protected boolean acceptType(IType candidate) { final IResource resource = candidate.getResource(); if (resource == null || !resource.isAccessible()) { return false; // exclude binary types } if (selection().isEmpty()) { return true; // not limited to resources: accept all } return isInResources(resource); }
protected IFile getFile(JavaClass clazz) { // Not in the current project, so check the IType's project IType type = getType(clazz); if (type == null) { return null; } IResource resource = type.getResource(); if (resource != null && resource.getType() == IResource.FILE && resource.isAccessible()) return (IFile) resource; return null; }
private RefactoringStatus analyzeAffectedCompilationUnits(IProgressMonitor pm) throws CoreException { RefactoringStatus result = new RefactoringStatus(); result.merge(Checks.checkCompileErrorsInAffectedFiles(fReferences, fType.getResource())); pm.beginTask("", fReferences.length); //$NON-NLS-1$ result.merge(checkConflictingTypes(pm)); return result; }
private RefactoringStatus analyzeAffectedCompilationUnits(IProgressMonitor pm) throws CoreException { RefactoringStatus result= new RefactoringStatus(); result.merge(Checks.checkCompileErrorsInAffectedFiles(fReferences, fType.getResource())); pm.beginTask("", fReferences.length); //$NON-NLS-1$ result.merge(checkConflictingTypes(pm)); return result; }
private RefactoringStatus analyzeAffectedCompilationUnits(IProgressMonitor pm) throws CoreException { RefactoringStatus result= new RefactoringStatus(); result.merge(Checks.checkCompileErrorsInAffectedFiles(fReferences, fType.getResource())); pm.beginTask("", fReferences.length); //$NON-NLS-1$ result.merge(checkConflictingTypes(pm)); return result; }
private RefactoringStatus analyzeAffectedCompilationUnits(IProgressMonitor pm) throws CoreException { RefactoringStatus result= new RefactoringStatus(); result.merge(Checks.checkCompileErrorsInAffectedFiles(fReferences, fType.getResource())); pm.beginTask("", fReferences.length); //$NON-NLS-1$ result.merge(checkConflictingTypes(pm)); return result; }
@Override public IResource getRefactoredResource(IResource element) { if (element instanceof IFile) { if (Checks.isTopLevel(fType) && element.equals(fType.getResource())) return getNewCompilationUnit().getResource(); } return element; }
@Override public IResource getRefactoredResource(IResource element) { if (element instanceof IFile) { if (Checks.isTopLevel(fType) && element.equals(fType.getResource())) { return getNewCompilationUnit().getResource(); } } return element; }
/** * {@inheritDoc} */ public IResource getRefactoredResource(IResource element) { if (element instanceof IFile) { if (Checks.isTopLevel(fType) && element.equals(fType.getResource())) return getNewCompilationUnit().getResource(); } return element; }
@Override public IResource getRefactoredResource(IResource element) { if (element instanceof IFile) { if (Checks.isTopLevel(fType) && element.equals(fType.getResource())) return getNewCompilationUnit().getResource(); } return element; }
public boolean accept(IType type) { IResource resource = type.getResource(); ICompilationUnit cu = JDTUtil.getJavaElement((IFile) resource); CompilationUnit astRoot = JUnitConverterQuickAssistProcessor.createCompilationUnit(cu); JUnitVisitor visitor = new JUnitVisitor(); astRoot.accept(visitor); return visitor.needsConversion(); }
/** * Tells whether the specified manifest main class is valid. * * @return <code>true</code> if a main class is specified and valid */ public static boolean isMainClassValid(JarPackageData data, IRunnableContext context) { if (data == null) return false; IType mainClass= data.getManifestMainClass(); if (mainClass == null) // no main class specified return true; try { // Check if main method is in scope IFile file= (IFile)mainClass.getResource(); if (file == null || !contains(asResources(data.getElements()), file)) return false; // Test if it has a main method return JavaModelUtil.hasMainMethod(mainClass); } catch (JavaModelException e) { } return false; }
/** * Returns the resource handle that corresponds to the compilation unit to was or * will be created or modified. * @return A resource or null if the page contains illegal values. * @since 3.0 */ public IResource getModifiedResource() { IType enclosing= getEnclosingType(); if (enclosing != null) { return enclosing.getResource(); } IPackageFragment pack= getPackageFragment(); if (pack != null) { String cuName= getCompilationUnitName(getTypeNameWithoutParameters()); return pack.getCompilationUnit(cuName).getResource(); } return null; }
/** * Returns the resource handle that corresponds to the compilation unit to was or * will be created or modified. * @return A resource or null if the page contains illegal values. * @since 3.0 */ public IResource getModifiedResource() { IType enclosing= getEnclosingType(); if (enclosing != null) { return enclosing.getResource(); } IPackageFragment pack= getPackageFragment(); if (pack != null) { String cuName= getCompilationUnitName(getTypeNameWithoutParameters()); return pack.getCompilationUnit(cuName).getResource(); } return null; }
/** * Returns the resource handle that corresponds to the compilation unit to was or * will be created or modified. * @return A resource or null if the page contains illegal values. * @since 3.0 */ public IResource getModifiedResource() { IType enclosing= getEnclosingType(); if (enclosing != null) { return enclosing.getResource(); } IPackageFragment pack= getPackageFragment(); if (pack != null) { String cuName= getCompilationUnitName(getTypeNameWithoutParameters()); return pack.getCompilationUnit(cuName).getResource(); } return null; }
/** * Returns the resource handle that corresponds to the compilation unit to was or * will be created or modified. * @return A resource or null if the page contains illegal values. * @since 3.0 */ public IResource getModifiedResource() { IType enclosing= getEnclosingType(); if (enclosing != null) { return enclosing.getResource(); } IPackageFragment pack= getPackageFragment(); if (pack != null) { String cuName= getCompilationUnitName(getTypeNameWithoutParameters()); return pack.getCompilationUnit(cuName).getResource(); } return null; }
/** * Tells whether the specified manifest main class is valid. * * @param data the Jar package data * @param context the runnable context * @return <code>true</code> if a main class is specified and valid */ public static boolean isMainClassValid(JarPackageData data, IRunnableContext context) { if (data == null) return false; IType mainClass= data.getManifestMainClass(); if (mainClass == null) // no main class specified return true; try { // Check if main method is in scope IFile file= (IFile)mainClass.getResource(); if (file == null || !contains(asResources(data.getElements()), file)) return false; // Test if it has a main method return JavaModelUtil.hasMainMethod(mainClass); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } return false; }
/** * Tells whether the specified manifest main class is valid. * * @param data the Jar package data * @param context the runnable context * @return <code>true</code> if a main class is specified and valid */ public static boolean isMainClassValid(JarPackageData data, IRunnableContext context) { if (data == null) return false; IType mainClass= data.getManifestMainClass(); if (mainClass == null) // no main class specified return true; try { // Check if main method is in scope IFile file= (IFile)mainClass.getResource(); if (file == null || !contains(asResources(data.getElements()), file)) return false; // Test if it has a main method return JavaModelUtil.hasMainMethod(mainClass); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } return false; }
private long getContainerTimestamp(TypeNameMatch match) { try { IType type= match.getType(); IResource resource= type.getResource(); if (resource != null) { URI location= resource.getLocationURI(); if (location != null) { IFileInfo info= EFS.getStore(location).fetchInfo(); if (info.exists()) { // The element could be removed from the build path. So check // if the Java element still exists. IJavaElement element= JavaCore.create(resource); if (element != null && element.exists()) return info.getLastModified(); } } } else { // external JAR IPackageFragmentRoot root= match.getPackageFragmentRoot(); IFileInfo info= EFS.getLocalFileSystem().getStore(root.getPath()).fetchInfo(); if (info.exists()) { return info.getLastModified(); } } } catch (CoreException e) { // Fall through } return IResource.NULL_STAMP; }