Skip to content

Commit

Permalink
reverse moving outline from Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Apr 19, 2024
1 parent 56d4ce5 commit dd3c21e
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 88 deletions.
6 changes: 6 additions & 0 deletions mtags/src/main/scala-2.11/scala/meta/internal/pc/Compat.scala
Expand Up @@ -3,6 +3,8 @@ package scala.meta.internal.pc
import scala.tools.nsc.reporters.Reporter
import scala.tools.nsc.reporters.StoreReporter

import scala.meta.pc.OutlineFiles

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] = {
val dealiased = tpe.dealiasWiden
Expand All @@ -19,4 +21,8 @@ trait Compat { this: MetalsGlobal =>
def isAliasCompletion(m: Member): Boolean = false

def constantType(c: ConstantType): ConstantType = c

def runOutline(files: OutlineFiles): Unit = {
// no outline compilation for 2.11
}
}

This file was deleted.

37 changes: 36 additions & 1 deletion mtags/src/main/scala-2.12/scala/meta/internal/pc/Compat.scala
@@ -1,8 +1,14 @@
package scala.meta.internal.pc

import scala.tools.nsc.reporters.Reporter
import java.{util => ju}

import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter

import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.OutlineFiles
import scala.meta.pc.VirtualFileParams

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrSamArgTypes(tpe)
Expand All @@ -16,4 +22,33 @@ trait Compat { this: MetalsGlobal =>
def isAliasCompletion(m: Member): Boolean = false

def constantType(c: ConstantType): ConstantType = c

def runOutline(files: OutlineFiles): Unit = {
this.settings.Youtline.value = true
runOutline(files.files)
if (files.isFirstCompileSubstitute()) {
// if first compilation substitute we compile all files twice
// first to emit symbols, second so signatures have information about those symbols
// this isn't a perfect strategy but much better than single compile
runOutline(files.files, forceNewUnit = true)
}
this.settings.Youtline.value = false
}

private def runOutline(
files: ju.List[VirtualFileParams],
forceNewUnit: Boolean = false
): Unit = {
files.asScala.foreach { params =>
val unit = this.addCompilationUnit(
params.text(),
params.uri.toString(),
cursor = None,
isOutline = true,
forceNew = forceNewUnit
)
this.typeCheck(unit)
this.richCompilationCache.put(params.uri().toString(), unit)
}
}
}
38 changes: 0 additions & 38 deletions mtags/src/main/scala-2.12/scala/meta/internal/pc/Outline.scala

This file was deleted.

34 changes: 34 additions & 0 deletions mtags/src/main/scala-2.13.5/meta/internal/pc/Compat.scala
@@ -1,8 +1,14 @@
package scala.meta.internal.pc

import java.{util => ju}

import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter

import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.OutlineFiles
import scala.meta.pc.VirtualFileParams

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrPfOrSamArgTypes(tpe)
Expand All @@ -20,4 +26,32 @@ trait Compat { this: MetalsGlobal =>
def constantType(c: ConstantType): ConstantType =
if (c.value.isSuitableLiteralType) LiteralType(c.value) else c

def runOutline(files: OutlineFiles): Unit = {
this.settings.Youtline.value = true
runOutline(files.files)
if (files.isFirstCompileSubstitute()) {
// if first compilation substitute we compile all files twice
// first to emit symbols, second so signatures have information about those symbols
// this isn't a perfect strategy but much better than single compile
runOutline(files.files, forceNewUnit = true)
}
this.settings.Youtline.value = false
}

private def runOutline(
files: ju.List[VirtualFileParams],
forceNewUnit: Boolean = false
): Unit = {
files.asScala.foreach { params =>
val unit = this.addCompilationUnit(
params.text(),
params.uri.toString(),
cursor = None,
isOutline = true,
forceNew = forceNewUnit
)
this.typeCheck(unit)
this.richCompilationCache.put(params.uri().toString(), unit)
}
}
}
35 changes: 35 additions & 0 deletions mtags/src/main/scala-2.13.6/meta/internal/pc/Compat.scala
@@ -1,8 +1,14 @@
package scala.meta.internal.pc

import java.{util => ju}

import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter

import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.OutlineFiles
import scala.meta.pc.VirtualFileParams

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrPfOrSamArgTypes(tpe)
Expand All @@ -19,4 +25,33 @@ trait Compat { this: MetalsGlobal =>

def constantType(c: ConstantType): ConstantType =
if (c.value.isSuitableLiteralType) LiteralType(c.value) else c

def runOutline(files: OutlineFiles): Unit = {
this.settings.Youtline.value = true
runOutline(files.files)
if (files.isFirstCompileSubstitute()) {
// if first compilation substitute we compile all files twice
// first to emit symbols, second so signatures have information about those symbols
// this isn't a perfect strategy but much better than single compile
runOutline(files.files, forceNewUnit = true)
}
this.settings.Youtline.value = false
}

private def runOutline(
files: ju.List[VirtualFileParams],
forceNewUnit: Boolean = false
): Unit = {
files.asScala.foreach { params =>
val unit = this.addCompilationUnit(
params.text(),
params.uri.toString(),
cursor = None,
isOutline = true,
forceNew = forceNewUnit
)
this.typeCheck(unit)
this.richCompilationCache.put(params.uri().toString(), unit)
}
}
}
35 changes: 35 additions & 0 deletions mtags/src/main/scala-2.13.7/meta/internal/pc/Compat.scala
@@ -1,8 +1,14 @@
package scala.meta.internal.pc

import java.{util => ju}

import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter

import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.OutlineFiles
import scala.meta.pc.VirtualFileParams

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrPfOrSamArgTypes(tpe)
Expand All @@ -20,4 +26,33 @@ trait Compat { this: MetalsGlobal =>
def constantType(c: ConstantType): ConstantType =
if (c.value.isSuitableLiteralType) LiteralType(c.value) else c

def runOutline(files: OutlineFiles): Unit = {
this.settings.Youtline.value = true
runOutline(files.files)
if (files.isFirstCompileSubstitute()) {
// if first compilation substitute we compile all files twice
// first to emit symbols, second so signatures have information about those symbols
// this isn't a perfect strategy but much better than single compile
runOutline(files.files, forceNewUnit = true)
}
this.settings.Youtline.value = false
}

private def runOutline(
files: ju.List[VirtualFileParams],
forceNewUnit: Boolean = false
): Unit = {
files.asScala.foreach { params =>
val unit = this.addCompilationUnit(
params.text(),
params.uri.toString(),
cursor = None,
isOutline = true,
forceNew = forceNewUnit
)
this.typeCheck(unit)
this.richCompilationCache.put(params.uri().toString(), unit)
}
}

}
35 changes: 35 additions & 0 deletions mtags/src/main/scala-2.13/scala/meta/internal/pc/Compat.scala
@@ -1,8 +1,14 @@
package scala.meta.internal.pc

import java.{util => ju}

import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter

import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.OutlineFiles
import scala.meta.pc.VirtualFileParams

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrPfOrSamArgTypes(tpe)
Expand All @@ -23,4 +29,33 @@ trait Compat { this: MetalsGlobal =>

def constantType(c: ConstantType): ConstantType =
if (c.value.isSuitableLiteralType) LiteralType(c.value) else c

def runOutline(files: OutlineFiles): Unit = {
this.settings.Youtline.value = true
runOutline(files.files)
if (files.isFirstCompileSubstitute()) {
// if first compilation substitute we compile all files twice
// first to emit symbols, second so signatures have information about those symbols
// this isn't a perfect strategy but much better than single compile
runOutline(files.files, forceNewUnit = true)
}
this.settings.Youtline.value = false
}

private def runOutline(
files: ju.List[VirtualFileParams],
forceNewUnit: Boolean = false
): Unit = {
files.asScala.foreach { params =>
val unit = this.addCompilationUnit(
params.text(),
params.uri.toString(),
cursor = None,
isOutline = true,
forceNew = forceNewUnit
)
this.typeCheck(unit)
this.richCompilationCache.put(params.uri().toString(), unit)
}
}
}
38 changes: 0 additions & 38 deletions mtags/src/main/scala-2.13/scala/meta/internal/pc/Outline.scala

This file was deleted.

Expand Up @@ -61,8 +61,7 @@ class MetalsGlobal(
with GlobalProxy
with AutoImports
with Keywords
with WorkspaceSymbolSearch
with Outline { compiler =>
with WorkspaceSymbolSearch { compiler =>
hijackPresentationCompilerThread()

val logger: Logger = Logger.getLogger(classOf[MetalsGlobal].getName)
Expand Down

0 comments on commit dd3c21e

Please sign in to comment.