protected IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IBuffer buffer = cu.getBuffer(); if (buffer instanceof IDocument) return (IDocument) buffer; return new DocumentAdapter(buffer); } /**
protected IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IBuffer buffer = cu.getBuffer(); if (buffer instanceof IDocument) return (IDocument) buffer; return new DocumentAdapter(buffer); } /**
protected IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IBuffer buffer = cu.getBuffer(); if (buffer instanceof IDocument) return (IDocument) buffer; return new DocumentAdapter(buffer); } /**
protected IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IBuffer buffer = cu.getBuffer(); if (buffer instanceof IDocument) return (IDocument) buffer; return new DocumentAdapter(buffer); } /**
protected IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IBuffer buffer = cu.getBuffer(); if (buffer instanceof IDocument) return (IDocument) buffer; return new DocumentAdapter(buffer); } /**
/** * Returns a list of NLSLines found in the compilation unit */ public static NLSLine[] scan(ICompilationUnit cu) throws JavaModelException, InvalidInputException { return scan(cu.getBuffer().getCharacters()); }
private static int findLineEnd(ICompilationUnit cu, int position) throws JavaModelException { IBuffer buffer= cu.getBuffer(); int length= buffer.getLength(); for (int i= position; i < length; i++) { if (IndentManipulation.isLineDelimiterChar(buffer.getChar(i))) { return i; } } return length; }
private static int findLineEnd(ICompilationUnit cu, int position) throws JavaModelException { IBuffer buffer= cu.getBuffer(); int length= buffer.getLength(); for (int i= position; i < length; i++) { if (IndentManipulation.isLineDelimiterChar(buffer.getChar(i))) { return i; } } return length; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
protected static String getNewText(final ASTNode node, final ICompilationUnit declaringCu, final boolean removeIndentation) throws JavaModelException { final String result= declaringCu.getBuffer().getText(node.getStartPosition(), node.getLength()); if (removeIndentation) return getUnindentedText(result, declaringCu); return result; }
void create(ICompilationUnit cu, boolean toRestore) throws CoreException { ImportRewrite.create(cu, toRestore); TextEdit edit = fImportsStructure.rewriteImports(new NullProgressMonitor()); IDocument document = new Document(cu.getSource()); try { edit.apply(document); } catch (Exception e) { } String imports = document.get(); cu.getBuffer().setContents(imports); cu.commitWorkingCopy(false, new NullProgressMonitor()); }
private static String getNormalizedTypeReference(SearchMatch searchResult) throws JavaModelException { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); String reference= cu.getBuffer().getText(searchResult.getOffset(), searchResult.getLength()); //reference may be package-qualified -> normalize (remove comments, etc.): return CommentAnalyzer.normalizeReference(reference); }
private static String getNormalizedTypeReference(SearchMatch searchResult) throws JavaModelException { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); String reference= cu.getBuffer().getText(searchResult.getOffset(), searchResult.getLength()); //reference may be package-qualified -> normalize (remove comments, etc.): return CommentAnalyzer.normalizeReference(reference); }
private static String getNormalizedTypeReference(SearchMatch searchResult) throws JavaModelException { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); String reference= cu.getBuffer().getText(searchResult.getOffset(), searchResult.getLength()); //reference may be package-qualified -> normalize (remove comments, etc.): return CommentAnalyzer.normalizeReference(reference); }
private static String getNormalizedTypeReference(SearchMatch searchResult) throws JavaModelException { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); String reference= cu.getBuffer().getText(searchResult.getOffset(), searchResult.getLength()); //reference may be package-qualified -> normalize (remove comments, etc.): return CommentAnalyzer.normalizeReference(reference); }
public void addAnnotation(IType newType, ImportsManager imports, String lineDelimiter) throws JavaModelException { if (isEnabled()) { List<E> selectedEnums= availableSelectedEnums(); if (selectedEnums.size() > 0) { String annotation= createAnnotationAndImports(selectedEnums, imports, lineDelimiter); int start= newType.getSourceRange().getOffset(); IBuffer buffer= newType.getCompilationUnit().getBuffer(); buffer.replace(start, 0, annotation); } } }
public void addAnnotation(IType newType, ImportsManager imports, String lineDelimiter) throws JavaModelException { if (isEnabled()) { List<E> selectedEnums= availableSelectedEnums(); if (selectedEnums.size() > 0) { String annotation= createAnnotationAndImports(selectedEnums, imports, lineDelimiter); int start= newType.getSourceRange().getOffset(); IBuffer buffer= newType.getCompilationUnit().getBuffer(); buffer.replace(start, 0, annotation); } } }
public static NLSLine[] scan(ICompilationUnit cu) throws JavaModelException, BadLocationException, InvalidInputException { IJavaProject javaProject= cu.getJavaProject(); IScanner scanner= null; if (javaProject != null) { String complianceLevel= javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true); String sourceLevel= javaProject.getOption(JavaCore.COMPILER_SOURCE, true); scanner= ToolFactory.createScanner(true, true, true, sourceLevel, complianceLevel); } else { scanner= ToolFactory.createScanner(true, true, false, true); } return scan(scanner, cu.getBuffer().getCharacters()); }