Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354472

Summary: [Xtend2] Allow instance extensions without parameters
Product: [Modeling] TMF Reporter: Bernd Kolb <b.kolb>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: christian.dietrich.opensource, sebastian.zarnekow
Version: unspecifiedFlags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Bernd Kolb CLA 2011-08-11 05:51:54 EDT
Build Identifier: 

Scenario:

I have an xtend class which contains helper functions. All of those functions have no parameters. They are for example used for copying a license and copyright text into each file. Some of those functions might become parameters in the future.

In order to use those functions I need to create a @Inject field in every XtendClass calling one of those functions. It would be much nicer if I could statically import those extensions

Reproducible: Always
Comment 1 Christian Dietrich CLA 2011-08-11 14:44:27 EDT
+1
Comment 2 Sebastian Zarnekow CLA 2011-08-11 14:48:44 EDT
I could be interesting to allow things like this:

class CopyrightProvider {
  def String getCopyright() {..}  
}

class CodeGenerator {
  @Inject extension CopyrightProvider copyrightProvider;

  def generateSomething() '''
    <<copyright>>
    other things
  '''  
}

Please note that is already possible to do this

class CodeGenerator {
  @Inject CopyrightProvider snippets;

  def generateSomething() '''
    <<snippets.copyright>>
    other things
  '''  
}
Comment 3 Sebastian Zarnekow CLA 2011-10-19 07:12:46 EDT
Pushed to master.
Comment 4 Karsten Thoms CLA 2017-09-19 17:53:39 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 18:04:20 EDT
Closing all bugs that were set to RESOLVED before Neon.0