Skip to content

PHP: NullPointerException when generating a method using Introduce Hint #6258

@troizet

Description

@troizet

Apache NetBeans version

Apache NetBeans 18

What happened

NullPointerException when generating a method using Introduce Hint.

How to reproduce

  • create a TestClass.php file with the TestClass class:
<?php

class TestClass {
}
  • сreate a test.php file with the code:
<?php

TestClass::generatedMethod();

or

<?php

$cls = new TestClass();
$cls->generatedMethod();
  • set the caret to generatedMethod
  • press Alt + Enter, then press CreateMethod "generatedMethod()" in Class "TestClass" (TestClass.php)

Did this work correctly in an earlier version?

No / Don't know

Operating System

Debian GNU/Linux 12 (bookworm)

JDK

OpenJDK Runtime Environment 17.0.7+7-Debian-1deb12u1

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

Stacktrace:

java.lang.NullPointerException: Cannot invoke "org.netbeans.modules.csl.api.OffsetRange.getEnd()" because "blockRange" is null
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion.getOffsetAfterUseTrait(IntroduceSuggestion.java:996)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion.getOffset(IntroduceSuggestion.java:915)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion.access$500(IntroduceSuggestion.java:98)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceMethodFix.getOffset(IntroduceSuggestion.java:535)
	at org.netbeans.modules.php.editor.verification.IntroduceSuggestion$IntroduceMethodFix.implement(IntroduceSuggestion.java:510)
	at org.netbeans.modules.csl.hints.infrastructure.FixWrapper.implement(FixWrapper.java:43)
[catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:810)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1419)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2034)

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

Labels

PHP[ci] enable extra PHP tests (php/php.editor)kind:bugBug report or fix

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions