Giter VIP home page Giter VIP logo

oraide's People

Contributors

phrohdoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

oraide's Issues

Remove component oraide-miniyaml

Prerequisites

  • #1 -- reimpl oraide-miniyaml tests for oraide-parser-miniyaml

Why

This component, oraide-miniyaml, has been superseded by the oraide-parser-miniyaml component and is not going to be used going forward so it should be deleted from the project.

How

Forcefully, recursively remove the component:

# in your terminal application, from the root of this project
$ rm -rf ./components/oraide-miniyaml/

For all remaining components, manually verify that they...

  • still successfully build (all packages included)
  • pass all of the tests that are expected to pass (via cargo test -p <component-name>)
  • still successfully generate docs (via cargo doc -p <component-name>)
  • any and all binary packages still perform as desired

Anything that is broken in one way or another should either...

  • be fixed
  • be deleted (if we are not going to use it going forward)

Implement go-to-definition

Feature Explanation & Use

The 'go-to-definition' feature of editors/IDEs takes users to the place (or places in some cases) where the symbol under their caret is defined (if any such definition is found).

This can be useful to OpenRA developers and game makers when they are, for example, creating unit B by copying unit A and making tweaks. They may want to quickly see the definition of a weapon so they can determine whether unit B should keep the current weapon or get a different one.

Implementation Notes & Steps

The query system needs to be able to handle the textDocument/definition request which consists of an identifier for the source document and a position in said document (details here).

  • Add a GoToDefinition struct variant containing fields with values derived from the TextDocumentPositionParams type to QueryRequest in the oraide-actor component

  • Add a Definition struct variant that contains a pos: Option<Position> field to QueryResponse in the oraide-actor component

  • Add a TextDocDefinition struct variant, similar to the existing TextDocDidOpen variant, to LspMessage in the oraide-language-server component

  • Add a match arm in the lsp_serve function of the oraide-language-server component for LspMessage::TextDocDefinition that sends a QueryRequest::GoToDefinition instance

  • Add a match arm in the QuerySystem::process_message function in the oraide-query-system for the new QueryRequest::GoToDefinition variant that queries the Database (self.db) for a definition given a Position in a file (see the existing hover_with_file_name usage for reference)

  • Add a function named definition_with_file_name to the trait LangServerCtx in the oraide-query-system component with the signature fn definition_with_file_name(&self, file_name: String, pos: Position) -> Option<Position> and be sure to include a salsa::invoke attribute (again see hover_with_file_name for reference) and inline documentation

  • Implement definition_with_file_name in components/oraide-query-system/src/query_definitions.rs

    • Attempt to get the associated FileId from the Database given the file's name (which is a URL in practice)
    • Use this ID to get the text of the file from the DB
    • Convert the input position to a byte index
    • Get the token spanning said byte index, if one exists
    • Get the text of said token
    • Use that text to search through the definitions (top-level items) of each file in the DB (we're not doing any search optimizations at this time)
    • If a match is found construct and return a Position
  • Back in the QuerySystem::process_message function's QueryRequest::GoToDefinition match arm's body send a QueryResponse::Definition instance to self.send_channel

  • Find the Actor impl for LspResponder in the oraide-language-server component (components/oraide-language-server/src/lib.rs) and add a match arm to the on_new_messages function's body for QueryResponse::Definition which will convert the Definition into an Option<languageserver_types::Location> and invoke send_response with the newly-created Option<languageserver_types::Location>

  • Test it!

Potential Future Enhancements

  • The type-data exporter utility command should denote which properties are references and the type of reference they are (see OpenRA.Game/Traits/LintAttributes.cs in the engine's source tree)
    • This data can then be used to narrow our searches once searches are contextually intelligent
  • ???

Implement `Text` from Lark

The Lark project, which heavily influences the design of oraide, has a struct named Text that is essentially a slice of a String.

Lark uses this type to avoid expensive clones of Strings in and out of the salsa database which we currently do a lot of.

Implementing and using Text will theoretically improve performance of oraide but we have no numbers to support this claim currently.


I'm not sure yet in which component to put this Text type (or if a new component should be created).

Remove binary package from oraide-sdk

oraide-sdk appears to be the only user of oraide-miniyaml (which we want to get rid of any way, see #2). Instead oraide-parser-miniyaml should be used.

Remove src/main.rs from oraide-sdk.
It exists only as a playground for oraide-sdk's types and we don't need it any more.

VSCode extension: Server process is not stopped when VSCode is closed

Issue

When VSCode is closed the server process should be stopped with the code written as it is now but this is not the case for reasons currently unknown.

This means the server process stays around holding things in memory that we no longer need.

The user may end up with multiple ora instances running in IDE mode eating up memory which is obviously not good.

Known Workaround(s)

macOS / Linux

You can use ps to find the process's PID (process ID) which in turn be used with kill to end the process.

$ ps aux | { head -1; grep ora }

USER     PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
taryn  28800   0.0  0.0  4272648   1136   ??  S     6:32AM   0:00.01 bash /Users/taryn/src/tools/oraide/components/oraide-language-server/tools/interceptor.bash ide
taryn  28809   0.0  0.0  4278196    720   ??  S     6:32AM   0:00.00 tee /tmp/ora.in.log
taryn  28810   0.0  0.0  4330876   8228   ??  S     6:32AM   0:00.02 /Users/taryn/src/tools/oraide/target/debug/ora ide
taryn  28811   0.0  0.0  4277172    700   ??  S     6:32AM   0:00.00 tee /tmp/ora.out.log

$ kill -9 28810

Windows

You can use the Get-Process and Stop-Process PowerShell commands to find and end the process.

PS /Users/taryn> Get-Process "ora"
 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
 ------    -----      -----     ------      --  -- -----------
      0     0.00       5.79       0.87   3645320 ora
PS /Users/taryn> Stop-Process -Id 36453

Possible Solution(s)

We should probably simplify extension.ts to be similar to Lark's.

Document the VSCode extension not properly stopping the language server process

For reasons currently unknown to me the VSCode extension does not actually stop the server process when the VSCode instance is closed so the server stays around which means memory is being taken up with absolutely no gain for the end user.

Document this fact somewhere in the VSCode-specific docs and how the process can be stopped manually should once choose to do so.

The how is:

  1. find the process' id:
$ ps aux | grep ora
  1. kill it:
# example pid: 12345
$ kill -9 12345

Support updating documents in the database in-place

Feature Explanation & Use

Currently we load documents into the database only when the document is opened (more concretely: when the server gets a textDocument/didOpen notification).

This work will have us updating the database when a document is changed via the client (if a document is changed in a different editor we won't know about that).

This will allow us to perform actions (such as responding to queries, ex: "find all references") based off of text that has not yet been written to disk.

That isn't the entire truth as we do not yet update the database when we get a textDocument/didSave notification, but hopefully you get the idea.

Once both textDocument/didChange and textDocument/didSave are implemented and update the relevant documents in the database in-place then we will have the absolute basic machinery to support basic features that users can logically expect from an IDE.

References

  1. textDocument/didChange / LSPCommand::didChange in Lark (spec)

  2. Mapping LSPCommand::didChange into QueryRequest::EditFile and sending to the query system in Lark

  3. Applying QueryRequest::EditFile in Lark

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.