Giter VIP home page Giter VIP logo

scalameta / metabrowse Goto Github PK

View Code? Open in Web Editor NEW
104.0 9.0 26.0 8.94 MB

Static site generator for code search with IDE features for Scala

Home Page: https://scalameta.org/metabrowse/#/scalafix/scalafix-core/src/main/scala/scalafix/patch/Patch.scala

License: Apache License 2.0

Scala 94.68% Shell 0.69% HTML 0.90% JavaScript 1.18% CSS 0.63% TypeScript 1.92%
scala metaprogramming documentation xref

metabrowse's Introduction

scalameta

Build Status

User documentation

Head over to the user docs to learn more about the project and its roadmap.

Tutorial

If you'd like to find out how to use scalameta, see this tutorial.

Team

The current maintainers (people who can merge pull requests) are:

An up-to-date list of contributors is available here: https://github.com/scalameta/scalameta/graphs/contributors.

metabrowse's People

Contributors

alexarchambault avatar chocpanda avatar dependabot[bot] avatar jonas avatar masseguillaume avatar olafurpg avatar rorygraves avatar scala-steward avatar scalameta-bot avatar tgodzik avatar xeno-by avatar xuwei-k avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metabrowse's Issues

Unclear --help on how to run cli

$ metadoc --help
metadoc 0.1.0-SNAPSHOT
Usage: metadoc [options]
  --usage
        Print usage and exit
  --help | -h
        Print help message and exit

Note that it doesn't mention that a classpath is expected.

Re-enable JsonSuite

To unblock the Scala.js v1.0 upgrade, we disabled JsonSuite. This test suite is for a feature that nobody is using to my best knowledge. Metabrowse supports reading JSON files instead of protobuf files. This feature was added to see if there was interest outside of the Scala community to emit SemanticDB, but it was never publicly advertised (only in one private DM). It's OK to close this issue by removing JsonSuite.

Discussion: Do we need a global dispatch mechanism?

As discussed elsewhere, we want to load content for each implemented language provider using futures. Some of the providers needs to access "global" state such as the editor instance(s). We can either try to implement this using services similar to Monaco which are injected and wired at start up or adopt something like Diode which provides several patterns for managing state, such as lenses and actions.

Run demo on a larger corpus

The corpus in the current demo is quite uninteresting code. It would be cool if the demo was a larger corpus such as for example the Scala community build, including semantic support for .sbt files, sbt sources and the Scala standard library.

Problems generating a metadoc site for the community build

Here are some findings from using the ZIP file of semantic DBs mentioned in #22 (comment) to generate a metadoc site.

  • Duplicate semantic DBs: the Scalameta community build contains several duplicates semantic DBs for the same path under META-INF. Not sure if this can be sanely handled by metadoc, but the problem of duplicate definitions could still apply if metadoc where to support multiple versions of the same project/file, e.g. Akka 2.4 and Akka 2.5.

  • Memory usage: The CLI currently loads all semantic DBs into memory and generates additional datasets for files and symbols in memory before writing anything out to disk. I was not able to generate a metadoc site for a significant subset of semantic DBs from the community build:

      > du -sh community/classes/
      581M	community/classes
    
  • File name too long: The current symbol name encoding scheme does not work on file systems with modest path lengths.

Running metadoc-site twice causes FileAlreadyExistsException

> metadoc-site
...
Writing symbol index
[error] (run-main-1) java.nio.file.FileAlreadyExistsException: /opt/metadoc/target/metadoc/symbol
java.nio.file.FileAlreadyExistsException: /opt/metadoc/target/metadoc/symbol
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
	at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
	at java.nio.file.Files.createDirectory(Files.java:674)
	at metadoc.cli.CliRunner.$anonfun$writeSymbolIndex$1(MetadocCli.scala:203)
	at metadoc.cli.CliRunner.$anonfun$writeSymbolIndex$1$adapted(MetadocCli.scala:201)
	at metadoc.cli.CliRunner.phase(MetadocCli.scala:135)
	at metadoc.cli.CliRunner.writeSymbolIndex(MetadocCli.scala:201)
	at metadoc.cli.CliRunner.run(MetadocCli.scala:301)
	at metadoc.cli.MetadocCli$.run(MetadocCli.scala:333)
	at metadoc.cli.MetadocCli$.run(MetadocCli.scala:311)
	at caseapp.CaseApp.main(CaseApp.scala:40)
	at metadoc.cli.MetadocCli.main(MetadocCli.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

Add custom UI chrome and empty start page

Based on #27 (comment), we should show an empty start page with instructions on how to open file, symbol, or the editor's context menu.

At the same time we should also add some basic "chrome" for managing settings (e.g. theme), link to GitHub. I suggest starting out with Material Design Lite which is declarative and integrates well with webpack.

sbt plugin

Metadoc is kind of useful now that #19 has been solved in #33. It would be nice to provide an sbt-metadoc plugin that generates a static site on some metadoc command. The command should compile all main and test sources and generate a site under some configured directory.

More efficient reference provider

The reference provider seems to do a lot of redundant fetches

screen shot 2017-07-03 at 08 43 37

It might be a good idea to change the schema to store a map<string, Ranges> instead of List[(Filename, Range)]. That would mean we only store the filename once for all references in that file and we solve the redundant semanticdb fetching problem.

Print method signatures for method symbols

Currently, "Go to symbol..." shows raw symbols IDs as containerName

screen shot 2018-09-24 at 09 09 29

It would be nice if we instead showed the method signature such as the parameter types and result types.

Search by filename

It would be nice if it was possible to open a particular file by searching its name. Ideally, this should be possible in a similar way as vscode does it with Cmd+P

jun-28-2017 22-36-26

Also, the url hash should ideally follow the active filename so that it's possible to share a link to a specific filename (+ line number)

Cannot find module webpack-dev-server

When following the "CONTRIBUTING" section in the README, I get the following error:

sbt @ metadoc > [error] module.js:491
[error]     throw err;
[error]     ^
[error] 
[error] Error: Cannot find module '/data/rw/code/scala/scala-profiling/metadoc/metadoc-js/target/scalajs-bundler-webpack-dev-server/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
[error]     at Function.Module._resolveFilename (module.js:489:15)
[error]     at Function.Module._load (module.js:439:25)
[error]     at Function.Module.runMain (module.js:609:10)
[error]     at startup (bootstrap_node.js:158:16)
[error]     at bootstrap_node.js:598:3

Executing the next command in the guide ~js/fastOptJS succeeds but the server is not spinned up, so I cannot open the Metadoc website.

Scalafix support

It would be nice if it was possible run scalafix rewrites on the code being browsed. In particular, it would be nice to see the sugars such as inferred type annotations and implicits expanded. Features such as jump to definition and see references should continue work on the rewritten source.

Prefer npm local installation

The README says: npm install -g yarn. I think it'll be better to prefer local installation. The build has to be adapted for npm install --local yarn to work. Currently it fails with the following error:

sbt @ metadoc > js/fastOptJS::startWebpackDevServer
[info] Installing webpack-dev-server in /data/rw/code/scala/scala-profiling/metadoc/metadoc-js/target/scalajs-bundler-webpack-dev-server
[info] Updating NPM dependencies
[info] Fast optimizing /data/rw/code/scala/scala-profiling/metadoc/metadoc-js/target/scala-2.12/scalajs-bundler/main/metadoc-js-fastopt.js
[trace] Stack trace suppressed: run last js/*:installWebpackDevServer for the full output.
[trace] Stack trace suppressed: run last js/compile:npmUpdate for the full output.
[error] (js/*:installWebpackDevServer) java.io.IOException: Cannot run program "yarn" (in directory "/data/rw/code/scala/scala-profiling/metadoc/metadoc-js/target/scalajs-bundler-webpack-dev-server"): error=2, No such file or directory
[error] (js/compile:npmUpdate) java.io.IOException: Cannot run program "yarn" (in directory "/data/rw/code/scala/scala-profiling/metadoc/metadoc-js/target/scala-2.12/scalajs-bundler/main"): error=2, No such file or directory

This is just a nice to have. Local npm packages are much superior in every case I can think of.

Search by symbol

Related to #20. It would be nice if it was possible to search by "symbol", where a symbol is a definition such as a class/trait/object and maybe val/var/def.

Consider adding a metabrowseForceCompile task to sbt-metabrowse

If sbt-metabrowse has some kind of metabrowseForceCompile command that inserts the semanticdb-scalac compiler plugin and -Yrangepos scalacOptions, then we can add the plugin globally and run that command in any build without fiddling with the build settings.

Some builds do libraryDependencies := ... and scalacOptions := ... which overrides addCompilerPlugin from the plugin.

Package webpack assets for CLI consumption

For the CLI to be able to generate a complete metadoc site it needs to be able to extract the webpack assets from somwhere. Options are:

  • package (and publish) webpack assets in a separate org.scalameta:metadoc-js:version:assets jar (note the classifier)
  • ship assets in the main metadoc-js jar for example inside a META-INF/metadoc-assets folder

Packaging can be achieved using sbt's Defaults.packageTaskSettings however version 0.8.0 of scalajs-bundler no longer support custom output paths so we need to find another long term way to resolve all assets generated by webpack.

Better testing infrastructure for metadoc cli

Follow up on #55 (comment)

An idea testing infrastructure makes it easy to

  • add new tests
  • update tests when expected behavior changes
  • review diffs from test

I'm personally a big fan of "expect tests" (see https://blog.janestreet.com/testing-with-expectations/), which are similar to partests in scala/scala.

Example expect tests in scalameta: https://github.com/scalameta/scalameta/blob/15a0187501dc8e5a6fe06d0e002ce1d3340968dc/scalameta/semanticdb-scalac/src/test/scala/scala/meta/tests/SemanticSuite.scala#L6

I'd love to setup something similar for metadoc once I finally get through with this scalafix 0.5.0 release.

Improve the Scala language syntax definition

The editor uses the Monarch language tokenizer defined in metadoc-js/src/main/resources/scala.ts which still lacks support for a lot of language constructs. A non-exhaustive list:

  • Symbols defined with backticks

     val `number-42` = 42
  • Strings defined with triple quotes

     val a = """
       select * from table;
     """
  • String contexts

     val a = s"$serverName resolves to ${resolve(serverName)}"

More info on Monarch: https://microsoft.github.io/monaco-editor/monarch.html
Inspiration from the Scala vscode integration: scala.tmLanguage and scala.configuration.json

Implement TypeDefinitionProvider

Monaco 0.9.0 (merged in #49) added a new TypeDefinitionProvider service
https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.typedefinitionprovider.html

It would be nice to implement it in metadoc. The service provides a way to jump to the type definition when hovering over a non-type symbol (e.g., in term or pat position).
Example motivation microsoft/TypeScript#10394

olafurpg@c17d2d9 shows a skeleton of how to implement this service in metadoc.

Find References of a method that overrides from Trait

Hi,

This is more of a question than an issues; so it it would be better to raise it elsewhere; please point me in the direction.

When I Find All References of a method that overrides from a Trait - "No Results" is reported.

Would there be options to explore a feature similar to Intelij's where it prompts: "Do you want to find usages for the base member?"

The goal is to go through a code set and find all unused methods. So any other approaches that could achieve that would also be of interest.

Thanks

Figure out uri scheme

See #32 (comment)

We currently use file:$filename but it might be a good idea to use a custom scheme such as semanticdb:$filename. It might get more tricky once we have multiple repositories.

Switch between files

Currently, metadoc only works for a single source file. It should be possible to switch between files when jumping to symbols defined in other compilation units.

Chunk large package indexes

From #100 (comment)

Grouping by top-level package is problematic for widely referenced packages, for example the org.scalatest symbol index in the megasite is 11mb. I was thinking of chunking down those files in ~500kb sizes and the client needs to "guess" the first package index and from there we can link to a secondary package index. That would mean users you never download more than ~1mb to resolve a symbol (and we can lower 1mb at the cost of producing more files).

Either way, I believe even 11mb is an acceptable solution considering the megasite is for a corpus of 3.5 million loc corpus. We can further improve the situation in followup PRs.

Start using fullOptsJS instead of fastOptJS again

To unblock the Scala.js v1.0 upgrade, we updated the build to use only fastOptJS instead of fullOptJS. Full optimization was failing with the following error from com.google.javascript.jscomp

sbt:metabrowse> last js / Compile / fullLinkJS
[info] Full optimizing /Users/olafurpg/dev/scalameta/metabrowse/metabrowse-js/target/scala-2.13/metabrowse-js-opt
[debug] Linker: Compute reachability: 1020002 us
[debug] Linker: Assemble LinkedClasses: 97469 us
[debug] Linker: Check IR: 672343 us
[debug] Linker: 1867273 us
[debug] Optimizer: Batch mode: true
[debug] Optimizer: Incremental part: 258541 us
[debug] Optimizer: Optimizing 26648 methods.
[debug] Optimizer: Optimizer part: 2344534 us
[debug] Optimizer: 2616057 us
[debug] Refiner: Compute reachability: 254856 us
[debug] Refiner: Assemble LinkedClasses: 18135 us
[debug] Refiner: 299668 us
[debug] Module Splitter: Calculate Dependency Info: 4730 us
[debug] Module Splitter: Analyze Modules: 1701 us
[debug] Module Splitter: Assemble Modules: 14870 us
[debug] Module Splitter: 22834 us
[debug] Emitter: Generate Classes: 1528297 us
[debug] Emitter: Write trees: 41128 us
[debug] Emitter: Class tree cache stats: reused: 0 -- invalidated: 2685
[debug] Emitter: Method tree cache stats: reused: 0 -- invalidated: 16066
[debug] Emitter: 1658313 us
[debug] Closure: Create trees): 1101883 us
[info] Closure: 0 error(s), 0 warning(s)
[error] java.lang.IllegalStateException
[error] 	at com.google.javascript.jscomp.jarjar.com.google.common.base.Preconditions.checkState(Preconditions.java:492)
[error] 	at com.google.javascript.jscomp.OptimizeParameters.addVariableToFunction(OptimizeParameters.java:995)
[error] 	at com.google.javascript.jscomp.OptimizeParameters.optimizeFunctionDefinition(OptimizeParameters.java:903)
[error] 	at com.google.javascript.jscomp.OptimizeParameters.tryEliminateConstantArgs(OptimizeParameters.java:614)
[error] 	at com.google.javascript.jscomp.OptimizeParameters.process(OptimizeParameters.java:128)
[error] 	at com.google.javascript.jscomp.OptimizeCalls.process(OptimizeCalls.java:125)
[error] 	at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:317)
[error] 	at com.google.javascript.jscomp.PhaseOptimizer$Loop.process(PhaseOptimizer.java:462)
[error] 	at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:232)
[error] 	at com.google.javascript.jscomp.Compiler.performOptimizations(Compiler.java:2438)
[error] 	at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$1(Compiler.java:808)
[error] 	at com.google.javascript.jscomp.CompilerExecutor.lambda$runInCompilerThread$0(CompilerExecutor.java:101)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] (js / Compile / fullLinkJS) java.lang.IllegalStateException

We should figure out what's causing this error and start using fullOptJS again

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.