Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ólafur Páll Geirsson
    @olafurpg
    you'll need a bit more work to handle references to overridden methods
    You can poke into the Metals codebase to see how "textDocument/references" is implemented
    Sequencer
    @sequencer
    OK! Thank you! I'll try.
    Roman Janusz
    @ghik
    @olafurpg thanks, will try it out
    Ólafur Páll Geirsson
    @olafurpg
    We’re hopefully doing a stable release in a couple days if you can hold out the wait
    Roman Janusz
    @ghik
    @olafurpg I still can't make it work with current snapshot. I built 0.7.7-SNAPSHOT from today's master and I'm getting this:
    java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: DecodingFailure(Attempt to decode value on failed cursor, List(DownField(providesFileWatching), DownField(capabilities)))
        at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
        at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915)
        at scala.meta.internal.metals.BuildServerConnection$.initialize(BuildServerConnection.scala:176)
        at scala.meta.internal.metals.BuildServerConnection$.fromStreams(BuildServerConnection.scala:129)
        at scala.meta.internal.metals.BloopServers.$anonfun$newServer$1(BloopServers.scala:71)
        at scala.util.Success.$anonfun$map$1(Try.scala:255)
        at scala.util.Success.map(Try.scala:213)
        at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
        at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
        at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: DecodingFailure(Attempt to decode value on failed cursor, List(DownField(providesFileWatching), DownField(capabilities)))
        at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
        at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
        at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
        at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
        at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Ólafur Páll Geirsson
    @olafurpg
    @ghik you may have an old version of bloop running
    we're waiting for a stable release of bloop to come out before releasing metals v0.8
    maybe best to wait until then
    Roman Janusz
    @ghik
    ok, thanks, that's probably what I will do
    but I don't understand why I'm running wrong version of bloop - isn't it set up automatically by metals?
    Tomasz Godzik
    @tgodzik
    @ghik might also be needed to reimport the build - that message usually means that some json has an unexpected structure
    Jakub Kozłowski
    @kubukoz
    I'm having trouble running scalafifx on a project (RemoveUnused) - using the sbt plugin/task. The plugin claims the files were changed but they remain unmodified...
    sbt:OrderService> scalafix RemoveUnused
    [info] Running scalafix on 10 Scala sources
    [info] Running scalafix on 6 Scala sources
    [info] Running scalafix on 3 Scala sources
    [info] Running scalafix on 50 Scala sources
    [success] Total time: 1 s, completed Dec 17, 2019 12:35:41 PM
    yet nothing changes
    I have the necessary flags on, and can see warnings on a fresh compile
    would appreciate any hints
    sandeshyapuram
    @pandareen
    Hello, can you point me to some examples? I could use some full-blown tutorials
    Bartosz Bąbol
    @BBartosz
    According to main page of scalameta: Scalameta- Library to read, analyze, transform and generate Scala programs -> how exactly scalameta is used to generate scala programs since macros are not part of scalameta anymore?
    Gabriele Petronella
    @gabro
    @BBartosz you can generate programs by constructing trees and printing them with Scalameta. Macros allow you to do roughly the same thing, except you do it during the compilation of your program
    in other words, you can do code generation with Scalameta
    (I use it for this purpose at work)
    Ólafur Páll Geirsson
    @olafurpg
    @BBartosz Scalameta does not support macros, you can use scala-reflect macros instead
    Roman Janusz
    @ghik
    Hi!
    I have an already parsed Source. I also have a Position representing some arbitrary range in that source. I would like to obtain Tokens representing tokens only from that range. How can I do this efficiently?
    Is there anything better I can do than manually implementing binary search?
    Ólafur Páll Geirsson
    @olafurpg
    You can access the underlying token array by using a package private API called “Origin”
    But you would still need to know the index in the array where your range starts
    So binary search is the best solution if you already have the token array.
    Roman Janusz
    @ghik
    Thanks
    Bartosz Bąbol
    @BBartosz

    @BBartosz you can generate programs by constructing trees and printing them with Scalameta. Macros allow you to do roughly the same thing, except you do it during the compilation of your program

    How exactly you generate them? I understand that you use quasiquotes to build your tree and then you save it to file, kinda like string?

    Roman Janusz
    @ghik
    @BBartosz yes, this way. You cannot generate programs with scalameta "on the fly", that is in compile time like macros.
    Bartosz Bąbol
    @BBartosz

    @BBartosz yes, this way. You cannot generate programs with scalameta "on the fly", that is in compile time like macros.

    yeah thx i was wondering whats the way to do it. I was using quasiquotes and macros but generating the code and saving it to file might also work for me

    sandeshyapuram
    @pandareen
    Is there a better way to kick off code generation? I am using Scala Annotations for pointing it towards scalameta to generate new codee.
    Ólafur Páll Geirsson
    @olafurpg
    @pandareen if you are generating source code as strings, I would recommend using something like treehugger instead http://eed3si9n.com/treehugger/
    vito-c
    @vito-c
    @olafurpg would treehugger be something we could use for refactoring as well? right now I am using patch like this:
            Patch.replaceTree(
              someTree,
              "val foo:SomeType = new Thing(1, 2,3)"
            )
    Charlie Hills
    @contagnas

    Hi all, wondering if someone could clarify the behavior of the semanticdb-scalac plugin for me. I'm running this command:

    $ ~/Downloads/scala-2.13.1/bin/scalac -Xplugin:$(realpath ~/Downloads/semanticdb-scalac_2.13.1-4.3.0.jar) -Yrangepos -Xplugin-require:semanticdb HelloWorld.scala

    I'm expecting to see semanticdb files in META-INF/semanticdb, but I do not. In fact, if I create the META-INF/semanticdb directory before running the above command, the semanticdb directory is deleted.

    Ondra Pelech
    @sideeffffect
    Hello, is there an integration between ScalaMeta/SemanticDB and Kythe?
    Muhammad Tabaza
    @Tabzz98
    Hi guys!
    Is there a way pass a Source to scala.tools.reflect.ToolBox.eval()?
    sandeshyapuram
    @pandareen
    Hello guys, what is the latest method to design frameworks that overcome Type Erasures? Does scalameta aim to solve this?
    I wouldn't want to use scala reflection as it's experimental
    Ólafur Páll Geirsson
    @olafurpg
    @contagnas it looks like you need the targetroot option as well
    ❯ cs launch scala:2.13.1 -- -Xplugin:$(cs fetch --intransitive org.scalameta:semanticdb-scalac_2.13.1:4.3.7) -Yrangepos -Xplugin-require:semanticdb -P:semanticdb:targetroot:$(pwd) foo.scala
    ❯ tree
    .
    ├── foo.scala
    └── META-INF
       └── semanticdb
          └── foo.scala.semanticdb
    where cs is coursier from https://get-coursier.io/docs/cli-overview
    @sideeffffect there's no published integration with kythe, i recall somebody implemented something a couple years ago but it didn't end up going anywhere I think
    @Tabzz98 Source.toString gives you the code that you can feed to eval
    @pandareen scalameta does not provide any features for runtime reflection. The only alternatives I'm aware of are scala/java runtime reflection
    Muhammad Tabaza
    @Tabzz98
    @olafurpg Ah, of course. I don't know why I didn't consider a solution where the parsing is done twice. All I had in mind was converting the whole tree. Thanks a lot!
    Ondra Pelech
    @sideeffffect
    @olafurpg thanks for the info
    Dale Wijnand
    @dwijnand
    Am I right in saying that there's information missing in the following, to link an eta-expansion to the method it expands?
    trait NullaryEtaExpansionScala[A] {
      def prop: A
      def meth(): A
    
      def def_prop = prop _
      def def_meth = meth _
    }
    $ type metac
    metac is aliased to `coursier launch org.scalameta:metac_2.12.11:4.3.7 -- -cp /Users/dnw/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.11/scala-library-2.12.11.jar'
    
    $ type metap
    metap is aliased to `coursier launch -M scala.meta.cli.Metap org.scalameta:scalameta_2.12:4.3.7 --'
    
    $ metac -P:semanticdb:synthetics:on NullaryEtaExpansionScala.scala
    
    $ tree META-INF/
    META-INF/
    └── semanticdb
        └── NullaryEtaExpansionScala.scala.semanticdb
    
    1 directory, 1 file
    
    $ metap .
    NullaryEtaExpansionScala.scala
    ------------------------------
    
    Summary:
    Schema => SemanticDB v4
    Uri => NullaryEtaExpansionScala.scala
    Text => empty
    Language => Scala
    Symbols => 6 entries
    Occurrences => 10 entries
    
    Symbols:
    _empty_/NullaryEtaExpansionScala# => trait NullaryEtaExpansionScala[A] extends AnyRef { +4 decls }
    _empty_/NullaryEtaExpansionScala#[A] => typeparam A
    _empty_/NullaryEtaExpansionScala#def_meth(). => method def_meth: Function0[A]
    _empty_/NullaryEtaExpansionScala#def_prop(). => method def_prop: Function0[A]
    _empty_/NullaryEtaExpansionScala#meth(). => abstract method meth(): A
    _empty_/NullaryEtaExpansionScala#prop(). => abstract method prop: A
    
    Occurrences:
    [0:6..0:30) <= _empty_/NullaryEtaExpansionScala#
    [0:31..0:32) <= _empty_/NullaryEtaExpansionScala#[A]
    [1:6..1:10) <= _empty_/NullaryEtaExpansionScala#prop().
    [1:12..1:13) => _empty_/NullaryEtaExpansionScala#[A]
    [2:6..2:10) <= _empty_/NullaryEtaExpansionScala#meth().
    [2:14..2:15) => _empty_/NullaryEtaExpansionScala#[A]
    [4:6..4:14) <= _empty_/NullaryEtaExpansionScala#def_prop().
    [4:17..4:21) => local0
    [5:6..5:14) <= _empty_/NullaryEtaExpansionScala#def_meth().
    [5:17..5:21) => local1
    $
    There's no reference occurrence of prop(). and no link from symbol local0, right?