/** * Checks whether the content of <code>document</code> at <code>position</code> looks like an * anonymous class definition. <code>position</code> must be to the left of the opening * parenthesis of the definition's parameter list. * * @param document the document being modified * @param partitioning the document partitioning * @param scanner the scanner * @param position the first character position in <code>document</code> to be considered * @return <code>true</code> if the content of <code>document</code> looks like an anonymous class * definition, <code>false</code> otherwise */ private static boolean looksLikeAnonymousClassDef( IDocument document, String partitioning, JavaHeuristicScanner scanner, int position) { int previousCommaParenEqual = scanner.scanBackward( position - 1, JavaHeuristicScanner.UNBOUND, new char[] {',', '(', '='}); if (previousCommaParenEqual == -1 || position < previousCommaParenEqual + 5) // 2 for borders, 3 for "new" return false; if (isNewMatch( document, previousCommaParenEqual + 1, position - previousCommaParenEqual - 2, partitioning)) return true; return false; }