@@ -121,43 +121,44 @@ protected void query(CompletionResultSet completionResultSet, Document doc, int
121121 return ;
122122 }
123123 ts .move (caretOffset );
124- ts .moveNext ();
125- Token <PHPTokenId > token = ts .token ();
126- if (token .id () != PHPTokenId .PHP_CONSTANT_ENCAPSED_STRING ) {
127- return ;
128- }
129- String caretInput = ts .token ().text ().toString ();
124+ if ( ts .moveNext ()) {
125+ Token <PHPTokenId > token = ts .token ();
126+ if (token .id () != PHPTokenId .PHP_CONSTANT_ENCAPSED_STRING ) {
127+ return ;
128+ }
129+ String caretInput = ts .token ().text ().toString ();
130130
131- int startOffset = ts .offset () + 1 ;
132- int removeLength = caretInput .length () - 2 ;
133- if (removeLength < 0 ) {
134- removeLength = 0 ;
135- }
136- int length = caretInput .length ();
131+ int startOffset = ts .offset () + 1 ;
132+ int removeLength = caretInput .length () - 2 ;
133+ if (removeLength < 0 ) {
134+ removeLength = 0 ;
135+ }
136+ int length = caretInput .length ();
137137
138- // check whether funciton is add_filter
139- if (!isValidCompletion (ts ) || length < 2 ) {
140- return ;
141- }
138+ // check whether funciton is add_filter
139+ if (!isValidCompletion (ts ) || length < 2 ) {
140+ return ;
141+ }
142142
143- // filter
144- int substrLength = caretOffset - startOffset + 1 ;
145- String filter = "" ; // NOI18N
146- if (substrLength > 1 ) {
147- filter = caretInput .substring (1 , substrLength );
148- }
149- currentInput = filter ;
150-
151- // set isAction and isFilter
152- List <WordPressCompletionItem > completions = getCodeCompletionList (phpModule );
153-
154- if (isAction || isFilter ) {
155- for (WordPressCompletionItem completion : completions ) {
156- String text = completion .getText ();
157- if (!text .isEmpty ()
158- && text .startsWith (filter )) {
159- completion .setOffset (startOffset , removeLength );
160- completionResultSet .addItem (completion );
143+ // filter
144+ int substrLength = caretOffset - startOffset + 1 ;
145+ String filter = "" ; // NOI18N
146+ if (substrLength > 1 ) {
147+ filter = caretInput .substring (1 , substrLength );
148+ }
149+ currentInput = filter ;
150+
151+ // set isAction and isFilter
152+ List <WordPressCompletionItem > completions = getCodeCompletionList (phpModule );
153+
154+ if (isAction || isFilter ) {
155+ for (WordPressCompletionItem completion : completions ) {
156+ String text = completion .getText ();
157+ if (!text .isEmpty ()
158+ && text .startsWith (filter )) {
159+ completion .setOffset (startOffset , removeLength );
160+ completionResultSet .addItem (completion );
161+ }
161162 }
162163 }
163164 }
0 commit comments