Changeset 1245


Ignore:
Timestamp:
Jul 21, 2011, 10:51:51 PM (6 years ago)
Author:
stefan
Message:
 
Location:
trunk/src/jlatexeditor/codehelper
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/codehelper/CommandsCodeHelper.java

    r1241 r1245  
    5151    }
    5252    return false;
    53   }
    54 
    55   @Override
    56   public WordWithPos getWordToReplace() {
    57     return word;
    58   }
    59 
    60   @Override
    61   public String getMaxCommonPrefix() {
    62     return getMaxCommonPrefix(word.word);
    6353  }
    6454
  • trunk/src/jlatexeditor/codehelper/DocumentClassCodeHelper.java

    r1241 r1245  
    3838  }
    3939
    40   @Override
    41   public WordWithPos getWordToReplace() {
    42     return word;
    43   }
    44 
    45   @Override
    46   public String getMaxCommonPrefix() {
    47     return getMaxCommonPrefix(word.word);
    48   }
    49 
    5040  public Iterable<CHCommand> getCompletions(String search, Function1<PackagesExtractor.Package, Boolean> filterFun) {
    5141    List<String> docClassNames = PackagesExtractor.getDocClassesParser().getPackages().getObjectsIterable(search).filter(filterFun).map(PACKAGE_2_NAME_FUNCTION).toList(20);
     
    6757
    6858  public String getMaxCommonPrefix(String search) {
    69     return search;
     59    String maxCommonPrefix = PackagesExtractor.getPackageParser().getPackages().getMaxCommonPrefix(search);
     60    if (maxCommonPrefix.length() > search.length()) {
     61      return maxCommonPrefix;
     62    }
     63    return search;
    7064  }
    7165}
  • trunk/src/jlatexeditor/codehelper/EnvironmentCodeHelper.java

    r1241 r1245  
    88import sce.codehelper.PatternPair;
    99import sce.codehelper.WordWithPos;
     10import util.AbstractTrie;
    1011import util.Function1;
    1112import util.TrieSet;
     13
     14import java.util.Arrays;
     15import java.util.List;
    1216
    1317/**
     
    4347  }
    4448
    45   @Override
    46   public WordWithPos getWordToReplace() {
    47     return word;
    48   }
    49 
    50   @Override
    51   public String getMaxCommonPrefix() {
    52     return getMaxCommonPrefix(word.word);
    53   }
    54 
    5549  public Iterable<CHCommand> getCompletions(String search, Function1<TrieSet<PackagesExtractor.Environment>, Boolean> filterFunc) {
    5650    ExtIterable<String> userIter = SCEManager.getBackgroundParser().getEnvironments().getObjectsIterable(search).map(ENVIRONMENT_2_STRING_FUNCTION);
     
    7165
    7266  public String getMaxCommonPrefix(String search) {
    73     // TODO
    74     return search;
     67    List<AbstractTrie<? extends Object>> tries = Arrays.asList(
     68      SCEManager.getBackgroundParser().getEnvironments(),
     69      PackagesExtractor.getPackageParser().getEnvironments(),
     70      PackagesExtractor.getDocClassesParser().getEnvironments()
     71    );
     72
     73    String maxPrefix = null;
     74    for (AbstractTrie<? extends Object> trie : tries) {
     75      String maxCommonPrefix = trie.getMaxCommonPrefix(search);
     76      if (maxCommonPrefix.length() >= search.length()) {
     77        if (maxPrefix == null) {
     78          maxPrefix = maxCommonPrefix;
     79        } else {
     80          maxPrefix = maxCommonPrefix(maxPrefix, maxCommonPrefix);
     81        }
     82      }
     83    }
     84
     85    return maxPrefix;
    7586  }
    7687}
  • trunk/src/jlatexeditor/codehelper/ExtPatternHelper.java

    r1241 r1245  
    3535
    3636  @Override
     37  public WordWithPos getWordToReplace() {
     38    return word;
     39  }
     40
     41  @Override
    3742  public Iterable<? extends CHCommand> getCompletions(int level) {
    3843    int minUsageCount = GProperties.getInt("editor.completion." + type + ".filter.level" + level);
    3944    return getCompletions(word.word, minUsage(minUsageCount));
    4045  }
     46
     47  @Override
     48  public String getMaxCommonPrefix() {
     49    return getMaxCommonPrefix(word.word);
     50  }
     51
     52  protected abstract String getMaxCommonPrefix(String search);
    4153
    4254  protected abstract Iterable<CHCommand> getCompletions(String search, Function1<T, Boolean> filterFunc);
  • trunk/src/jlatexeditor/codehelper/UsePackageCodeHelper.java

    r1241 r1245  
    4141  }
    4242
    43   @Override
    44   public WordWithPos getWordToReplace() {
    45     return word;
    46   }
    47 
    48   @Override
    49   public String getMaxCommonPrefix() {
    50     return getMaxCommonPrefix(word.word);
    51   }
    52 
    5343  public Iterable<CHCommand> getCompletions(String search, Function1<PackagesExtractor.Package, Boolean> filterFunc) {
    5444    ExtIterable<PackagesExtractor.Package> packIter = PackagesExtractor.getPackageParser().getPackages().getObjectsIterable(search);
     
    6858
    6959  public String getMaxCommonPrefix(String search) {
     60    String maxCommonPrefix = PackagesExtractor.getPackageParser().getPackages().getMaxCommonPrefix(search);
     61    if (maxCommonPrefix.length() > search.length()) {
     62      return maxCommonPrefix;
     63    }
    7064    return search;
    7165  }
Note: See TracChangeset for help on using the changeset viewer.