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.

Bug 142675 - NullPointerException at org.netbeans.modules.php.editor.PHPCodeCompletion.findCompletionContext
Summary: NullPointerException at org.netbeans.modules.php.editor.PHPCodeCompletion.fin...
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Petr Pisl
URL: http://statistics.netbeans.org/except...
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2008-08-02 11:34 UTC by vieiro
Modified: 2008-09-25 11:27 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 85543


Attachments
stacktrace (1.28 KB, text/plain)
2008-08-02 11:34 UTC, vieiro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vieiro 2008-08-02 11:34:27 UTC
Build: NetBeans IDE Dev (Build 200807040101)
VM: Java HotSpot(TM) Client VM, 10.0-b22, Java(TM) SE Runtime Environment, 1.6.0_06-b02
OS: Linux, 2.6.24-16-generic, i386

User Comments: 
While editing PHP source code

Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.modules.php.editor.PHPCodeCompletion.findCompletionContext(PHPCodeCompletion.java:191)
        at org.netbeans.modules.php.editor.PHPCodeCompletion.complete(PHPCodeCompletion.java:279)
        at org.netbeans.modules.gsfret.editor.completion.GsfCompletionProvider$JavaCompletionQuery.addCodeCompletionItems(GsfCompletionProvider.java:569)
        at org.netbeans.modules.gsfret.editor.completion.GsfCompletionProvider$JavaCompletionQuery.resolveCompletion(GsfCompletionProvider.java:555)
        at org.netbeans.modules.gsfret.editor.completion.GsfCompletionProvider$JavaCompletionQuery.run(GsfCompletionProvider.java:385)
        at org.netbeans.modules.gsfret.editor.completion.GsfCompletionProvider$JavaCompletionQuery.run(GsfCompletionProvider.java:219)
Comment 1 vieiro 2008-08-02 11:34:31 UTC
Created attachment 66376 [details]
stacktrace
Comment 2 Tomasz Slota 2008-08-07 10:34:04 UTC
Weird, looks like a problem with the parser. Apparently for some token token.id() was PHP_CONSTANT_ENCAPSED_STRING and at the same time 
token.text() was null.

Reassigning to ppisl for evaluation

The fragment of code was:

switch (tokenSequence.token().id()){
            case T_INLINE_HTML:
                return CompletionContext.HTML;
            case PHP_CONSTANT_ENCAPSED_STRING:
                if (tokenSequence.token().text().charAt(0) == '"') { // NPE was thrown here!!!
                    return CompletionContext.STRING;
                } else {
                    return CompletionContext.NONE;
                }
            default:
        }
Comment 3 Petr Pisl 2008-08-07 10:42:37 UTC
It would be good to have an reproducible case.
Comment 4 Petr Pisl 2008-09-25 11:27:12 UTC
I'm not still able to reproduce it in recent builds. The code completion code has many changes since this issue was
filled. I'm closing this as worksforme, please reopen and attach a file, where we can reproduce it.