Skip to content

Commit

Permalink
Enable compiler driven save actions
Browse files Browse the repository at this point in the history
It is now possible to correctly abort compiler driven save actions,
therefore they can be enabled. However given that it is very likely that
timeouts occur and given that refactorings still introduce syntax errors
to files, all compiler driven save actions are marked as experimental.

Re #1002308
  • Loading branch information
kiritsuku committed May 27, 2015
1 parent 1c10f07 commit c7271ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
Expand Up @@ -5,8 +5,18 @@ import scala.tools.nsc.ast.parser.Tokens

object AddMissingOverrideSetting extends SaveActionSetting(
id = ExtensionSetting.fullyQualifiedName[AddMissingOverride],
name = "Add missing override keyword",
description = "Adds the override keyword to all symbols that override another symbol.",
name = "Add missing override keyword (experimental)",
description =
"""|Adds the override keyword to all symbols that override another symbol.
|
|Note: This save action is marked as experimental because it relies on compiler \
|support. This means that on the one side it may need a lot of time to complete \
|and on the other side it may introduce compilation errors due to the fact that \
|it relies on tree refactorings. You can enable this save action but please \
|consider to disable it again when it interferes in any way with your work \
|approach. The Scala IDE team would be happy when you also report back any \
|problems that you have with this save action.
|""".stripMargin.replaceAll("\\\\\n", ""),
codeExample = """|trait T {
| def method: Int
| def value: Int
Expand Down
Expand Up @@ -3,10 +3,19 @@ package saveactions

object AddReturnTypeToPublicSymbolsSetting extends SaveActionSetting(
id = ExtensionSetting.fullyQualifiedName[AddReturnTypeToPublicSymbols],
name = "Add return type to public symbols",
name = "Add return type to public symbols (experimental)",
description =
"Adds the return type to all public symbols when they not yet exist." +
" The symbols that can be public and can have types are defs, vars and vals.",
"""|Adds the return type to all public symbols when they not yet exist. \
|The symbols that can be public and can have types are defs, vars and vals.
|
|Note: This save action is marked as experimental because it relies on compiler \
|support. This means that on the one side it may need a lot of time to complete \
|and on the other side it may introduce compilation errors due to the fact that \
|it relies on tree refactorings. You can enable this save action but please \
|consider to disable it again when it interferes in any way with your work \
|approach. The Scala IDE team would be happy when you also report back any \
|problems that you have with this save action.
|""".stripMargin.replaceAll("\\\\\n", ""),
codeExample = """|class X {
| def meth = new java.io.File("")
| val value = new java.io.File("")
Expand Down
Expand Up @@ -44,21 +44,11 @@ import org.scalaide.util.internal.eclipse.TextEditUtils

object SaveActionExtensions {

/**
* The settings for all existing save actions.
*/
val saveActionSettings: Seq[SaveActionSetting] = Seq(
RemoveTrailingWhitespaceSetting,
AddNewLineAtEndOfFileSetting,
AutoFormattingSetting,
RemoveDuplicatedEmptyLinesSetting
)

/**
* The ID which is used as key in the preference store to identify the actual
* timeout value for save actions.
*/
final val SaveActionTimeoutId: String = "org.scalaide.extensions.SaveAction.Timeout"
val SaveActionTimeoutId: String = "org.scalaide.extensions.SaveAction.Timeout"

/**
* The time a save action gets until the IDE waits no longer on its result.
Expand All @@ -77,6 +67,13 @@ object SaveActionExtensions {
AddMissingOverrideSetting -> AddMissingOverrideCreator.create _,
AddReturnTypeToPublicSymbolsSetting -> AddReturnTypeToPublicSymbolsCreator.create _
)

/**
* The settings for all existing save actions.
*/
val saveActionSettings: Seq[SaveActionSetting] =
documentSaveActions.map(_._1) ++ compilerSaveActions.map(_._1)

}

trait SaveActionExtensions extends HasLogger {
Expand Down Expand Up @@ -135,10 +132,7 @@ trait SaveActionExtensions extends HasLogger {

try {
applyDocumentExtensions(udoc)
// TODO compiler driven save actions first need to get fixed before they can be enabled.
// See #1002308
if (false)
applyCompilerExtensions(udoc)
applyCompilerExtensions(udoc)
}
finally {
updateEditor()
Expand Down

0 comments on commit c7271ed

Please sign in to comment.