/** * Creates a TokenScanner * @param scanner The scanner to be wrapped * @param document The document used for line information if specified */ public TokenScanner(IScanner scanner, IDocument document) { fScanner= scanner; fEndPosition= fScanner.getSource().length - 1; fDocument= document; }
/** * Creates a TokenScanner * @param scanner The scanner to be wrapped * @param document The document used for line information if specified */ public TokenScanner(IScanner scanner, IDocument document) { fScanner= scanner; fEndPosition= fScanner.getSource().length - 1; fDocument= document; }
/** * Creates a TokenScanner * @param scanner The scanner to be wrapped * @param document The document used for line information if specified */ public TokenScanner(IScanner scanner, IDocument document) { fScanner= scanner; fEndPosition= fScanner.getSource().length - 1; fDocument= document; }
/** * Creates a TokenScanner * @param document The textbuffer to create the scanner on */ public TokenScanner(IDocument document, IJavaProject project) { String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); fScanner= ToolFactory.createScanner(true, false, false, sourceLevel, complianceLevel); // no line info required fScanner.setSource(document.get().toCharArray()); fDocument= document; fEndPosition= fScanner.getSource().length - 1; }
/** * Creates a TokenScanner * @param document The textbuffer to create the scanner on * @param project the current Java project */ public TokenScanner(IDocument document, IJavaProject project) { String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); fScanner= ToolFactory.createScanner(true, false, false, sourceLevel, complianceLevel); // no line info required fScanner.setSource(document.get().toCharArray()); fDocument= document; fEndPosition= fScanner.getSource().length - 1; }
/** * Creates a TokenScanner * @param document The textbuffer to create the scanner on * @param project the current Java project */ public TokenScanner(IDocument document, IJavaProject project) { String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); fScanner= ToolFactory.createScanner(true, false, false, sourceLevel, complianceLevel); // no line info required fScanner.setSource(document.get().toCharArray()); fDocument= document; fEndPosition= fScanner.getSource().length - 1; }
IDocument document= new Document(String.valueOf(scanner.getSource())); for (int i= 0; i < result.length; i++) { setTagPositions(document, result[i]);
IDocument document= new Document(String.valueOf(scanner.getSource())); for (int i= 0; i < result.length; i++) { setTagPositions(document, result[i]);
IDocument document= new Document(String.valueOf(scanner.getSource())); for (int i= 0; i < result.length; i++) { setTagPositions(document, result[i]);
/** * Creates a TokenScanner * @param typeRoot The type root to scan on * @throws CoreException thrown if the buffer cannot be accessed */ public TokenScanner(ITypeRoot typeRoot) throws CoreException { IJavaProject project= typeRoot.getJavaProject(); IBuffer buffer= typeRoot.getBuffer(); if (buffer == null) { throw new CoreException(createError(DOCUMENT_ERROR, "Element has no source", null)); //$NON-NLS-1$ } String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); fScanner= ToolFactory.createScanner(true, false, true, sourceLevel, complianceLevel); // line info required fScanner.setSource(buffer.getCharacters()); fDocument= null; // use scanner for line information fEndPosition= fScanner.getSource().length - 1; }
/** * Creates a TokenScanner * @param cu The compliation unit to can on * @throws JavaModelException thorwn if the buffer cannot be accessed */ public TokenScanner(ICompilationUnit cu) throws JavaModelException { IJavaProject project= cu.getJavaProject(); String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); fScanner= ToolFactory.createScanner(true, false, true, sourceLevel, complianceLevel); // line info required fScanner.setSource(cu.getBuffer().getCharacters()); fDocument= null; // use scanner for line information fEndPosition= fScanner.getSource().length - 1; }
/** * Creates a TokenScanner * @param typeRoot The type root to scan on * @throws CoreException thrown if the buffer cannot be accessed */ public TokenScanner(ITypeRoot typeRoot) throws CoreException { IJavaProject project= typeRoot.getJavaProject(); IBuffer buffer= typeRoot.getBuffer(); if (buffer == null) { throw new CoreException(createError(DOCUMENT_ERROR, "Element has no source", null)); //$NON-NLS-1$ } String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); fScanner= ToolFactory.createScanner(true, false, true, sourceLevel, complianceLevel); // line info required fScanner.setSource(buffer.getCharacters()); fDocument= null; // use scanner for line information fEndPosition= fScanner.getSource().length - 1; }
try { result= (NLSLine[]) lines.toArray(new NLSLine[lines.size()]); IDocument document= new Document(String.valueOf(scanner.getSource())); for (int i= 0; i < result.length; i++) { setTagPositions(document, result[i]);
private void check(RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) { char[] characters= scanner.getSource(); selection= adjustSelection(characters, selection, end); scanner.resetTo(start, end); int token= 0; try { loop: while (token != ITerminalSymbols.TokenNameEOF) { token= scanner.getNextToken(); switch(token) { case ITerminalSymbols.TokenNameCOMMENT_LINE: case ITerminalSymbols.TokenNameCOMMENT_BLOCK: case ITerminalSymbols.TokenNameCOMMENT_JAVADOC: if (checkStart(scanner, selection.getOffset())) { result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment); break loop; } if (checkEnd(scanner, selection.getInclusiveEnd())) { result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment); break loop; } break; } } } catch (InvalidInputException e) { result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error); } }
private void check(RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) { char[] characters= scanner.getSource(); selection= adjustSelection(characters, selection, end); scanner.resetTo(start, end); int token= 0; try { loop: while (token != ITerminalSymbols.TokenNameEOF) { token= scanner.getNextToken(); switch(token) { case ITerminalSymbols.TokenNameCOMMENT_LINE: case ITerminalSymbols.TokenNameCOMMENT_BLOCK: case ITerminalSymbols.TokenNameCOMMENT_JAVADOC: if (checkStart(scanner, selection.getOffset())) { result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment); break loop; } if (checkEnd(scanner, selection.getInclusiveEnd())) { result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment); break loop; } break; } } } catch (InvalidInputException e) { result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error); } }
private void check(RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) { char[] characters= scanner.getSource(); selection= adjustSelection(characters, selection, end); scanner.resetTo(start, end); int token= 0; try { loop: while (token != ITerminalSymbols.TokenNameEOF) { token= scanner.getNextToken(); switch(token) { case ITerminalSymbols.TokenNameCOMMENT_LINE: case ITerminalSymbols.TokenNameCOMMENT_BLOCK: case ITerminalSymbols.TokenNameCOMMENT_JAVADOC: if (checkStart(scanner, selection.getOffset())) { result.addFatalError(JavaManipulationMessages.CommentAnalyzer_starts_inside_comment); break loop; } if (checkEnd(scanner, selection.getInclusiveEnd())) { result.addFatalError(JavaManipulationMessages.CommentAnalyzer_ends_inside_comment); break loop; } break; } } } catch (InvalidInputException e) { result.addFatalError(JavaManipulationMessages.CommentAnalyzer_internal_error); } }