use of org.eclipse.jdt.core.compiler.InvalidInputException in project che by eclipse.
the class CommentAnalyzer method normalizeReference.
/**
* Removes comments and whitespace
* @param reference the type reference
* @return the reference only consisting of dots and java identifier characters
*/
public static String normalizeReference(String reference) {
IScanner scanner = ToolFactory.createScanner(false, false, false, false);
scanner.setSource(reference.toCharArray());
StringBuffer sb = new StringBuffer();
try {
int tokenType = scanner.getNextToken();
while (tokenType != ITerminalSymbols.TokenNameEOF) {
sb.append(scanner.getRawTokenSource());
tokenType = scanner.getNextToken();
}
} catch (InvalidInputException e) {
Assert.isTrue(false, reference);
}
reference = sb.toString();
return reference;
}
use of org.eclipse.jdt.core.compiler.InvalidInputException in project che by eclipse.
the class Util method isJustWhitespaceOrComment.
private static boolean isJustWhitespaceOrComment(int start, int end, IBuffer buffer) {
if (start == end)
return true;
Assert.isTrue(start <= end);
String trimmedText = buffer.getText(start, end - start).trim();
if (0 == trimmedText.length()) {
return true;
} else {
IScanner scanner = ToolFactory.createScanner(false, false, false, null);
scanner.setSource(trimmedText.toCharArray());
try {
return scanner.getNextToken() == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
return false;
}
}
}
Aggregations