Community
Participate
Working Groups
I was creating an extension using the ext_skel script. The project was created using cdt (C++ development tools). So the project itself is not a pdt project (maybe thats the problem at all). Opening the automatically created php file of the new extension shows up a null pointer exception every time you type a character. Opening and changing some other files (f.e. exis/example.php) shows up other NPEs. I was using the latest cvs snapshot of dltk and pdt (updated some minustes before to confirm the bug) --------SNIP php file content <?php $br = (php_sapi_name() == "cli")? "":"<br>"; if(!extension_loaded('bgh_reflection')) { dl('bgh_reflection.' . PHP_SHLIB_SUFFIX); } $module = 'bgh_reflection'; $functions = get_extension_funcs($module); echo "Functions available in the test extension:$br\n"; foreach($functions as $func) { echo $func."$br\n"; } echo "$br\n"; if (extension_loaded($module)) { $bgh = new bgh\reflection\Test(); echo $bgh->foo(); } else { echo "Module $module is not compiled into PHP"; } ?> --------SNIP exception 1: ------------- java.lang.NullPointerException at org.eclipse.php.internal.ui.editor.highlighters.DeprecatedHighlighting$DeprecatedApply.visit(DeprecatedHighlighting.java:55) at org.eclipse.php.internal.core.ast.nodes.ClassName.accept0(ClassName.java:66) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.core.ast.nodes.ClassInstanceCreation.childrenAccept(ClassInstanceCreation.java:84) at org.eclipse.php.internal.core.ast.nodes.ClassInstanceCreation.accept0(ClassInstanceCreation.java:74) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.core.ast.nodes.Assignment.childrenAccept(Assignment.java:130) at org.eclipse.php.internal.core.ast.nodes.Assignment.accept0(Assignment.java:159) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.core.ast.nodes.ExpressionStatement.childrenAccept(ExpressionStatement.java:73) at org.eclipse.php.internal.core.ast.nodes.ExpressionStatement.accept0(ExpressionStatement.java:67) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.core.ast.nodes.Block.childrenAccept(Block.java:97) at org.eclipse.php.internal.core.ast.nodes.Block.accept0(Block.java:90) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.core.ast.nodes.IfStatement.childrenAccept(IfStatement.java:96) at org.eclipse.php.internal.core.ast.nodes.IfStatement.accept0(IfStatement.java:89) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.core.ast.nodes.Program.childrenAccept(Program.java:191) at org.eclipse.php.internal.core.ast.nodes.Program.accept0(Program.java:184) at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275) at org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting.consumes(AbstractSemanticHighlighting.java:93) exception 2: -------------- java.lang.NullPointerException at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.extractClasses(PHPSelectionEngine.java:723) at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.internalASTResolve(PHPSelectionEngine.java:349) at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.select(PHPSelectionEngine.java:103) at org.eclipse.dltk.internal.core.Openable.codeSelect(Openable.java:553) at org.eclipse.dltk.internal.core.AbstractSourceModule.codeSelect(AbstractSourceModule.java:97) at org.eclipse.dltk.internal.core.AbstractSourceModule.codeSelect(AbstractSourceModule.java:88) at org.eclipse.dltk.internal.ui.text.hover.AbstractScriptEditorTextHover.getHoverInfo(AbstractScriptEditorTextHover.java:141) at org.eclipse.php.internal.ui.editor.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:106) at org.eclipse.php.internal.ui.editor.hover.PHPTextHoverProxy.getHoverInfo(PHPTextHoverProxy.java:73) at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:168)
We can probably reproduce this by opening a php file in a non-php project. This brings a general question about how should we treat PHP files that are context-less? Maybe to have another IEditorInput, or do some tricks made by JDT?
I do some small changes,but I can still get NPE for php file in a non-php project. But I think there will be much less NPE than before:)