-
Notifications
You must be signed in to change notification settings - Fork 13
[feat] GO support #43
base: main
Are you sure you want to change the base?
Conversation
maclick
commented
Jan 24, 2024
- [feature] create go build target |#BAZEL-784 Done
- calculateAllGoSdkInfos done
- added setSdk
- go sdk mock works
- changed home path to /usr/local/go
- added isGoSupportEnabled = true for each module
- extension point for Go SDK - not yet full working
# Conflicts: # buildSrc/src/main/kotlin/versions.kt # protocol/src/main/kotlin/org/jetbrains/bsp/utils/Extractors.kt # src/main/kotlin/org/jetbrains/plugins/bsp/config/BspFeatureFlags.kt # src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt # src/main/resources/META-INF/plugin.xml # src/main/resources/messages/BspPluginBundle.properties
# Conflicts: # buildSrc/src/main/kotlin/versions.kt # protocol/src/main/kotlin/org/jetbrains/bsp/protocol/utils/Extractors.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/TargetIdToModuleEntitiesMap.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/GoWorkspaceModelEntities.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/WorkspaceModelUpdaterImpl.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/updaters/GoModuleUpdater.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/updaters/transformers/ModuleDetailsToGoModuleTransformer.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/updaters/transformers/ProjectDetailsToModuleDetailsTransformer.kt # src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt # src/main/resources/messages/BspPluginBundle.properties
* added isGoSupportEnabled = true for each module * fixed imports and added toGoModule --------- Co-authored-by: Maciej Bielik <[email protected]>
# Conflicts: # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/DefaultMagicMetaModelState.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/JavaWorkspaceModelEntities.kt
# Conflicts: # src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt
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.
small thing
public fun goSdkExtensionExists(): Boolean = ep.extensionList.isNotEmpty() | ||
|
||
public class GoSdkGetter: GoSdkGetterExtension { | ||
private var goSdks: Set<GoSdk> = emptySet() |
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.
extension points shouldnt have state, so i'd be better to keep it in a service with state
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.
bump (you can check DefaultConnectionDetailsProviderExtension
for an inspiration)
# Conflicts: # buildSrc/src/main/kotlin/versions.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/MagicMetaModelImpl.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/TargetIdToModuleEntitiesMap.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/WorkspaceModelToModulesMapTransformer.kt # src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/WorkspaceModelUpdaterImpl.kt # src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt # src/main/kotlin/org/jetbrains/plugins/bsp/ui/gutters/BspJVMRunLineMarkerContributor.kt # src/main/resources/META-INF/plugin.xml
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.
looks nice in general some comments / questions
|
||
public data class LibraryItem( | ||
val id: BuildTargetIdentifier, | ||
val dependencies: List<BuildTargetIdentifier>, | ||
val ijars: List<String>, | ||
val jars: List<String>, | ||
val sourceJars: List<String>, | ||
) | ||
val goImportPath: String? = "", |
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.
if it's nullable, why default is not null?
|
||
public data class LibraryItem( | ||
val id: BuildTargetIdentifier, | ||
val dependencies: List<BuildTargetIdentifier>, | ||
val ijars: List<String>, | ||
val jars: List<String>, | ||
val sourceJars: List<String>, | ||
) | ||
val goImportPath: String? = "", | ||
val goRoot: URI? = URI(""), |
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.
same here
public fun goSdkExtensionExists(): Boolean = ep.extensionList.isNotEmpty() | ||
|
||
public class GoSdkGetter: GoSdkGetterExtension { | ||
private var goSdks: Set<GoSdk> = emptySet() |
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.
bump (you can check DefaultConnectionDetailsProviderExtension
for an inspiration)
val goImportPath: String? = "", | ||
val goRoot: URI? = URI(""), |
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.
same here - it can be null
(!isInsideJar() && getStrictParentOfType<PsiNameIdentifierOwner>() | ||
?.isClassOrMethod() ?: false) || isGoTopLevelFunction() | ||
|
||
private fun PsiElement.isGoTopLevelFunction() = |
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.
i believe that u need to create a separate class for go (to register it correctly in plugin.xml) but prob it'd be worth to create a base class and just 2 impls: jvm and go
if (!goEntitiesExtensionExists()) { | ||
error("Go entities extension does not exist.") | ||
} | ||
val goEntitiesExtension = goEntitiesExtension()!! |
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.
it can be done: goEntitiesExtension ?: error("Go entities extension does not exist.")
@@ -95,6 +96,7 @@ public object WorkspaceModelToModulesMapTransformer { | |||
languageIds = entity.customImlData?.customModuleOptions.orEmpty(), | |||
associates = entity.getKotlinSettings()?.getAssociates().orEmpty(), | |||
) | |||
// TODO: add support for GoModule |
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.
bump
.asSequence() | ||
.mapNotNull { targetsMap[it] } | ||
.map { it.id.toBsp4JTargetIdentifier() } | ||
.mapNotNull { buildTargetIdentifier -> projectDetails.targets.find { it.id == buildTargetIdentifier } } |
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.
it'll be slow for big projects, maybe it's better to create an index before
Merge master
Add tests for Go resources