private boolean checkGenericsHeuristic(IDocument document, int end, int bound) { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); return scanner.looksLikeClassInstanceCreationBackward(end, bound); }
private boolean checkGenericsHeuristic(IDocument document, int end, int bound) throws BadLocationException { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); return scanner.looksLikeClassInstanceCreationBackward(end, bound); }
private boolean checkGenericsHeuristic(IDocument document, int end, int bound) { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); return scanner.looksLikeClassInstanceCreationBackward(end, bound); }
/** * Returns <code>true</code> if the character at the specified offset is a less-than sign, rather than * the opening angle bracket of a type parameter list. * * @param document a document * @param offset an offset within the document * @return <code>true</code> if the character at the specified offset is a less-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterOpeningBracket(offset, document, scanner); }
/** * Returns true if the character at the specified offset is a greater-than sign, rather than an * type parameter list close angle bracket. * * @param document a document * @param offset an offset within the document * @return true if the character at the specified offset is a greater-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isGreaterThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterClosingBracket(offset, document, scanner); }
/** * Returns <code>true</code> if the character at the specified offset is a less-than sign, rather than * the opening angle bracket of a type parameter list. * * @param document a document * @param offset an offset within the document * @return <code>true</code> if the character at the specified offset is a less-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterOpeningBracket(offset, document, scanner); }
/** * Returns true if the character at the specified offset is a greater-than sign, rather than an * type parameter list close angle bracket. * * @param document a document * @param offset an offset within the document * @return true if the character at the specified offset is a greater-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isGreaterThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterClosingBracket(offset, document, scanner); }
/** * Returns true if the character at the specified offset is a * less-than sign, rather than an type parameter list open * angle bracket. * * @param document a document * @param offset an offset within the document * @return true if the character at the specified offset is not * a type parameter start bracket * @throws BadLocationException */ private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false)); return !isTypeParameterBracket(offset, document, scanner); }
private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset) { try { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); IRegion sourceRange= scanner.findSurroundingBlock(offset); if (sourceRange == null) return null; String source= document.get(sourceRange.getOffset(), sourceRange.getLength()); StringBuffer contents= new StringBuffer(); contents.append("class ____C{void ____m()"); //$NON-NLS-1$ final int methodOffset= contents.length(); contents.append(source); contents.append('}'); char[] buffer= contents.toString().toCharArray(); return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; }
private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset) { try { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); IRegion sourceRange= scanner.findSurroundingBlock(offset); if (sourceRange == null) return null; String source= document.get(sourceRange.getOffset(), sourceRange.getLength()); StringBuffer contents= new StringBuffer(); contents.append("class ____C{void ____m()"); //$NON-NLS-1$ final int methodOffset= contents.length(); contents.append(source); contents.append('}'); char[] buffer= contents.toString().toCharArray(); return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; }
private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) { try { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); IRegion sourceRange= scanner.findSurroundingBlock(offset); if (sourceRange == null) return null; String source= document.get(sourceRange.getOffset(), sourceRange.getLength()); StringBuffer contents= new StringBuffer(); contents.append("class ____C{void ____m()"); //$NON-NLS-1$ final int methodOffset= contents.length(); contents.append(source); contents.append('}'); char[] buffer= contents.toString().toCharArray(); return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; }
protected final int guessMethodContextInformationPosition(ContentAssistInvocationContext context) { final int contextPosition= context.getInvocationOffset(); IDocument document= context.getDocument(); JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); int bound= Math.max(-1, contextPosition - 2000); // try the innermost scope of parentheses that looks like a method call int pos= contextPosition - 1; do { int paren= scanner.findOpeningPeer(pos, bound, '(', ')'); if (paren == JavaHeuristicScanner.NOT_FOUND) break; int token= scanner.previousToken(paren - 1, bound); // next token must be a method name (identifier) or the closing angle of a // constructor call of a parameterized type. if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) return paren + 1; pos= paren - 1; } while (true); return contextPosition; }
protected final int guessMethodContextInformationPosition(ContentAssistInvocationContext context) { final int contextPosition= context.getInvocationOffset(); IDocument document= context.getDocument(); JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); int bound= Math.max(-1, contextPosition - 2000); // try the innermost scope of parentheses that looks like a method call int pos= contextPosition - 1; do { int paren= scanner.findOpeningPeer(pos, bound, '(', ')'); if (paren == JavaHeuristicScanner.NOT_FOUND) break; int token= scanner.previousToken(paren - 1, bound); // next token must be a method name (identifier) or the closing angle of a // constructor call of a parameterized type. if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) return paren + 1; pos= paren - 1; } while (true); return contextPosition; }
/** * Returns the block balance, i.e. zero if the blocks are balanced at <code>offset</code>, a * negative number if there are more closing than opening braces, and a positive number if there * are more opening than closing braces. * * @param document the document * @param offset the offset * @param partitioning the partitioning * @return the block balance */ private static int getBlockBalance(IDocument document, int offset, String partitioning) { if (offset < 1) return -1; if (offset >= document.getLength()) return 1; int begin= offset; int end= offset - 1; JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); while (true) { begin= scanner.findOpeningPeer(begin - 1, '{', '}'); end= scanner.findClosingPeer(end + 1, '{', '}'); if (begin == -1 && end == -1) return 0; if (begin == -1) return -1; if (end == -1) return 1; } }
/** * Returns the block balance, i.e. zero if the blocks are balanced at * <code>offset</code>, a negative number if there are more closing than opening * braces, and a positive number if there are more opening than closing braces. * * @param document * @param offset * @param partitioning * @return the block balance */ private static int getBlockBalance(IDocument document, int offset, String partitioning) { if (offset < 1) return -1; if (offset >= document.getLength()) return 1; int begin= offset; int end= offset - 1; JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); while (true) { begin= scanner.findOpeningPeer(begin - 1, '{', '}'); end= scanner.findClosingPeer(end + 1, '{', '}'); if (begin == -1 && end == -1) return 0; if (begin == -1) return -1; if (end == -1) return 1; } }
/** * Returns the block balance, i.e. zero if the blocks are balanced at <code>offset</code>, a * negative number if there are more closing than opening braces, and a positive number if there * are more opening than closing braces. * * @param document the document * @param offset the offset * @param partitioning the partitioning * @return the block balance */ private static int getBlockBalance(IDocument document, int offset, String partitioning) { if (offset < 1) return -1; if (offset >= document.getLength()) return 1; int begin= offset; int end= offset - 1; JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); while (true) { begin= scanner.findOpeningPeer(begin - 1, '{', '}'); end= scanner.findClosingPeer(end + 1, '{', '}'); if (begin == -1 && end == -1) return 0; if (begin == -1) return -1; if (end == -1) return 1; } }
protected int guessContextInformationPosition(ContentAssistInvocationContext context) { final int contextPosition= context.getInvocationOffset(); IDocument document= context.getDocument(); JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); int bound= Math.max(-1, contextPosition - 200); // try the innermost scope of parentheses that looks like a method call int pos= contextPosition - 1; do { int paren= scanner.findOpeningPeer(pos, bound, '(', ')'); if (paren == JavaHeuristicScanner.NOT_FOUND) break; int token= scanner.previousToken(paren - 1, bound); // next token must be a method name (identifier) or the closing angle of a // constructor call of a parameterized type. if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) return paren + 1; pos= paren - 1; } while (true); return super.guessContextInformationPosition(context); } }
@Override protected int guessContextInformationPosition(ContentAssistInvocationContext context) { final int contextPosition= context.getInvocationOffset(); IDocument document= context.getDocument(); JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); int bound= Math.max(-1, contextPosition - 200); // try the innermost scope of angle brackets that looks like a generic type argument list try { int pos= contextPosition - 1; do { int angle= scanner.findOpeningPeer(pos, bound, '<', '>'); if (angle == JavaHeuristicScanner.NOT_FOUND) break; int token= scanner.previousToken(angle - 1, bound); // next token must be a method name that is a generic type if (token == Symbols.TokenIDENT) { int off= scanner.getPosition() + 1; int end= angle; String ident= document.get(off, end - off).trim(); if (JavaHeuristicScanner.isGenericStarter(ident)) return angle + 1; } pos= angle - 1; } while (true); } catch (BadLocationException x) { } return super.guessContextInformationPosition(context); }
protected int guessContextInformationPosition(ContentAssistInvocationContext context) { final int contextPosition= context.getInvocationOffset(); IDocument document= context.getDocument(); JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); int bound= Math.max(-1, contextPosition - 200); // try the innermost scope of angle brackets that looks like a generic type argument list try { int pos= contextPosition - 1; do { int angle= scanner.findOpeningPeer(pos, bound, '<', '>'); if (angle == JavaHeuristicScanner.NOT_FOUND) break; int token= scanner.previousToken(angle - 1, bound); // next token must be a method name that is a generic type if (token == Symbols.TokenIDENT) { int off= scanner.getPosition() + 1; int end= angle; String ident= document.get(off, end - off).trim(); if (JavaHeuristicScanner.isGenericStarter(ident)) return angle + 1; } pos= angle - 1; } while (true); } catch (BadLocationException x) { } return super.guessContextInformationPosition(context); }
@Override protected int guessContextInformationPosition(ContentAssistInvocationContext context) { final int contextPosition= context.getInvocationOffset(); IDocument document= context.getDocument(); JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); int bound= Math.max(-1, contextPosition - 200); // try the innermost scope of angle brackets that looks like a generic type argument list try { int pos= contextPosition - 1; do { int angle= scanner.findOpeningPeer(pos, bound, '<', '>'); if (angle == JavaHeuristicScanner.NOT_FOUND) break; int token= scanner.previousToken(angle - 1, bound); // next token must be a method name that is a generic type if (token == Symbols.TokenIDENT) { int off= scanner.getPosition() + 1; int end= angle; String ident= document.get(off, end - off).trim(); if (JavaHeuristicScanner.isGenericStarter(ident)) return angle + 1; } pos= angle - 1; } while (true); } catch (BadLocationException x) { } return super.guessContextInformationPosition(context); }