@@ -21,6 +21,21 @@ final case class ModifiableDependency(
2121
2222object SbtDependencyAnalyzerActionUtil {
2323
24+ private def isScalaArtifact (coordinates : UnifiedCoordinates ): Boolean = {
25+ coordinates.getArtifactId.endsWith(" _3" ) || coordinates.getArtifactId.endsWith(" _2.13" ) ||
26+ coordinates.getArtifactId.endsWith(" _2.12" ) || coordinates.getArtifactId.endsWith(" _2.11" )
27+ }
28+
29+ private def getArtifactWithoutScalaVersion (coordinates : UnifiedCoordinates ) = {
30+ val artifactName = coordinates.getArtifactId
31+ .stripSuffix(" _3" )
32+ .stripSuffix(" _2.13" )
33+ .stripSuffix(" _2.12" )
34+ .stripSuffix(" _2.11" )
35+
36+ artifactName
37+ }
38+
2439 def getModifiableDependency (e : AnActionEvent ): ModifiableDependency =
2540 val project = e.getProject
2641 val dependency = e.getData(DependencyAnalyzerView .Companion .getDEPENDENCY)
@@ -34,22 +49,18 @@ object SbtDependencyAnalyzerActionUtil {
3449
3550 val candidateDeclaredDependencies = DependencyUtils
3651 .getDeclaredDependency(module)
37- val declared = candidateDeclaredDependencies.find(dc =>
52+ val declaredDependency = candidateDeclaredDependencies.find(dc =>
3853 // hard code, see SbtDependencyUtils#getLibraryDependenciesOrPlacesFromPsi
3954 val artifactName =
40- if (
41- coordinates.getArtifactId.endsWith(" _3" ) || coordinates.getArtifactId.endsWith(" _2.13" ) ||
42- coordinates.getArtifactId.endsWith(" _2.12" ) || coordinates.getArtifactId.endsWith(" _2.11" )
43- ) coordinates.getArtifactId.split('_' ).head
44- else coordinates.getArtifactId
55+ if (isScalaArtifact(coordinates)) getArtifactWithoutScalaVersion(coordinates) else coordinates.getArtifactId
4556 (dc.getCoordinates.getArtifactId == coordinates.getArtifactId ||
46- dc.getCoordinates.getArtifactId == artifactName ||
57+ getArtifactWithoutScalaVersion( dc.getCoordinates) == artifactName ||
4758 // maybe a fixed artifact
4859 dc.getCoordinates.getVersion == artifactName) &&
4960 dc.getCoordinates.getGroupId == coordinates.getGroupId
5061 )
5162
52- ModifiableDependency (module, coordinates, declared , candidateDeclaredDependencies, parentDependency)
63+ ModifiableDependency (module, coordinates, declaredDependency , candidateDeclaredDependencies, parentDependency)
5364 end getModifiableDependency
5465
5566}
0 commit comments