From df69195be74e950649ea3a225f8731304616b05a Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Sun, 15 Sep 2013 02:42:47 +0530 Subject: [PATCH] prediction length added --- pdex/src/processing/mode/experimental/ASTGenerator.java | 4 +++- pdex/src/processing/mode/experimental/TextArea.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index c8ae6795b..ede894eca 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -780,9 +780,11 @@ public class ASTGenerator { protected ArrayList 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); diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 77e26b5cc..6b2dd7a19 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -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;