Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Roman Janusz
    @ghik
    Lossless parsing is one of the selling points of scalameta
    Ólafur Páll Geirsson
    @olafurpg
    If you're doing a new programming language then I think it's totally reasonable to write your own parser
    even if it's only a subset of Scala
    btw, the dotty parser doesn't loose as much information as the scalac parser
    Roman Janusz
    @ghik
    That's interesting, how public/reusable its API is?
    Ólafur Páll Geirsson
    @olafurpg
    there is also a nice parser in https://github.com/twitter/rsc/ that you could base off
    Roman Janusz
    @ghik
    I'd be fine if I could just fork some existing parser and modify it to my needs
    Ólafur Páll Geirsson
    @olafurpg
    I think you can consider all dotty compiler apis as private
    Roman Janusz
    @ghik
    Oh yeah I forgot about rsc, thanks
    Ólafur Páll Geirsson
    @olafurpg
    best approach is probably to copy-paste and adapt
    so find the code you understand the best and feel most comfortable changing
    I BTW found the link to the tolerant-php-parser in https://github.com/scalameta/scalameta/issues/1170#issuecomment-403751263 interesting
    Roman Janusz
    @ghik
    I'll look into it, thanks for help and all the references!
    Ólafur Páll Geirsson
    @olafurpg
    One somewhat interesting observation I found while working on diagnostics in Metals is that it seems to be totally fine to publish only a single syntax error
    it's usually the first syntax error that's most helpful in tracking down the problem, if the parser recovers from the first error and continues to publish 10 more syntax errors then it makes it harder to track the source of the error
    Roman Janusz
    @ghik
    yeah but even that single syntax error prevents the parser from returning an actual tree that could be used for things like completion
    Ólafur Páll Geirsson
    @olafurpg
    so Metals actually runs the Scalameta parser on every keystroke even if it has no parser recovery and publishes at most a single syntax error
    the thing is that you wouldn't be able to implement completions anyways with the impartial scalameta tree
    for completions you need a typechecker
    Roman Janusz
    @ghik
    scala presentation compiler has no problem with that
    it can typecheck on best-effort manner
    Ólafur Páll Geirsson
    @olafurpg
    yeah, we use the presentation compiler with completions and it's working pretty great in my experience
    Roman Janusz
    @ghik
    yes I'm also using it in my "current version" of this "programming language"
    but lossy parsing is really biting me
    Ólafur Páll Geirsson
    @olafurpg
    the desugared scalac trees simplify a lot of semantic analysis
    Roman Janusz
    @ghik
    the thing that i hoped for is scalameta for syntactic analysis and presentation compiler for potential typechecking and completion
    presentation compiler unfortunately has a lot of limitations
    for example: it doesn't handle scala.Dynamic well
    Ólafur Páll Geirsson
    @olafurpg
    we have an mtags module in metals that adds several feature improvements to the scala presentation compiler APIs, including support for Dynamic
    the dynamic fixes could be upstreamed into the compiler, but other improvements include for example auto-importing symbols that are in the workspace but not in scope
    we do several syntactic analyses using the scalameta parser such as code folding and document outlines
    but they only run on valid source code, in between that we adjust positions based on token edit distance between the last successful parse and the current dirty buffer
    Kiko
    @kikofernandez
    Hi there. I was wondering if there is any way to get transform a semanticdb class into its pretty printed form, so that I can get interesting information from semantic db and use the AST facilities of scalameta
    Ólafur Páll Geirsson
    @olafurpg
    @kikofernandez the scalafix apis combine the Scalameta ast and SemanticDB
    Kiko
    @kikofernandez
    right, so I have to go for scalafix them. Thanks
    I am really new into Scala and Scalameta et al. Is there any way I can use Scalafix to generate code (not visible to the developer) that gets compiled?
    Anthony Garo
    @agaro1121
    Hi everyone, I want to match on imports that start with a specific string.
    What’s the best way to do that?
    something like:
    case importer"scala.$eref.{..$importeesnel}" =>
          println(eref)
          println(importeesnel)
          println()
    mohnishkodnani
    @mohnishkodnani
    Hi,
    I am trying to create a service , where given certain parameters, you create code for a new usecase. I have a scala.meta.Type from parsing the case class() extends ... with ... > i want to use that scala.meta.Type with reflection to find all the methods I have to override and generate them ? Is there a way to do this ?
    Ólafur Páll Geirsson
    @olafurpg
    @mohnishkodnani a scala.meta.Type represents only the syntax tree of that source code, it has no knowledge about the type or the supermethods to implement so this is not possible I'm afraid.
    Gabriele Petronella
    @gabro

    is anyone experiencing this issue with spurious unused warnings when using quasiquotes as a pattern?

    def f(m: Decl.Def): List[scala.meta.Type] =
        m.decltpe.collect {
          case t"$_[$tpe]" => tpe
        }

    This yields two unused warnings, one for each $

    Anthony Cerruti
    @srnb_gitlab
    What's the status on Scala Meta for Native 0.3.9/2.11 and JS 1.0.0-M8/2.12-2.13?
    Brent Gracey
    @myFree

    Hi all;

    Is there a plugin which can generate SemanticDb files for a Java project?

    From https://scalameta.org/docs/semanticdb/guide.html#example
    SemanticDB producers provide full Scala support and partial Java support

    Is this support only for when a Scala project calls to Java files?

    Thanks

    mtes3
    @mtes3
    Hello.
    I tried to move from scala-macros to meta.
    But I still do not understand the next things:
    meta v4.2.0 is library for analyze scala code (read file -> transform to tokens, ans so on)
    but meta contain inline definition for make macros, is it right? and for macro purposes I should use 1.8.0 + meta/paradise compiler plugin, is it correct?
    thanks in advance
    Gabriele Petronella
    @gabro
    @mtes3 scalameta macros is a dead unmaintained project, that won’t be published for Scala 2.13. You should stick with macro paradise, which has been moved into the compiler under a flag
    mtes3
    @mtes3
    @gabro thanks for explanation. under macro paradise did you mean base macros (white/black context)?
    Gabriele Petronella
    @gabro
    I also mean macro annotations
    mtes3
    @mtes3
    I understood, thanks
    Dariusz Marynowski
    @driuzz

    Hi all,
    I'm trying to use scalameta to get type information for very simple piece of code, like this:

    object X {
      val a = List(1,2,3).head
    }

    the problem is with head method and its type, which is always A, but should be Int in this case. Also synthetic information is not generated for this method, so there is no way to retrieve real type.
    I checked scalameta code and it looks like toTextDocument method in implicit class XtensionCompilationUnitDocument doesn't support such situation at all. Synthetic data are generated for only small amount of hardcoded methods, like apply, map etc.
    Also type (tpe field) from Trees#Selectis not read at all what causes that there is no way to retrieve return type for head method from SemanticDocument.
    Can someone advice how to handle this problem?

    Ólafur Páll Geirsson
    @olafurpg
    @driuzz getting the type of a term is not supported with SemanticDB