This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 240157
Collapse All | Expand All

(-)a/php.editor/src/org/netbeans/modules/php/editor/PHPBracesMatcher.java (+44 lines)
Lines 79-84 Link Here
79
            TokenSequence<?extends PHPTokenId> ts = LexUtilities.getPHPTokenSequence(doc, offset);
79
            TokenSequence<?extends PHPTokenId> ts = LexUtilities.getPHPTokenSequence(doc, offset);
80
80
81
            if (ts != null) {
81
            if (ts != null) {
82
                // #240157
83
                if (searchForward(ts, offset)){
84
                    return null;
85
                }
86
82
                ts.move(offset);
87
                ts.move(offset);
83
88
84
                if (!ts.moveNext()) {
89
                if (!ts.moveNext()) {
Lines 159-164 Link Here
159
            TokenSequence<?extends PHPTokenId> ts = LexUtilities.getPHPTokenSequence(doc, offset);
164
            TokenSequence<?extends PHPTokenId> ts = LexUtilities.getPHPTokenSequence(doc, offset);
160
165
161
            if (ts != null) {
166
            if (ts != null) {
167
                // #240157
168
                if (searchForward(ts, offset)){
169
                    return null;
170
                }
171
162
                ts.move(offset);
172
                ts.move(offset);
163
173
164
                if (!ts.moveNext()) {
174
                if (!ts.moveNext()) {
Lines 212-215 Link Here
212
        }
222
        }
213
    }
223
    }
214
224
225
    private boolean searchForward(TokenSequence<? extends PHPTokenId> ts, int offset) {
226
        // if there is a brace token just before a caret position, search foward
227
        // e.g. if (isSomething()^), if (isSomething())^{
228
        // "^" is the caret
229
        if (context.isSearchingBackward()) {
230
            ts.move(offset);
231
            if (ts.movePrevious()) {
232
                Token<? extends PHPTokenId> previousToken = ts.token();
233
                if (previousToken != null && isBraceToken(previousToken)) {
234
                    return true;
235
                }
236
            }
237
        }
238
        return false;
239
    }
240
241
    private static boolean isBraceToken(Token<? extends PHPTokenId> token) {
242
        PHPTokenId id = token.id();
243
        return LexUtilities.textEquals(token.text(), '(') // NOI18N
244
                || LexUtilities.textEquals(token.text(), ')') // NOI18N
245
                || id == PHPTokenId.PHP_CURLY_OPEN
246
                || id == PHPTokenId.PHP_CURLY_CLOSE
247
                || LexUtilities.textEquals(token.text(), '[') // NOI18N
248
                || LexUtilities.textEquals(token.text(), ']') // NOI18N
249
                || LexUtilities.textEquals(token.text(), '$', '{') // NOI18N
250
                || LexUtilities.textEquals(token.text(), ':') // NOI18N
251
                || id == PHPTokenId.PHP_ENDFOR
252
                || id == PHPTokenId.PHP_ENDFOREACH
253
                || id == PHPTokenId.PHP_ENDIF
254
                || id == PHPTokenId.PHP_ENDSWITCH
255
                || id == PHPTokenId.PHP_ENDWHILE
256
                || id == PHPTokenId.PHP_ELSEIF
257
                || id == PHPTokenId.PHP_ELSE;
258
    }
215
}
259
}

Return to bug 240157