Skip to content

Commit ee0bc24

Browse files
author
builduser
committed
Merged branch idea251.release into idea251.x
2 parents 315dade + 83d0e13 commit ee0bc24

File tree

5 files changed

+27
-189
lines changed

5 files changed

+27
-189
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,16 @@ UI Designer uses different border class in internal mode, see `com.intellij.uiDe
113113
4. **Unexpected local git changes in `uiDesigner.xml` or other files in .idea directory** \
114114
It may happen due to disable [internal mode](https://plugins.jetbrains.com/docs/intellij/enabling-internal.html) or by enabling it after/during setup. \
115115
The solution to this problem might be to revert these changes, enable [internal mode](https://plugins.jetbrains.com/docs/intellij/enabling-internal.html) (if it has not already been done) and restart IntelliJ.
116-
5. **The Scala plugin is not loaded when running the `scalaCommunity` Run Configuration.** Unfortunately, there can be multiple reasons for this, like an improperly packaged plugin which cannot be loaded by IDEA at runtime. \
117-
Check the list of project modules in `File > Project Structure...` and make sure that they don't have a name that starts with `scala.<module name>` (e.g. `scala.structure-view`). This is a bug in the sbt import process. \
118-
If there are modules like this, then remove all modules from the project (in the same Project Structure window) and reimport the project `<sbt tab> > Reload All sbt Projects`.
116+
5. **The Scala plugin is not loaded when running the `scalaCommunity` / `scalaUltimate` Run Configuration.**\
117+
Unfortunately, there can be multiple reasons for this, like an improperly packaged plugin which cannot be loaded by IDEA at runtime. Check the list of project modules in `File > Project Structure...` and make sure that they don't have a name that starts with `scala.<module name>` (e.g. `scala.structure-view`). This is a bug in the sbt import process. If there are modules like this, then remove all modules from the project (in the same Project Structure window) and reimport the project `<sbt tab> > Reload All sbt Projects`.
118+
**TLDR**:
119+
1. Open `File | Project Structure`
120+
2. Select "Modules"
121+
3. Remove all modules except `-build` modules (they have special icon with sbt) and except root modules like (scalaCommunity or scalaUltimate)
122+
4. Click "Ok"
123+
5. Remove `target` directory in the project root (the one that contains `plugin/Scala` directory)
124+
6. Reload the project structure
125+
7. It should be fixed now! Run the main run configuration (`scalaCommunity` or `scalaUltimate`)
119126

120127
## Other
121128
### Investigation performance issues

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml"
22

33
//NOTE: KEEP VERSIONS IN SYNC WITH ultimate/project/plugins.sbt
44
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.2")
5-
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "4.1.3")
5+
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "4.1.4")
66
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
77
addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % "3.1.4")
88
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.13.3")

scala/scala-impl/resources/messages/ScalaBundle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,6 @@ xml.delete.unmatched.tag=Delete Unmatched Tag
843843
xml.rename.opening.tag=Rename Opening Tag
844844
xml.rename.closing.tag=Rename Closing Tag
845845

846-
### org/jetbrains/plugins/scala/components/PluginVersionVerifier.scala
847-
incompatible.plugin.detected=Incompatible plugin detected
848-
849846
### org/jetbrains/plugins/scala/components/Scala3Disclaimer.scala
850847
scala.3.support.is.experimental=Scala 3 support is being actively developed.<br>Please use nightly builds to benefit from the new improvements.
851848
configure.updates=Configure updates...

scala/scala-impl/src/org/jetbrains/plugins/scala/components/PluginVersionVerifier.scala

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@ package org.jetbrains.plugins.scala.components
22

33
import com.intellij.ide.plugins.cl.PluginClassLoader
44
import com.intellij.ide.plugins.{org => _, _}
5-
import com.intellij.notification._
6-
import com.intellij.openapi.application.ApplicationManager
7-
import com.intellij.openapi.diagnostic.{ControlFlowException, Logger}
5+
import com.intellij.openapi.diagnostic.Logger
86
import com.intellij.openapi.extensions.PluginId
9-
import com.intellij.util.PathUtil
10-
import org.jetbrains.annotations.Nls
11-
import org.jetbrains.plugins.scala.ScalaBundle
12-
import org.jetbrains.plugins.scala.extensions.{PathExt, invokeLater}
13-
import org.jetbrains.plugins.scala.util.ScalaNotificationGroups
14-
15-
import java.nio.file.Paths
16-
import javax.swing.event.HyperlinkEvent
17-
import scala.annotation.nowarn
7+
import org.jetbrains.plugins.scala.extensions.invokeLater
188

199
object ScalaPluginVersionVerifier {
2010

@@ -67,78 +57,10 @@ object ScalaPluginVersionVerifier {
6757
class ScalaPluginVersionVerifierActivity extends RunOnceStartupActivity {
6858
override def doRunActivity(): Unit = {
6959
invokeLater {
70-
ScalaPluginUpdater.upgradeRepo()
7160
ScalaPluginUpdater.askUpdatePluginBranchIfNeeded()
72-
checkHaskForcePlugin()
7361
ScalaPluginUpdater.postCheckIdeaCompatibility()
74-
ScalaPluginUpdater.setupReporter()
7562
}
7663
}
7764

7865
override protected def doCleanup(): Unit = {}
79-
80-
private def showIncompatiblePluginNotification(@Nls message: String)(callback: String => Unit): Unit = {
81-
if (ApplicationManager.getApplication.isUnitTestMode) {
82-
ScalaPluginVersionVerifier.LOG.error(message)
83-
} else {
84-
val notification = ScalaNotificationGroups.scalaPluginVerifier.createNotification(ScalaBundle.message("incompatible.plugin.detected"), message, NotificationType.ERROR)
85-
//TODO
86-
notification.setListener((notification: Notification, event: HyperlinkEvent) => {
87-
notification.expire()
88-
val description = event.getDescription
89-
callback(description)
90-
}): @nowarn("cat=deprecation")
91-
92-
Notifications.Bus.notify(notification)
93-
}
94-
}
95-
96-
private def checkHaskForcePlugin(): Unit = {
97-
val haskforceId = PluginId.findId("com.haskforce")
98-
val plugin = PluginManagerCore.getPlugin(haskforceId)
99-
if (plugin == null || !plugin.isEnabled)
100-
return
101-
102-
val hasScala211 = try {
103-
val scalaClass = plugin.getPluginClassLoader.loadClass("scala.Option")
104-
val pathToJar = PathUtil.getJarPathForClass(scalaClass)
105-
val path = Paths.get(pathToJar)
106-
path.nameContains("-2.11")
107-
} catch {
108-
case c: ControlFlowException => throw c
109-
case _: ClassNotFoundException => false
110-
case e: Exception =>
111-
ScalaPluginVersionVerifier.LOG.debug(e)
112-
false
113-
}
114-
if (hasScala211) {
115-
val DisableHaskForcePlugin = "Disable HaskForce Plugin"
116-
val DisableScalaPlugin = "Disable Scala Plugin"
117-
val Ignore = "Ignore"
118-
val message =
119-
s"""Plugin ${plugin.getName} of version ${plugin.getVersion} is
120-
|incompatible with Scala Plugin for IDEA 2017.3
121-
|${hyperlink(DisableHaskForcePlugin)}
122-
|${hyperlink(DisableScalaPlugin)}
123-
|${hyperlink(Ignore)}
124-
|""".stripMargin
125-
showIncompatiblePluginNotification(message) {
126-
case DisableHaskForcePlugin =>
127-
disablePlugin(haskforceId)
128-
case DisableScalaPlugin =>
129-
disablePlugin(ScalaPluginVersionVerifier.scalaPluginId)
130-
case Ignore =>
131-
case _ =>
132-
}
133-
}
134-
135-
}
136-
137-
private def hyperlink(description: String): String =
138-
s"""<p/><a href="$description">$description</a>"""
139-
140-
private def disablePlugin(id: PluginId) = {
141-
PluginManagerCore.disablePlugin(id)
142-
PluginManagerConfigurable.showRestartDialog()
143-
}
14466
}

scala/scala-impl/src/org/jetbrains/plugins/scala/components/ScalaPluginUpdater.scala

Lines changed: 14 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
package org.jetbrains.plugins.scala.components
22

33
import com.intellij.ide.plugins.{org => _, _}
4-
import com.intellij.ide.util.PropertiesComponent
54
import com.intellij.notification._
65
import com.intellij.openapi.actionSystem.{ActionUpdateThread, AnAction, AnActionEvent}
7-
import com.intellij.openapi.application.{ApplicationInfo, ApplicationManager, PermanentInstallationID}
6+
import com.intellij.openapi.application.{ApplicationInfo, ApplicationManager}
87
import com.intellij.openapi.diagnostic.Logger
9-
import com.intellij.openapi.editor.EditorFactory
10-
import com.intellij.openapi.editor.event.{DocumentEvent, DocumentListener}
11-
import com.intellij.openapi.fileEditor.FileDocumentManager
128
import com.intellij.openapi.project.ProjectManager
139
import com.intellij.openapi.updateSettings.impl._
1410
import com.intellij.openapi.util.NlsActions.ActionText
15-
import com.intellij.openapi.util.{BuildNumber, JDOMUtil, SystemInfo}
16-
import com.intellij.openapi.vfs.CharsetToolkit
11+
import com.intellij.openapi.util.{BuildNumber, JDOMUtil}
1712
import com.intellij.platform.ide.customization.ExternalProductResourceUrls
1813
import com.intellij.util.io.HttpRequests
19-
import com.intellij.util.io.HttpRequests.Request
2014
import org.jdom.JDOMException
2115
import org.jetbrains.plugins.scala.settings.ScalaApplicationSettings
2216
import org.jetbrains.plugins.scala.settings.ScalaApplicationSettings.pluginBranch
2317
import org.jetbrains.plugins.scala.settings.ScalaApplicationSettings.pluginBranch._
24-
import org.jetbrains.plugins.scala.util.{ScalaNotificationGroups, UnloadAwareDisposable}
25-
import org.jetbrains.plugins.scala.{ScalaBundle, ScalaFileType, extensions}
18+
import org.jetbrains.plugins.scala.util.ScalaNotificationGroups
19+
import org.jetbrains.plugins.scala.{ScalaBundle, extensions}
2620

27-
import java.net.URLEncoder
28-
import java.util.concurrent.TimeUnit
2921
import scala.xml.XML
3022

3123
class InvalidRepoException(what: String) extends Exception(what)
@@ -35,55 +27,23 @@ object ScalaPluginUpdater {
3527
private val LOG = Logger.getInstance(getClass)
3628
private val scalaPluginId = "1347"
3729
private val baseUrl: String = "https://plugins.jetbrains.com/plugins/%s/" + scalaPluginId
38-
private var doneUpdating = false
3930
private def pluginDescriptor: IdeaPluginDescriptorImpl = ScalaPluginVersionVerifier.getPluginDescriptor
4031

41-
// *_OLD versions are for legacy repository format.
42-
// Need to keep track of them to upgrade to new repository format automatically
43-
// Remove eventually, when no significant amount of users will have older ones.
44-
private val CASSIOPEIA_OLD = "cassiopeia_old"
45-
private val FOURTEEN_ONE_OLD = "14.1_old"
46-
private val FOURTEEN_ONE = "14.1"
47-
48-
private val knownVersions = Map(
49-
CASSIOPEIA_OLD -> Map(
50-
Release -> "DUMMY",
51-
EAP -> "https://www.jetbrains.com/idea/plugins/scala-eap-cassiopeia.xml",
52-
Nightly -> "https://www.jetbrains.com/idea/plugins/scala-nightly-cassiopeia.xml"
53-
),
54-
FOURTEEN_ONE_OLD -> Map(
55-
Release -> "DUMMY",
56-
EAP -> "https://www.jetbrains.com/idea/plugins/scala-eap-14.1.xml",
57-
Nightly -> ""
58-
),
59-
FOURTEEN_ONE -> Map(
60-
Release -> "DUMMY",
61-
EAP -> baseUrl.format("eap"),
62-
Nightly -> baseUrl.format("nightly")
63-
)
32+
private def currentRepo: Map[pluginBranch, String] = Map(
33+
Release -> "DUMMY",
34+
EAP -> baseUrl.format("eap"),
35+
Nightly -> baseUrl.format("nightly")
6436
)
6537

66-
private val currentVersion: String = FOURTEEN_ONE
67-
68-
private def currentRepo: Map[pluginBranch, String] = knownVersions(currentVersion)
69-
7038
private def NotificationGroup = ScalaNotificationGroups.scalaPluginUpdater
7139

7240
// save plugin version before patching to restore it when switching back
7341
private var savedPluginVersion = ""
7442

75-
private val updateListener = new DocumentListener {
76-
override def documentChanged(e: DocumentEvent): Unit = {
77-
val file = FileDocumentManager.getInstance().getFile(e.getDocument)
78-
if (file != null && file.getFileType == ScalaFileType.INSTANCE)
79-
scheduleUpdate()
80-
}
81-
}
82-
8343
@throws(classOf[InvalidRepoException])
8444
def doUpdatePluginHosts(branch: ScalaApplicationSettings.pluginBranch, descriptor: IdeaPluginDescriptorImpl): AnyVal = {
85-
if(currentRepo(branch).isEmpty)
86-
throw new InvalidRepoException(s"Branch $branch is unavailable for IDEA version $currentVersion")
45+
if (currentRepo(branch).isEmpty)
46+
throw new InvalidRepoException(s"Branch $branch is unavailable")
8747

8848
// update hack - set plugin version to 0 when downgrading
8949
// also unpatch it back if user changed mind about downgrading
@@ -121,7 +81,7 @@ object ScalaPluginUpdater {
12181
else Release
12282
}
12383

124-
def pluginIsEap: Boolean = {
84+
private def pluginIsEap: Boolean = {
12585
val updateSettings = UpdateSettings.getInstance()
12686
updateSettings.getStoredPluginHosts.contains(currentRepo(EAP))
12787
}
@@ -131,28 +91,7 @@ object ScalaPluginUpdater {
13191
updateSettings.getStoredPluginHosts.contains(currentRepo(Nightly))
13292
}
13393

134-
def pluginIsRelease: Boolean = !pluginIsEap && !pluginIsNightly
135-
136-
def upgradeRepo(): Unit = {
137-
val updateSettings = UpdateSettings.getInstance()
138-
for {
139-
(version, repo) <- knownVersions
140-
if version != currentVersion
141-
} {
142-
if (updateSettings.getStoredPluginHosts.contains(repo(EAP))) {
143-
updateSettings.getStoredPluginHosts.remove(repo(EAP))
144-
if (currentRepo(EAP).nonEmpty)
145-
updateSettings.getStoredPluginHosts.add(currentRepo(EAP))
146-
}
147-
if (updateSettings.getStoredPluginHosts.contains(repo(Nightly))) {
148-
updateSettings.getStoredPluginHosts.remove(repo(Nightly))
149-
if (currentRepo(Nightly).nonEmpty)
150-
updateSettings.getStoredPluginHosts.add(currentRepo(Nightly))
151-
else if (currentRepo(EAP).nonEmpty)
152-
updateSettings.getStoredPluginHosts.add(currentRepo(EAP))
153-
}
154-
}
155-
}
94+
private def pluginIsRelease: Boolean = !pluginIsEap && !pluginIsNightly
15695

15796
def postCheckIdeaCompatibility(branch: ScalaApplicationSettings.pluginBranch): Unit = {
15897
val infoImpl = ApplicationInfo.getInstance()
@@ -203,6 +142,8 @@ object ScalaPluginUpdater {
203142

204143
def getPlatformUpdateResult: Option[PlatformUpdates] = {
205144
val url = ExternalProductResourceUrls.getInstance.getUpdateMetadataUrl
145+
if (url == null)
146+
return None
206147

207148
val info: Option[Product] = HttpRequests.request(url).connect { request =>
208149
val productCode = ApplicationInfo.getInstance().getBuild.getProductCode
@@ -222,35 +163,6 @@ object ScalaPluginUpdater {
222163
notification.foreach(Notifications.Bus.notify)
223164
}
224165

225-
private def scheduleUpdate(): Unit = {
226-
val key = "scala.last.updated"
227-
val lastUpdateTime = PropertiesComponent.getInstance().getLong(key , 0)
228-
EditorFactory.getInstance().getEventMulticaster.removeDocumentListener(updateListener)
229-
if (lastUpdateTime == 0L || System.currentTimeMillis() - lastUpdateTime > TimeUnit.DAYS.toMillis(1)) {
230-
ApplicationManager.getApplication.executeOnPooledThread(new Runnable {
231-
override def run(): Unit = {
232-
val buildNumber = ApplicationInfo.getInstance().getBuild.asString()
233-
val pluginVersion = pluginDescriptor.getVersion
234-
val os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8)
235-
val uid: String = PermanentInstallationID.get()
236-
val url = s"https://plugins.jetbrains.com/plugins/list?pluginId=$scalaPluginId&build=$buildNumber&pluginVersion=$pluginVersion&os=$os&uuid=$uid"
237-
PropertiesComponent.getInstance().setValue(key, System.currentTimeMillis().toString)
238-
doneUpdating = true
239-
try {
240-
HttpRequests.request(url).connect((request: Request) => JDOMUtil.load(request.getReader()))
241-
} catch {
242-
case e: Throwable => LOG.warn(e)
243-
}
244-
}
245-
})
246-
}
247-
}
248-
249-
def setupReporter(): Unit = {
250-
if (ApplicationManager.getApplication.isUnitTestMode) return
251-
EditorFactory.getInstance().getEventMulticaster.addDocumentListener(updateListener, UnloadAwareDisposable.scalaPluginDisposable)
252-
}
253-
254166
// this hack uses reflection to downgrade plugin version
255167
def patchPluginVersion(newVersion: String, descriptor: IdeaPluginDescriptorImpl): Unit = {
256168
val versionField = classOf[IdeaPluginDescriptorImpl].getDeclaredField("version")

0 commit comments

Comments
 (0)