public Result getMatchingEntries(int cursorPos, PeekingIterator<Character> chars) {
   String possibleClass = getPossibleClass(chars);
   if (isClass(possibleClass)) {
     currentClass = possibleClass;
     return Result.withEntries(cursorPos, getEntries(possibleClass));
   } else {
     return Result.empty(cursorPos);
   }
 }
 /**
  * Returns the possible entries for an incomplete line, when the autocomplete isn't triggered by a
  * ., but by ctrl-space. For example, it could be called for a line like "FooClass.ba", and we
  * want to return all entries in FooClass that start with "ba". Similarily, calling this method
  * for a line like "SomeB" should return completions for beans whose names start with that prefix,
  * e.g., "SomeBean".
  *
  * @param cursorPos
  * @param chars a reverse character iterator
  */
 public Result getEntriesForIncompleteString(int cursorPos, PeekingIterator<Character> chars) {
   // Traverse the chars until you find the period. If you find a non-letter or digit char before
   // the period, attempt top-level completion instead of member completion.
   String suffix = "";
   while (chars.hasNext() && JavaScriptIdentifierNames.isIdentifierNameCharacter(chars.peek())) {
     suffix = chars.next() + suffix;
   }
   while (chars.hasNext() && Character.isWhitespace(chars.peek())) {
     chars.next();
   }
   if (chars.hasNext() && chars.next() == '.') {
     String possibleClass = getPossibleClass(chars);
     if (isClass(possibleClass)) {
       currentClass = possibleClass;
       return getMatchingEntries(cursorPos - suffix.length(), suffix);
     }
     return Result.empty(cursorPos);
   } else {
     currentClass = null;
     return getMatchingEntries(cursorPos - suffix.length(), suffix);
   }
 }
예제 #3
0
파일: Heap.java 프로젝트: jmgimeno/fpinjava
 public static <A extends Comparable<A>> Heap<A> heap(A element) {
   return heap(element, Result.empty());
 }
예제 #4
0
파일: Heap.java 프로젝트: jmgimeno/fpinjava
 public static <A extends Comparable<A>> Heap<A> empty() {
   return empty(Result.empty());
 }