prediction length added

This commit is contained in:
Manindra Moharana
2013-09-15 02:42:47 +05:30
parent 4dceb7dda7
commit df69195be7
2 changed files with 4 additions and 2 deletions
@@ -780,9 +780,11 @@ public class ASTGenerator {
protected ArrayList<CompletionCandidate> candidates;
protected String lastPredictedWord = " ";
protected AtomicBoolean predictionsEnabled;
protected int predictionMinLength = 3;
public void preparePredictions(final String word, final int line, final int lineStartNonWSOffset) {
if(!predictionsEnabled.get()) return;
if(word.length() < predictionMinLength) return;
// This method is called from TextArea.fetchPhrase, which is called via a SwingWorker instance
// in TextArea.processKeyEvent
if(caretWithinLineComment()){
@@ -809,7 +811,7 @@ public class ASTGenerator {
noCompare = true;
}
if (word2.length() > 2 && !noCompare
if (word2.length() >= predictionMinLength && !noCompare
&& word2.length() > lastPredictedWord.length()) {
if (word2.startsWith(lastPredictedWord)) {
log(word + " starts with " + lastPredictedWord);
@@ -303,7 +303,7 @@ public class TextArea extends JEditTextArea {
word = word.trim();
if (word.endsWith("."))
word = word.substring(0, word.length() - 1);
if(word.length() > 1)
errorCheckerService.getASTGenerator().preparePredictions(word, line
+ errorCheckerService.mainClassOffset,0);
return word;