WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) { super(workingCopy.getPath().toString(), participant); this.charContents = ((CompilationUnit)workingCopy).getContents(); this.workingCopy = workingCopy; } @Override
WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) { super(workingCopy.getPath().toString(), participant); this.charContents = ((CompilationUnit)workingCopy).getContents(); this.workingCopy = workingCopy; } public String toString() {
WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) { super(workingCopy.getPath().toString(), participant); this.charContents = ((CompilationUnit)workingCopy).getContents(); this.workingCopy = workingCopy; } public String toString() {
WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) { super(workingCopy.getPath().toString(), participant); this.charContents = ((CompilationUnit)workingCopy).getContents(); this.workingCopy = workingCopy; } public String toString() {
WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) { super(workingCopy.getPath().toString(), participant); this.charContents = ((CompilationUnit)workingCopy).getContents(); this.workingCopy = workingCopy; } public String toString() {
public String getJavaPath() { // create if necessary ICompilationUnit cu = getCompilationUnit(); return (cu != null) ? cu.getPath().toString() : ""; //$NON-NLS-1$ }
WorkingCopyDocument(org.eclipse.jdt.core.ICompilationUnit workingCopy, SearchParticipant participant) { super(workingCopy.getPath().toString(), participant); this.charContents = ((CompilationUnit)workingCopy).getContents(); this.workingCopy = workingCopy; } public String toString() {
private static HashMap workingCopiesThatCanSeeFocus(org.eclipse.jdt.core.ICompilationUnit[] copies, SearchPattern pattern, SearchParticipant participant) { if (copies == null) return new HashMap(); HashMap result = new HashMap(); for (int i=0, length = copies.length; i<length; i++) { org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i]; IPath projectOrJar = MatchLocator.getProjectOrJar(workingCopy).getPath(); if (pattern.focus == null || IndexSelector.canSeeFocus(pattern, projectOrJar) != IndexSelector.PROJECT_CAN_NOT_SEE_FOCUS) { result.put( workingCopy.getPath().toString(), new WorkingCopyDocument(workingCopy, participant) ); } } return result; }
private static HashMap workingCopiesThatCanSeeFocus(org.eclipse.jdt.core.ICompilationUnit[] copies, SearchPattern pattern, SearchParticipant participant) { if (copies == null) return new HashMap(); HashMap result = new HashMap(); for (int i=0, length = copies.length; i<length; i++) { org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i]; IPath projectOrJar = MatchLocator.getProjectOrJar(workingCopy).getPath(); if (pattern.focus == null || IndexSelector.canSeeFocus(pattern, projectOrJar) != IndexSelector.PROJECT_CAN_NOT_SEE_FOCUS) { result.put( workingCopy.getPath().toString(), new WorkingCopyDocument(workingCopy, participant) ); } } return result; }
private static HashMap workingCopiesThatCanSeeFocus(org.eclipse.jdt.core.ICompilationUnit[] copies, SearchPattern pattern, SearchParticipant participant) { if (copies == null) return new HashMap(); HashMap result = new HashMap(); for (int i=0, length = copies.length; i<length; i++) { org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i]; IPath projectOrJar = MatchLocator.getProjectOrJar(workingCopy).getPath(); if (pattern.focus == null || IndexSelector.canSeeFocus(pattern, projectOrJar) != IndexSelector.PROJECT_CAN_NOT_SEE_FOCUS) { result.put( workingCopy.getPath().toString(), new WorkingCopyDocument(workingCopy, participant) ); } } return result; }
private static HashMap workingCopiesThatCanSeeFocus(org.eclipse.jdt.core.ICompilationUnit[] copies, SearchPattern pattern, SearchParticipant participant) { if (copies == null) return new HashMap(); HashMap result = new HashMap(); for (int i=0, length = copies.length; i<length; i++) { org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i]; IPath projectOrJar = MatchLocator.getProjectOrJar(workingCopy).getPath(); if (pattern.focus == null || IndexSelector.canSeeFocus(pattern, projectOrJar)) { result.put( workingCopy.getPath().toString(), new WorkingCopyDocument(workingCopy, participant) ); } } return result; }
private static HashMap workingCopiesThatCanSeeFocus(org.eclipse.jdt.core.ICompilationUnit[] copies, SearchPattern pattern, SearchParticipant participant) { if (copies == null) return new HashMap(); HashMap result = new HashMap(); for (int i=0, length = copies.length; i<length; i++) { org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i]; IPath projectOrJar = MatchLocator.getProjectOrJar(workingCopy).getPath(); if (pattern.focus == null || IndexSelector.canSeeFocus(pattern, projectOrJar) != IndexSelector.PROJECT_CAN_NOT_SEE_FOCUS) { result.put( workingCopy.getPath().toString(), new WorkingCopyDocument(workingCopy, participant) ); } } return result; }
private static HashMap workingCopiesThatCanSeeFocus(org.eclipse.jdt.core.ICompilationUnit[] copies, SearchPattern pattern, SearchParticipant participant) { if (copies == null) return new HashMap(); HashMap result = new HashMap(); for (int i=0, length = copies.length; i<length; i++) { org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i]; IPath projectOrJar = MatchLocator.getProjectOrJar(workingCopy).getPath(); if (pattern.focus == null || IndexSelector.canSeeFocus(pattern, projectOrJar) != IndexSelector.PROJECT_CAN_NOT_SEE_FOCUS) { result.put( workingCopy.getPath().toString(), new WorkingCopyDocument(workingCopy, participant) ); } } return result; }
private boolean testOnBuildPath(ICompilationUnit cu, MultiStatus status) { IJavaProject project= cu.getJavaProject(); if (!project.isOnClasspath(cu)) { String cuLocation= cu.getPath().makeRelative().toString(); String message= Messages.format(ActionMessages.OrganizeImportsAction_multi_error_notoncp, cuLocation); status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); return false; } return true; }
private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException { for (int i = 0; i < types.length; i++) { //could this be a problem (same package imports)? if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())) { String msg = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1, new Object[] { JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false) }); result.addError(msg, JavaStatusContext.create(imp)); } } }
private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException { for (int i= 0; i < types.length; i++) { //could this be a problem (same package imports)? if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())){ String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1, new Object[]{ JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)}); result.addError(msg, JavaStatusContext.create(imp)); } } }
private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException { for (int i= 0; i < types.length; i++) { //could this be a problem (same package imports)? if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())){ String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1, new Object[]{ JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)}); result.addError(msg, JavaStatusContext.create(imp)); } } }
private static IDocument aquireDocument(ICompilationUnit cu, IProgressMonitor monitor) throws CoreException { if (JavaModelUtil.isPrimary(cu)) { IFile file= (IFile) cu.getResource(); if (file.exists()) { ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager(); IPath path= cu.getPath(); bufferManager.connect(path, LocationKind.IFILE, monitor); return bufferManager.getTextFileBuffer(path, LocationKind.IFILE).getDocument(); } } monitor.done(); return new Document(cu.getSource()); }
public static ITestContent parseType(IType type) { BaseVisitor result = new AnnotationVisitor(); ICompilationUnit compilationUnit = type.getCompilationUnit(); if (compilationUnit == null) { return result; } ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setResolveBindings(true); parser.setSource(compilationUnit); parser.setProject(type.getJavaProject()); parser.setUnitName(compilationUnit.getPath().toString()); CompilationUnit cu = (CompilationUnit) parser.createAST(null); cu.accept(result); return result; }
private TextEdit getTextEdit() throws CoreException { IDocument document= null; ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); IPath path= fCU.getPath(); if (manager != null && path != null) { manager.connect(path, LocationKind.NORMALIZE, null); try { ITextFileBuffer buffer= manager.getTextFileBuffer(path, LocationKind.NORMALIZE); if (buffer != null) document= buffer.getDocument(); } finally { manager.disconnect(path, LocationKind.NORMALIZE, null); } } if (document == null) document= new Document(fCU.getSource()); return fASTRewrite.rewriteAST(document, fCU.getJavaProject().getOptions(true)); }