private int readName(IScanner scanner, StringBuilder buf) throws InvalidInputException { int tok= scanner.getNextToken(); while (tok == ITerminalSymbols.TokenNameIdentifier) { buf.append(scanner.getCurrentTokenSource()); tok= scanner.getNextToken(); if (tok != ITerminalSymbols.TokenNameDOT) { return tok; } buf.append('.'); tok= scanner.getNextToken(); } return tok; }
private int readName(IScanner scanner, StringBuffer buf) throws InvalidInputException { int tok= scanner.getNextToken(); while (tok == ITerminalSymbols.TokenNameIdentifier) { buf.append(scanner.getCurrentTokenSource()); tok= scanner.getNextToken(); if (tok != ITerminalSymbols.TokenNameDOT) { return tok; } buf.append('.'); tok= scanner.getNextToken(); } return tok; }
private static void parseTags(NLSLine line, IScanner scanner) { String s= new String(scanner.getCurrentTokenSource()); int pos= s.indexOf(NLSElement.TAG_PREFIX); while (pos != -1) { int start= pos + NLSElement.TAG_PREFIX_LENGTH; int end= s.indexOf(NLSElement.TAG_POSTFIX, start); if (end < 0) return; //no error recovery String index= s.substring(start, end); int i= 0; try { i= Integer.parseInt(index) - 1; // Tags are one based not zero based. } catch (NumberFormatException e) { return; //ignore the exception - no error recovery } if (line.exists(i)) { NLSElement element= line.get(i); element.setTagPosition(scanner.getCurrentTokenStartPosition() + pos, end - pos + 1); } else { return; //no error recovery } pos= s.indexOf(NLSElement.TAG_PREFIX, start); } }
private static void parseTags(NLSLine line, IScanner scanner) { String s= new String(scanner.getCurrentTokenSource()); int pos= s.indexOf(NLSElement.TAG_PREFIX); while (pos != -1) { int start= pos + NLSElement.TAG_PREFIX_LENGTH; int end= s.indexOf(NLSElement.TAG_POSTFIX, start); if (end < 0) return; //no error recovery String index= s.substring(start, end); int i= 0; try { i= Integer.parseInt(index) - 1; // Tags are one based not zero based. } catch (NumberFormatException e) { return; //ignore the exception - no error recovery } if (line.exists(i)) { NLSElement element= line.get(i); element.setTagPosition(scanner.getCurrentTokenStartPosition() + pos, end - pos + 1); } else { return; //no error recovery } pos= s.indexOf(NLSElement.TAG_PREFIX, start); } }
private static void parseTags(NLSLine line, IScanner scanner) { String s= new String(scanner.getCurrentTokenSource()); int pos= s.indexOf(NLSElement.TAG_PREFIX); while (pos != -1) { int start= pos + NLSElement.TAG_PREFIX_LENGTH; int end= s.indexOf(NLSElement.TAG_POSTFIX, start); if (end < 0) { return; //no error recovery } String index= s.substring(start, end); int i= 0; try { i= Integer.parseInt(index) - 1; // Tags are one based not zero based. } catch (NumberFormatException e) { return; //ignore the exception - no error recovery } if (line.exists(i)) { NLSElement element= line.get(i); element.setTagPosition(scanner.getCurrentTokenStartPosition() + pos, end - pos + 1); } else { return; //no error recovery } pos= s.indexOf(NLSElement.TAG_PREFIX, start); } }
private static void parseTags(NLSLine line, IScanner scanner) { String s= new String(scanner.getCurrentTokenSource()); int pos= s.indexOf(NLSElement.TAG_PREFIX); while (pos != -1) { int start= pos + NLSElement.TAG_PREFIX_LENGTH; int end= s.indexOf(NLSElement.TAG_POSTFIX, start); if (end < 0) return; //no error recovery String index= s.substring(start, end); int i= 0; try { i= Integer.parseInt(index) - 1; // Tags are one based not zero based. } catch (NumberFormatException e) { return; //ignore the exception - no error recovery } if (line.exists(i)) { NLSElement element= line.get(i); element.setTagPosition(scanner.getCurrentTokenStartPosition() + pos, end - pos + 1); } else { return; //no error recovery } pos= s.indexOf(NLSElement.TAG_PREFIX, start); } }
int token; while ((token= scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) { char[] currentTokenSource= scanner.getCurrentTokenSource(); switch (token) { case ITerminalSymbols.TokenNameCOMMENT_LINE:
int token; while ((token= scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) { char[] currentTokenSource= scanner.getCurrentTokenSource(); switch (token) { case ITerminalSymbols.TokenNameCOMMENT_LINE:
break; default: buf.append(scanner.getCurrentTokenSource()); buf.append(' '); break;
private IPath getPackagePath(String source) throws InvalidInputException { IScanner scanner= ToolFactory.createScanner(false, false, false, false); scanner.setSource(source.toCharArray()); scanner.resetTo(0, source.length() - 1); int tok= scanner.getNextToken(); if (tok != ITerminalSymbols.TokenNamepackage) { return null; } IPath res= Path.EMPTY; do { tok= scanner.getNextToken(); if (tok == ITerminalSymbols.TokenNameIdentifier) { res= res.append(new String(scanner.getCurrentTokenSource())); } else { return res; } tok= scanner.getNextToken(); } while (tok == ITerminalSymbols.TokenNameDOT); return res; }
nlsElementIndex= 0; String value= new String(scanner.getCurrentTokenSource()); currentLine.add( new NLSElement(
nlsElementIndex= 0; String value= new String(scanner.getCurrentTokenSource()); currentLine.add( new NLSElement(
nlsElementIndex= 0; String value= new String(scanner.getCurrentTokenSource()); currentLine.add( new NLSElement(
nlsElementIndex= 0; String value= new String(scanner.getCurrentTokenSource()); currentLine.add( new NLSElement(
return null; String src= new String(scanner.getCurrentTokenSource()); int keyStart= scanner.getCurrentTokenStartPosition(); int keyEnd= scanner.getCurrentTokenEndPosition();
return null; String src= new String(scanner.getCurrentTokenSource()); int tokenStart= scanner.getCurrentTokenStartPosition(); int tokenEnd= scanner.getCurrentTokenEndPosition();
return null; String src= new String(scanner.getCurrentTokenSource()); int tokenStart= scanner.getCurrentTokenStartPosition(); int tokenEnd= scanner.getCurrentTokenEndPosition();
protected void checkSelectedNodes() { ASTNode[] nodes= getSelectedNodes(); if (nodes.length == 0) return; ASTNode node= nodes[0]; int selectionOffset= getSelection().getOffset(); try { int start= fScanner.getNextStartOffset(selectionOffset, true); if (start == node.getStartPosition()) { int lastNodeEnd= ASTNodes.getExclusiveEnd(nodes[nodes.length - 1]); int pos= fScanner.getNextStartOffset(lastNodeEnd, true); int selectionEnd= getSelection().getInclusiveEnd(); if (pos <= selectionEnd) { IScanner scanner= fScanner.getScanner(); char[] token= scanner.getCurrentTokenSource(); //see https://bugs.eclipse.org/324237 if (start < lastNodeEnd && token.length == 1 && (token[0] == ';' || token[0] == ',')) { setSelection(Selection.createFromStartEnd(start, lastNodeEnd - 1)); } else { ISourceRange range= new SourceRange(lastNodeEnd, pos - lastNodeEnd); invalidSelection(JavaManipulationMessages.StatementAnalyzer_end_of_selection, JavaStatusContext.create(fCUnit, range)); } } return; // success } } catch (CoreException e) { // fall through } ISourceRange range= new SourceRange(selectionOffset, node.getStartPosition() - selectionOffset + 1); invalidSelection(JavaManipulationMessages.StatementAnalyzer_beginning_of_selection, JavaStatusContext.create(fCUnit, range)); }
protected void checkSelectedNodes() { ASTNode[] nodes= getSelectedNodes(); if (nodes.length == 0) return; ASTNode node= nodes[0]; int selectionOffset= getSelection().getOffset(); try { int start= fScanner.getNextStartOffset(selectionOffset, true); if (start == node.getStartPosition()) { int lastNodeEnd= ASTNodes.getExclusiveEnd(nodes[nodes.length - 1]); int pos= fScanner.getNextStartOffset(lastNodeEnd, true); int selectionEnd= getSelection().getInclusiveEnd(); if (pos <= selectionEnd) { IScanner scanner= fScanner.getScanner(); char[] token= scanner.getCurrentTokenSource(); //see https://bugs.eclipse.org/324237 if (start < lastNodeEnd && token.length == 1 && (token[0] == ';' || token[0] == ',')) { setSelection(Selection.createFromStartEnd(start, lastNodeEnd - 1)); } else { ISourceRange range= new SourceRange(lastNodeEnd, pos - lastNodeEnd); invalidSelection(RefactoringCoreMessages.StatementAnalyzer_end_of_selection, JavaStatusContext.create(fCUnit, range)); } } return; // success } } catch (CoreException e) { // fall through } ISourceRange range= new SourceRange(selectionOffset, node.getStartPosition() - selectionOffset + 1); invalidSelection(RefactoringCoreMessages.StatementAnalyzer_beginning_of_selection, JavaStatusContext.create(fCUnit, range)); }