Skip to content

Commit

Permalink
FBP-73. Improve injector
Browse files Browse the repository at this point in the history
  • Loading branch information
valb3r committed Jul 22, 2023
1 parent 75e57b7 commit 25b299f
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 143 deletions.
4 changes: 2 additions & 2 deletions activiti-intellij-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ sourceSets {
}

intellij {
version = intellijPlatform
version = "IC-2021.3"
pluginName = 'activiti-bpmn-plugin'
updateSinceUntilBuild = false
plugins = intellijPlatformPlugins
plugins = ["java"]
}

runPluginVerifier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ abstract class DefaultDelegateExpressionUiInjector: MultiHostInjector {
return mutableListOf(PsiLiteralExpression::class.java)
}

private val spelStart = "^\"[$#]\\{".toRegex()

private val spelEnd = "}\""

override fun getLanguagesToInject(registrar: MultiHostRegistrar, context: PsiElement) {
if (context !is PsiLanguageInjectionHost) {
return
Expand All @@ -39,10 +43,6 @@ abstract class DefaultDelegateExpressionUiInjector: MultiHostInjector {
return
}

if (!context.text.contains("[$#]\\{".toRegex()) || !context.text.contains("}")) {
return
}

injectSpel(context, registrar)
}

Expand All @@ -51,7 +51,11 @@ abstract class DefaultDelegateExpressionUiInjector: MultiHostInjector {
val language = Language.getRegisteredLanguages().firstOrNull { it.id == "SpEL" } ?:
Language.getRegisteredLanguages().firstOrNull { it.id == "JAVA" } ?: return
registrar.startInjecting(language)
registrar.addPlace("", "", context, TextRange(3, text.length - 2))
if (context.text.contains(spelStart) && context.text.endsWith(spelEnd)) {
registrar.addPlace("", "", context, TextRange(3, text.length - 2))
} else {
registrar.addPlace("", "", context, TextRange(1, text.length - 1))
}
registrar.doneInjecting()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<idea-plugin>
<actions>
<group id="BpmnCamundaAttachToDataSource"
text="Attach To Schema"
description="Attach to database schema to investigate process"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.AttachCamundaToDataSource"
class="com.valb3r.bpmn.intellij.plugin.camunda.actions.AttachCamundaBpmnDebuggerToDbAction"
text="Attach To Schema (Camunda)"
description="Attach to database schema (Camunda) for BPMN process debugging"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnCamundaDetachFromDataSource"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.BpmnDetachCamundaFromDataSource"
class="com.valb3r.bpmn.intellij.plugin.camunda.actions.DetachCamundaBpmnDebuggerFromDbAction"
text="Detach Debugger (Camunda)"
description="Detach BPMN debugger from DataSource (Camunda)"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
</actions>
</idea-plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<idea-plugin>
</idea-plugin>
68 changes: 0 additions & 68 deletions camunda-intellij-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,74 +202,6 @@
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnCamundaAttachToDataSource"
text="Attach To Schema"
description="Attach to database schema to investigate process"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.AttachCamundaToDataSource"
class="com.valb3r.bpmn.intellij.plugin.camunda.actions.AttachCamundaBpmnDebuggerToDbAction"
text="Attach To Schema (Camunda)"
description="Attach to database schema (Camunda) for BPMN process debugging"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnCamundaDetachFromDataSource"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.BpmnDetachCamundaFromDataSource"
class="com.valb3r.bpmn.intellij.plugin.camunda.actions.DetachCamundaBpmnDebuggerFromDbAction"
text="Detach Debugger (Camunda)"
description="Detach BPMN debugger from DataSource (Camunda)"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
</actions>

<!-- Extension points defined by the plugin. Extension points are registered by a plugin so that other plugins
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<idea-plugin>
<actions>
<group id="BpmnFlowableAttachToDataSource"
text="Attach To Schema"
description="Attach to database schema to investigate process"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.AttachFlowableToDataSource"
class="com.valb3r.bpmn.intellij.plugin.flowable.actions.AttachFlowableBpmnDebuggerToDbAction"
text="Attach To Schema (Flowable)"
description="Attach to database schema (Flowable) for BPMN process debugging"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnFlowableDetachFromDataSource"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.BpmnDetachFlowableFromDataSource"
class="com.valb3r.bpmn.intellij.plugin.flowable.actions.DetachFlowableBpmnDebuggerFromDbAction"
text="Detach Debugger (Flowable)"
description="Detach BPMN debugger from DataSource (Flowable)"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
</actions>
</idea-plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<idea-plugin>
</idea-plugin>
Loading

0 comments on commit 25b299f

Please sign in to comment.