Skip to content

Commit

Permalink
Shorten target names in bsp library origin names (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk authored May 21, 2020
1 parent a35f379 commit 2cfbc5b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/META-INF/pants-scala.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<extensions defaultExtensionNs="com.intellij">
<externalProjectDataService implementation="com.twitter.intellij.pants.service.scala.PantsScalaDataService" order="last"/>
<highlightVisitor implementation="com.twitter.intellij.pants.highlight.PantsScalaHighlightVisitor"/>
<bspResolverNamingExtension implementation="com.twitter.intellij.pants.service.scala.PantsBspResolverNamingExtension"/>
</extensions>
<extensions defaultExtensionNs="com.intellij.plugins.pants">
<projectResolver implementation="com.twitter.intellij.pants.service.scala.ScalaSdkResolver"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).

package com.twitter.intellij.pants.service.scala

import org.jetbrains.bsp.project.resolver.BspResolverNamingExtension
import org.jetbrains.bsp.project.resolver.BspResolverDescriptors.ModuleDescription

class PantsBspResolverNamingExtension extends BspResolverNamingExtension {

def libraryData(moduleDescription: ModuleDescription): Option[String] = shortName("dependencies", moduleDescription)

def libraryTestData(moduleDescription: ModuleDescription): Option[String] = shortName("test dependencies", moduleDescription)

private def shortName(suffix: String, moduleDescription: ModuleDescription): Option[String] = {
val name = moduleDescription.data.name
val shortName = name.split(":").last
Some(s"$shortName $suffix")
}

}

0 comments on commit 2cfbc5b

Please sign in to comment.