-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Semester Project] Add new front-end phase for unused entities and add support for unused imports #16157
[Semester Project] Add new front-end phase for unused entities and add support for unused imports #16157
Changes from 40 commits
27bfda8
93ba6c9
f2c1551
d6fa4cb
9f75334
b131601
e37c2f9
2d6da62
617155d
0801dd6
a6e7d05
e1188b6
5447cdb
950e7de
9ad1daa
5ecb0eb
a1c2bae
f993782
b2fd8cb
368748a
e69c4a3
8ac97b3
892621b
6d8d20d
412412c
f354b96
d41c6dd
95c8a40
b2f0fa1
82290c8
5a755dd
2ed1f1f
8a91af1
ca8dbaf
426d34a
5ab55f8
0cb2af0
d1f9441
e158a9f
e2b6b61
b0790d1
7f04ce3
779ec7d
d37d99e
ae24d64
527aa31
bfa20a1
c70fa68
7de90b3
c89e27c
422ecb8
4a06bc6
1db9040
08f807c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import annotation.tailrec | |
import collection.mutable.ArrayBuffer | ||
import reflect.ClassTag | ||
import scala.util.{Success, Failure} | ||
import dotty.tools.dotc.config.Settings.Setting.ChoiceWithHelp | ||
|
||
object Settings: | ||
|
||
|
@@ -184,6 +185,19 @@ object Settings: | |
def update(x: T)(using Context): SettingsState = setting.updateIn(ctx.settingsState, x) | ||
def isDefault(using Context): Boolean = setting.isDefaultIn(ctx.settingsState) | ||
|
||
/** | ||
* A choice with help description. | ||
* | ||
* NOTE : `equals` and `toString` have special behaviors | ||
*/ | ||
case class ChoiceWithHelp[T](name: T, description: String): | ||
override def equals(x: Any): Boolean = x match | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a bit of a hack... But I think we can address this in the future, there are probably other things that could be cleaned up in the Settings implementation at some point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this was a dirty fix, just to give basic documentation for this new feature. I can maybe find a better solution if I have some time once I fixed the main parts of the PR. |
||
case s:String => s == name.toString() | ||
case _ => false | ||
override def toString(): String = | ||
s"\n- $name${if description.isEmpty() then "" else s" :\n\t${description.replace("\n","\n\t")}"}" | ||
end Setting | ||
|
||
class SettingGroup { | ||
|
||
private val _allSettings = new ArrayBuffer[Setting[?]] | ||
|
@@ -265,6 +279,9 @@ object Settings: | |
def MultiChoiceSetting(name: String, helpArg: String, descr: String, choices: List[String], default: List[String], aliases: List[String] = Nil): Setting[List[String]] = | ||
publish(Setting(name, descr, default, helpArg, Some(choices), aliases = aliases)) | ||
|
||
def MultiChoiceHelpSetting(name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil): Setting[List[ChoiceWithHelp[String]]] = | ||
publish(Setting(name, descr, default, helpArg, Some(choices), aliases = aliases)) | ||
|
||
def IntSetting(name: String, descr: String, default: Int, aliases: List[String] = Nil): Setting[Int] = | ||
publish(Setting(name, descr, default, aliases = aliases)) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we live without this option? It really seems to address an edge case that is very, very unlikely to affect anyone and Martin says it would only stem from a "blatant abuse of inlining and the type system".
There's always
@nowarn
if someone needs to work around a false positive.@szymon-rd wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I agree, but it's not possible to annotate imports. So I wanted to leave some workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True...