code completion filtering, substitution after default and custom Smarty delimiters
1.1 --- a/php.smarty/src/org/netbeans/modules/php/smarty/SmartyFramework.java Fri Jun 11 15:31:52 2010 +0200
1.2 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/SmartyFramework.java Mon Jun 14 10:39:20 2010 +0200
1.3 @@ -39,9 +39,11 @@
1.4
1.5 package org.netbeans.modules.php.smarty;
1.6
1.7 +import org.netbeans.modules.php.api.phpmodule.PhpModule;
1.8 import org.netbeans.modules.php.api.phpmodule.PhpProgram;
1.9 import org.netbeans.modules.php.api.util.UiUtils;
1.10 import org.netbeans.modules.php.smarty.ui.options.SmartyOptions;
1.11 +import org.openide.filesystems.FileObject;
1.12
1.13
1.14 /**
1.15 @@ -86,6 +88,21 @@
1.16 return OPTIONS_SUB_PATH;
1.17 }
1.18
1.19 + public static String getCloseDelimiter(FileObject fileObject) {
1.20 + if (!SmartyPhpModuleCustomizerExtender.getCustomCloseDelimiter(PhpModule.forFileObject(fileObject)).isEmpty()) {
1.21 + return SmartyPhpModuleCustomizerExtender.getCustomCloseDelimiter(PhpModule.forFileObject(fileObject));
1.22 + } else {
1.23 + return DELIMITER_DEFAULT_CLOSE;
1.24 + }
1.25 + }
1.26
1.27 + public static String getOpenDelimiter(FileObject fileObject) {
1.28 + if (!SmartyPhpModuleCustomizerExtender.getCustomOpenDelimiter(PhpModule.forFileObject(fileObject)).isEmpty()) {
1.29 + return SmartyPhpModuleCustomizerExtender.getCustomOpenDelimiter(PhpModule.forFileObject(fileObject));
1.30 + } else {
1.31 + return DELIMITER_DEFAULT_OPEN;
1.32 + }
1.33 +
1.34 + }
1.35
1.36 }
2.1 --- a/php.smarty/src/org/netbeans/modules/php/smarty/editor/completion/CodeCompletionUtils.java Fri Jun 11 15:31:52 2010 +0200
2.2 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/editor/completion/CodeCompletionUtils.java Mon Jun 14 10:39:20 2010 +0200
2.3 @@ -42,7 +42,12 @@
2.4 import java.util.Locale;
2.5 import javax.swing.text.BadLocationException;
2.6 import javax.swing.text.Document;
2.7 +import org.netbeans.modules.editor.NbEditorDocument;
2.8 +import org.netbeans.modules.editor.NbEditorUtilities;
2.9 +import org.netbeans.modules.php.smarty.SmartyFramework;
2.10 +import org.netbeans.modules.php.smarty.SmartyPhpModuleCustomizerExtender;
2.11 import org.netbeans.modules.php.smarty.editor.utlis.LexerUtils;
2.12 +import org.netbeans.modules.php.smarty.ui.options.SmartyOptions;
2.13 import org.openide.util.Exceptions;
2.14
2.15 /**
2.16 @@ -57,6 +62,10 @@
2.17 int readLength = (COMPLETION_MAX_FILTER_LENGHT > offset) ? offset : COMPLETION_MAX_FILTER_LENGHT;
2.18 try {
2.19 int lastWS = getLastWS(doc.getText(offset - readLength, readLength));
2.20 + String preWord = doc.getText(offset - lastWS, lastWS);
2.21 + if (preWord.startsWith(SmartyFramework.getOpenDelimiter(NbEditorUtilities.getFileObject(doc)))) {
2.22 + return preWord.substring(SmartyFramework.getOpenDelimiter(NbEditorUtilities.getFileObject(doc)).length());
2.23 + }
2.24 return doc.getText(offset - lastWS, lastWS);
2.25 } catch (BadLocationException ex) {
2.26 Exceptions.printStackTrace(ex);