vscode-codeql icon indicating copy to clipboard operation
vscode-codeql copied to clipboard

Add stubs for missing method overrides

Open RasmusWL opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I'm always frustrated when subclassing an abstract class in QL, since I need to manually write out names and signatures of abstract methods I must implement.

And all the while, my IDE is laughing at my struggle, since it knows what I need to do (with the <YourClass> must implement abstract method: <methodName> errors).

I usually go to the abstract base class and use multiple-cursors on the abstract part, but with multiple base classes that are abstract, even this process becomes tedious.

Describe the solution you'd like

class MyClass extends AbstracClass {
  MyClass() { this = foo() }
}

Right-click the MyClass part of class MyClass, select Add stubs for missing method overrides, and the above code is extended to become

class MyClass extends AbstracClass {
  MyClass() { this = foo() }

  override string method1(int arg) { 
    // TODO: this is a stub
    none() 
  }

  override method2() {
    // TODO: this is a stub
    none() 
  }
}

I think this is very common in Java, so we might be able to borrow how the stubs are populated from there (like how the TODO comment is formulated).

Describe alternatives you've considered N/A

Additional context N/A

RasmusWL avatar Oct 22 '20 09:10 RasmusWL