| Summary: | NPE in Xtend2Compiler | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Andreas Muelder <Andreas.Muelder> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | jan, sebastian.zarnekow, sven.efftinge |
| Version: | unspecified | Flags: | sven.efftinge:
indigo+
|
| Target Milestone: | SR2 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
This does not only happen for dispatch functions. I think it also breaks the operator overloading feature of xtend. We should not allow such function names, as the "_" namespace should be preserved for generated Xtend stuff. (In reply to comment #1) > This does not only happen for dispatch functions. > I think it also breaks the operator overloading feature of xtend. Andreas, could you please elaborate on this comment? What does break the operator overloading and how does that happen?(In reply to comment #2) > We should not allow such function names, as the "_" namespace should be > preserved for generated Xtend stuff. This arises the question on how we want to implement e.g. the LabelProvider with Xtend which dispatches by means of a polymorphic dispatcher in its super type? Sebastian, maybe I am wrong but refering to the eclipse help, the method signature to overload an operator starts with an underscore, i.E: e1 += e2 e1._operator_add(e2) Defining such a method in xtend leads to the same NullPointerException. (In reply to comment #4) > Sebastian, > > maybe I am wrong but refering to the eclipse help, the method signature to > overload an operator starts with an underscore, i.E: It's actually the documentation which is wrong. The method signature has to be #operator_add or #operator_plus. See org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping.OP_PREFIX Thanks for the hint. I've added a validation for dispatch functions not allowing names starting with an underscore. Also made sure that non-dispatch method names can start with an underscore. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
Build Identifier: 20110615-0604 If a dispatch function name starts with an underscore, the Xtend2Compiler throws an NPE and does not generate java classes. class Example { def dispatch _test(Object e) {} def dispatch _test(String f){} } java.lang.NullPointerException at org.eclipse.xtext.xtend2.compiler.Xtend2Compiler.generateDispatchMethod(Xtend2Compiler.java:200) at org.eclipse.xtext.xtend2.compiler.Xtend2Compiler.generateDispatchMethods(Xtend2Compiler.java:193) at org.eclipse.xtext.xtend2.compiler.Xtend2Compiler.compile(Xtend2Compiler.java:166) at org.eclipse.xtext.xtend2.compiler.Xtend2Compiler.compile(Xtend2Compiler.java:114) at org.eclipse.xtext.xtend2.ui.builder.Xtend2BuilderParticipant.compile(Xtend2BuilderParticipant.java:146) at org.eclipse.xtext.xtend2.ui.builder.Xtend2BuilderParticipant.processDelta(Xtend2BuilderParticipant.java:115) at org.eclipse.xtext.xtend2.ui.builder.Xtend2BuilderParticipant.build(Xtend2BuilderParticipant.java:75) at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60) at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:160) at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:141) at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:91) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Reproducible: Always