nextflow-io / language-server

The Nextflow language server
Apache License 2.0
0 stars 0 forks source link

Symbol resolution #7

Closed bentsherman closed 4 months ago

bentsherman commented 4 months ago

Symbol resolution is the basis of many language features:

Once you can determine the set of available symbols in a given scope, and trace symbol references back to symbol definitions, you can implement all of the above features.

This issue is mainly a way for me to think through all of the moving parts, because it's complicated. But you can share your opinion too I guess.

Script

Built-in symbols should be annotated in the Nextflow codebase, then the language server can query these annotations. For example:

@StdLib('''
  The `map` operator applies a mapping function to each value from a source channel.

  [Read more](https://nextflow.io/docs/latest/operator.html#map)
''')
DataflowWriteChannel map(DataflowReadChannel source, Closure closure) {
    // ...
}

For now I can keep these definitions in the language server and then move them into Nextflow once they are stable. Even better if we can do it with Groovydoc instead of annotations, but I'm not sure if that's possible.

Config

bentsherman commented 4 months ago

Basic name resolution has been implemented for scripts and configs. Remaining items:

Remaining LSP features:

Type inference is needed to go any deeper, e.g. to resolve object members, so it will be treated separately.

bentsherman commented 4 months ago

Variable and class names are now being resolved. Config will also be updated separately. Other language features will be implemented separately.