static ICompilationUnit findWorkingCopyForCu(ICompilationUnit[] newWorkingCopies, ICompilationUnit cu){ ICompilationUnit original= cu == null ? null : cu.getPrimary(); for (int i= 0; i < newWorkingCopies.length; i++) { if (newWorkingCopies[i].getPrimary().equals(original)) return newWorkingCopies[i]; } return null; }
static ICompilationUnit findWorkingCopyForCu(ICompilationUnit[] newWorkingCopies, ICompilationUnit cu){ ICompilationUnit original= cu == null ? null : cu.getPrimary(); for (int i= 0; i < newWorkingCopies.length; i++) { if (newWorkingCopies[i].getPrimary().equals(original)) return newWorkingCopies[i]; } return null; }
private void integrateSolution(CleanUpChange solution, ICompilationUnit source) { ICompilationUnit primary= source.getPrimary(); List<CleanUpChange> changes= fSolutions.get(primary); if (changes == null) { changes= new ArrayList<>(); fSolutions.put(primary, changes); } changes.add(solution); } }
public static ResourceMapping create(ICompilationUnit unit) { if (unit == null) { return null; } return new CompilationUnitResourceMapping(unit.getPrimary()); }
@Override public IBuffer createBuffer(ICompilationUnit workingCopy) { ICompilationUnit original= workingCopy.getPrimary(); IResource resource= original.getResource(); if (resource instanceof IFile) return new DocumentAdapter(workingCopy, (IFile) resource); return DocumentAdapter.NULL; } });
private IResource getResource(IJavaElement element) { if (element == null) return null; element= (IJavaElement) element.getOpenable(); if (element instanceof ICompilationUnit) { element= ((ICompilationUnit) element).getPrimary(); } return element.getResource(); }
private IFile getFile(ICompilationUnit unit) { unit= unit.getPrimary(); IResource resource= unit.getResource(); if (resource != null && resource.getType() == IResource.FILE) return (IFile)resource; return null; }
@Override public IBuffer createBuffer(ICompilationUnit workingCopy) { ICompilationUnit original = workingCopy.getPrimary(); IResource resource = original.getResource(); if (resource instanceof IFile) { return new DocumentAdapter(workingCopy, (IFile) resource); } return DocumentAdapter.Null; }
@Override public IBuffer createBuffer(ICompilationUnit workingCopy) { ICompilationUnit original= workingCopy.getPrimary(); IResource resource= original.getResource(); if (resource instanceof IFile) { return new DocumentAdapter(workingCopy, (IFile)resource); } return DocumentAdapter.Null; }
public static IResource getResource(IJavaElement element){ if (element instanceof ICompilationUnit) { return ((ICompilationUnit)element).getPrimary().getResource(); } else { return element.getResource(); } }
public static IResource getResource(IJavaElement element){ if (element instanceof ICompilationUnit) return ((ICompilationUnit)element).getPrimary().getResource(); else return element.getResource(); }
private IResource getResource(IJavaElement element) { if (element == null) return null; element= (IJavaElement) element.getOpenable(); if (element instanceof ICompilationUnit) { element= ((ICompilationUnit) element).getPrimary(); } return element.getResource(); }
/** * Returns if a CU can be edited. */ public static boolean isEditable(ICompilationUnit cu) { Assert.isNotNull(cu); IResource resource= cu.getPrimary().getResource(); return (resource.exists() && !resource.getResourceAttributes().isReadOnly()); }
private IResource getUnderlyingResource() { Object input= getInput(); if (input instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) input; cu= cu.getPrimary(); return cu.getResource(); } else if (input instanceof IClassFile) { return ((IClassFile) input).getResource(); } return null; }
/** * Returns if a CU can be edited. * @param cu the compilation unit * @return <code>true</code> if the CU can be edited */ public static boolean isEditable(ICompilationUnit cu) { Assert.isNotNull(cu); IResource resource= cu.getPrimary().getResource(); return (resource.exists() && !resource.getResourceAttributes().isReadOnly()); }
private IResource getUnderlyingResource() { Object input= getInput(); if (input instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) input; cu= cu.getPrimary(); return cu.getResource(); } else if (input instanceof IClassFile) { return ((IClassFile) input).getResource(); } return null; }
/** * Returns if a CU can be edited. * @param cu the compilation unit * @return <code>true</code> if the CU can be edited */ public static boolean isEditable(ICompilationUnit cu) { Assert.isNotNull(cu); IResource resource= cu.getPrimary().getResource(); return (resource.exists() && !resource.getResourceAttributes().isReadOnly()); }
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException { ICompilationUnit copy= unit.getPrimary().getWorkingCopy(null); try { TextChangeManager manager= createChangeManager(monitor, copy, newTypeName); String result= manager.get(copy).getPreviewContent(new NullProgressMonitor()); return result; } finally { copy.discardWorkingCopy(); } }
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException { ICompilationUnit copy= unit.getPrimary().getWorkingCopy(null); try { TextChangeManager manager= createChangeManager(monitor, copy, newTypeName); String result= manager.get(copy).getPreviewContent(new NullProgressMonitor()); return result; } finally { copy.discardWorkingCopy(); } }
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException { ICompilationUnit copy= unit.getPrimary().getWorkingCopy(null); try { TextChangeManager manager= createChangeManager(monitor, copy, newTypeName); String result= manager.get(copy).getPreviewContent(new NullProgressMonitor()); return result; } finally { copy.discardWorkingCopy(); } }