Skip to content

Commit

Permalink
remove "project" keyword from class
Browse files Browse the repository at this point in the history
Since that was leftover from ProjectComponent
  • Loading branch information
davissuber committed Oct 12, 2023
1 parent 962cb7b commit 75ea90d
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity

class AttachMotifProjectServiceActivity : ProjectActivity {
class AttachMotifServiceActivity : ProjectActivity {
override suspend fun execute(project: Project) {
project.service<MotifProjectService>().attach()
project.service<MotifService>().attach()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ import com.intellij.ui.content.Content
import com.intellij.ui.content.ContentFactory
import javax.swing.Icon
import motif.core.ResolvedGraph
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions
import motif.intellij.ui.MotifErrorPanel
import motif.intellij.ui.MotifScopePanel
import motif.intellij.ui.MotifUsagePanel
import org.jetbrains.kotlin.idea.KotlinLanguage

@Service(Service.Level.PROJECT)
class MotifProjectService(val project: Project) : Disposable {
class MotifService(val project: Project) : Disposable {

companion object {
const val TOOL_WINDOW_ID: String = "Motif"
Expand Down Expand Up @@ -86,7 +86,7 @@ class MotifProjectService(val project: Project) : Disposable {
onGraphUpdated(emptyGraph)

project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.PROJECT_OPENED)
}
}
Expand All @@ -113,13 +113,13 @@ class MotifProjectService(val project: Project) : Disposable {
if (updatedGraph.errors.isNotEmpty())
MotifAnalyticsActions.GRAPH_UPDATE_ERROR
else MotifAnalyticsActions.GRAPH_UPDATE_SUCCESS
project.getService(AnalyticsProjectService::class.java).logEvent(eventName)
project.getService(AnalyticsService::class.java).logEvent(eventName)
} catch (t: Throwable) {
val emptyGraph: ResolvedGraph = ResolvedGraph.create(emptyList())
onGraphUpdated(emptyGraph)

project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.GRAPH_COMPUTATION_ERROR)
PluginManager.getLogger().error(LABEL_GRAPH_COMPUTATION_ERROR, t)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifProjectService.Companion.TOOL_WINDOW_ID
import motif.intellij.MotifService
import motif.intellij.MotifService.Companion.TOOL_WINDOW_ID
import motif.intellij.ScopeHierarchyUtils.Companion.getParentScopes
import motif.intellij.ScopeHierarchyUtils.Companion.isInitializedGraph
import motif.intellij.ScopeHierarchyUtils.Companion.isMotifScopeClass
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions

/*
* {@AnAction} used to trigger displaying a particular scope ancestors hierarchy.
*/
class MotifAncestorGraphAction : AnAction(), MotifProjectService.Listener {
class MotifAncestorGraphAction : AnAction(), MotifService.Listener {

private var graph: ResolvedGraph? = null

Expand All @@ -48,18 +48,18 @@ class MotifAncestorGraphAction : AnAction(), MotifProjectService.Listener {
val graph = graph ?: return

if (!isInitializedGraph(graph)) {
project.getService(MotifProjectService::class.java).refreshGraph { actionPerformed(event) }
project.getService(MotifService::class.java).refreshGraph { actionPerformed(event) }
return
}

val toolWindow: ToolWindow =
ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID) ?: return
toolWindow.activate {
project.getService(MotifProjectService::class.java).onSelectedAncestorScope(element)
project.getService(MotifService::class.java).onSelectedAncestorScope(element)
}

project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.ANCESTOR_MENU_CLICK)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowManager
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifProjectService.Companion.TOOL_WINDOW_ID
import motif.intellij.MotifService
import motif.intellij.MotifService.Companion.TOOL_WINDOW_ID
import motif.intellij.ScopeHierarchyUtils.Companion.isInitializedGraph
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions

/*
* {@AnAction} used to trigger displaying entire scope hierarchy.
*/
class MotifGraphAction : AnAction(), MotifProjectService.Listener {
class MotifGraphAction : AnAction(), MotifService.Listener {

private var graph: ResolvedGraph? = null

Expand All @@ -42,7 +42,7 @@ class MotifGraphAction : AnAction(), MotifProjectService.Listener {
val graph = graph ?: return

if (!isInitializedGraph(graph)) {
project.getService(MotifProjectService::class.java).refreshGraph { actionPerformed(event) }
project.getService(MotifService::class.java).refreshGraph { actionPerformed(event) }
return
}

Expand All @@ -51,7 +51,7 @@ class MotifGraphAction : AnAction(), MotifProjectService.Listener {
toolWindow.activate {}

project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.GRAPH_MENU_CLICK)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifProjectService.Companion.TOOL_WINDOW_ID
import motif.intellij.MotifService
import motif.intellij.MotifService.Companion.TOOL_WINDOW_ID
import motif.intellij.ScopeHierarchyUtils
import motif.intellij.ScopeHierarchyUtils.Companion.getUsageCount
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions

/*
* {@AnAction} used to trigger navigation to a particular scope in the scope hierarchy window.
*/
class MotifUsageAction : AnAction(), MotifProjectService.Listener {
class MotifUsageAction : AnAction(), MotifService.Listener {

private var graph: ResolvedGraph? = null

Expand All @@ -47,18 +47,16 @@ class MotifUsageAction : AnAction(), MotifProjectService.Listener {
val graph = graph ?: return

if (!ScopeHierarchyUtils.isInitializedGraph(graph)) {
project.getService(MotifProjectService::class.java).refreshGraph { actionPerformed(event) }
project.getService(MotifService::class.java).refreshGraph { actionPerformed(event) }
return
}

val toolWindow: ToolWindow =
ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID) ?: return
toolWindow.activate {
project.getService(MotifProjectService::class.java).onSelectedClass(element)
}
toolWindow.activate { project.getService(MotifService::class.java).onSelectedClass(element) }

project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.USAGE_MENU_CLICK)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.intellij.openapi.project.Project
import java.util.UUID

@Service(Service.Level.PROJECT)
class AnalyticsProjectService(val project: Project) : Disposable {
class AnalyticsService(val project: Project) : Disposable {

companion object {
private val LOGGER_EXTENSION_POINT_NAME: ExtensionPointName<MotifAnalyticsLogger> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import javax.swing.JTree
import javax.swing.tree.DefaultMutableTreeNode
import motif.core.ResolvedGraph
import motif.errormessage.ErrorMessage
import motif.intellij.MotifProjectService
import motif.intellij.MotifService
import motif.intellij.ScopeHierarchyUtils.Companion.isRootElement
import motif.intellij.hierarchy.ScopeHierarchyBrowser.Companion.LABEL_GO_NEXT_SCOPE
import motif.intellij.hierarchy.ScopeHierarchyBrowser.Companion.LABEL_GO_PREVIOUS_SCOPE
Expand All @@ -49,7 +49,7 @@ class ErrorHierarchyBrowser(
initialGraph: ResolvedGraph,
private val rootElement: PsiElement,
private val selectionListener: Listener?
) : HierarchyBrowserBase(project, rootElement), MotifProjectService.Listener {
) : HierarchyBrowserBase(project, rootElement), MotifService.Listener {

private var graph: ResolvedGraph = initialGraph

Expand Down Expand Up @@ -130,7 +130,7 @@ class ErrorHierarchyBrowser(
}

override fun doRefresh(currentBuilderOnly: Boolean) {
project.getService(MotifProjectService::class.java).refreshGraph()
project.getService(MotifService::class.java).refreshGraph()
}

override fun onGraphUpdated(graph: ResolvedGraph) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ import motif.ast.IrType
import motif.ast.intellij.IntelliJClass
import motif.ast.intellij.IntelliJType
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifService
import motif.intellij.ScopeHierarchyUtils
import motif.intellij.ScopeHierarchyUtils.Companion.isMotifScopeClass
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions
import motif.intellij.hierarchy.descriptor.ScopeHierarchyRootDescriptor
import motif.intellij.hierarchy.descriptor.ScopeHierarchyScopeAncestorDescriptor
Expand All @@ -60,7 +60,7 @@ class ScopeHierarchyBrowser(
initialGraph: ResolvedGraph,
private val rootElement: PsiElement,
private val selectionListener: Listener?
) : HierarchyBrowserBase(project, rootElement), MotifProjectService.Listener {
) : HierarchyBrowserBase(project, rootElement), MotifService.Listener {

companion object {
const val LABEL_GO_PREVIOUS_SCOPE: String = "Go to previous Scope."
Expand Down Expand Up @@ -189,12 +189,12 @@ class ScopeHierarchyBrowser(
else -> {}
}

project.getService(MotifProjectService::class.java).refreshGraph()
project.getService(MotifService::class.java).refreshGraph()

val action: String =
if (status == Status.INITIALIZING) MotifAnalyticsActions.GRAPH_INIT
else MotifAnalyticsActions.GRAPH_UPDATE
project.getService(AnalyticsProjectService::class.java).logEvent(action)
project.getService(AnalyticsService::class.java).logEvent(action)
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import motif.ast.IrType
import motif.ast.intellij.IntelliJClass
import motif.ast.intellij.IntelliJType
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifService
import motif.intellij.ScopeHierarchyUtils.Companion.isMotifScopeClass
import motif.intellij.hierarchy.ScopeHierarchyBrowser.Companion.LABEL_GO_NEXT_SCOPE
import motif.intellij.hierarchy.ScopeHierarchyBrowser.Companion.LABEL_GO_PREVIOUS_SCOPE
Expand All @@ -61,7 +61,7 @@ class ScopePropertyHierarchyBrowser(
initialGraph: ResolvedGraph,
private val rootElement: PsiElement,
private val hierarchyType: PropertyHierarchyType
) : HierarchyBrowserBase(project, rootElement), MotifProjectService.Listener {
) : HierarchyBrowserBase(project, rootElement), MotifService.Listener {

private var graph: ResolvedGraph = initialGraph

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.text.MessageFormat
import javax.swing.JPanel
import javax.swing.JTree
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifService
import motif.intellij.hierarchy.ScopeHierarchyBrowser.Companion.LABEL_GO_NEXT_SCOPE
import motif.intellij.hierarchy.ScopeHierarchyBrowser.Companion.LABEL_GO_PREVIOUS_SCOPE
import motif.intellij.hierarchy.descriptor.ScopeHierarchyUsageSectionDescriptor
Expand All @@ -42,7 +42,7 @@ class UsageHierarchyBrowser(
project: Project,
initialGraph: ResolvedGraph,
private val rootElement: PsiElement
) : HierarchyBrowserBase(project, rootElement), MotifProjectService.Listener {
) : HierarchyBrowserBase(project, rootElement), MotifService.Listener {

private var graph: ResolvedGraph = initialGraph

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ import com.intellij.psi.impl.source.PsiClassReferenceType
import com.intellij.util.ConstantFunction
import java.awt.event.MouseEvent
import motif.core.ResolvedGraph
import motif.intellij.MotifProjectService
import motif.intellij.MotifProjectService.Companion.TOOL_WINDOW_ID
import motif.intellij.MotifService
import motif.intellij.MotifService.Companion.TOOL_WINDOW_ID
import motif.intellij.ScopeHierarchyUtils.Companion.getParentScopes
import motif.intellij.ScopeHierarchyUtils.Companion.isMotifScopeClass
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions

/*
* {@LineMarkerProvider} used to display icon in gutter to navigate to motif scope ancestors hierarchy.
*/
class ScopeHierarchyLineMarkerProvider : LineMarkerProvider, MotifProjectService.Listener {
class ScopeHierarchyLineMarkerProvider : LineMarkerProvider, MotifService.Listener {

companion object {
const val LABEL_ANCESTORS_SCOPE: String = "View Scope Ancestors."
Expand Down Expand Up @@ -83,21 +83,19 @@ class ScopeHierarchyLineMarkerProvider : LineMarkerProvider, MotifProjectService
ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID) ?: return
if (element is PsiClass) {
toolWindow.activate {
project.getService(MotifProjectService::class.java).onSelectedAncestorScope(element)
project.getService(MotifService::class.java).onSelectedAncestorScope(element)
}
} else if (element is PsiMethod) {
if (element.returnType is PsiClassReferenceType) {
val returnElementClass: PsiClass =
(element.returnType as PsiClassReferenceType).resolve() ?: return
toolWindow.activate {
project
.getService(MotifProjectService::class.java)
.onSelectedAncestorScope(returnElementClass)
project.getService(MotifService::class.java).onSelectedAncestorScope(returnElementClass)
}
}
}
project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.ANCESTOR_GUTTER_CLICK)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ import java.awt.event.MouseEvent
import motif.ast.intellij.IntelliJClass
import motif.core.ResolvedGraph
import motif.core.ScopeEdge
import motif.intellij.MotifProjectService
import motif.intellij.MotifService
import motif.intellij.ScopeHierarchyUtils.Companion.getParentScopes
import motif.intellij.ScopeHierarchyUtils.Companion.isMotifChildScopeMethod
import motif.intellij.ScopeHierarchyUtils.Companion.isMotifScopeClass
import motif.intellij.analytics.AnalyticsProjectService
import motif.intellij.analytics.AnalyticsService
import motif.intellij.analytics.MotifAnalyticsActions
import motif.intellij.toPsiClass
import motif.intellij.toPsiMethod

/*
* {@LineMarkerProvider} used to display navigation icons in gutter to navigate to parent/children of Motif scopes.
*/
class ScopeNavigationLineMarkerProvider : LineMarkerProvider, MotifProjectService.Listener {
class ScopeNavigationLineMarkerProvider : LineMarkerProvider, MotifService.Listener {

companion object {
const val LABEL_NAVIGATE_PARENT_SCOPE: String = "Navigate to parent Scope."
Expand Down Expand Up @@ -158,7 +158,7 @@ class ScopeNavigationLineMarkerProvider : LineMarkerProvider, MotifProjectServic
}
}
project
.getService(AnalyticsProjectService::class.java)
.getService(AnalyticsService::class.java)
.logEvent(MotifAnalyticsActions.NAVIGATION_GUTTER_CLICK)
}

Expand Down
4 changes: 2 additions & 2 deletions intellij/src/main/kotlin/motif/intellij/ui/MotifErrorPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import javax.swing.JSplitPane
import javax.swing.JTextArea
import motif.core.ResolvedGraph
import motif.errormessage.ErrorMessage
import motif.intellij.MotifProjectService
import motif.intellij.MotifService
import motif.intellij.ScopeHierarchyUtils
import motif.intellij.hierarchy.ErrorHierarchyBrowser
import motif.models.MotifError

class MotifErrorPanel(project: Project, graph: ResolvedGraph) :
JPanel(), MotifProjectService.Listener, ErrorHierarchyBrowser.Listener {
JPanel(), MotifService.Listener, ErrorHierarchyBrowser.Listener {

private val splitPane: JSplitPane
private val errorBrowser: ErrorHierarchyBrowser
Expand Down
Loading

0 comments on commit 75ea90d

Please sign in to comment.