Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed InteliJ analysis behaviour when analyzing file #13

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ abstract class AnalyzeAction : AbstractAction() {
}

private fun analyze(context: DataContext, project: Project) {
// try to get the file/folder from context, otherwise check if they can be retrieved from the opened editor
val file: VirtualFile? = PlatformDataKeys.VIRTUAL_FILE.getData(context).let {
it ?: project.let { it1 ->
FileEditorManager.getInstance(it1).selectedEditor?.file
// If analyzeFileOpenedInEditor is true, use the file opened in the editor. Else it will try to
// get the file/folder from context, otherwise check if they can be retrieved from the opened editor.
val file: VirtualFile? = analyzeFileOpenedInEditor().let {
if (it) {
FileEditorManager.getInstance(project).selectedEditor?.file
} else {
PlatformDataKeys.VIRTUAL_FILE.getData(context).let {virtualFile ->
virtualFile ?: FileEditorManager.getInstance(project).selectedEditor?.file
}
}
}

if (isFileRequired() && file == null) {
showErrorMessageDialog(
ErrorMessages.NO_ACTIVE_FILE
Expand Down Expand Up @@ -88,4 +94,6 @@ abstract class AnalyzeAction : AbstractAction() {
protected abstract fun getTicsCommand(file: VirtualFile?, project: Project?): GeneralCommandLine

protected abstract fun isFileRequired(): Boolean

protected abstract fun analyzeFileOpenedInEditor(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ open class AnalyzeFile : AnalyzeAction() {
override fun isFileRequired(): Boolean {
return true
}

override fun analyzeFileOpenedInEditor(): Boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ class AnalyzeFileOrFolder : AnalyzeFile() {

super.update(e)
}

override fun analyzeFileOpenedInEditor(): Boolean {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ class AnalyzeProject : AnalyzeAction() {
override fun isFileRequired(): Boolean {
return false
}

override fun analyzeFileOpenedInEditor(): Boolean {
return false
}
}
11 changes: 7 additions & 4 deletions src/main/kotlin/com/tiobe/plugins/intellij/icons/TicsIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import javax.swing.Icon
object TicsIcons {

@JvmField
val ANALYZE_FILE: Icon = load("/icons/TI_analyze_file.png")
val ANALYZE_FILE: Icon = load("/icons/tics-file-solid.svg")

@JvmField
val ANALYZE_FOLDER: Icon = load("/icons/TI_analyze_project.png")
val ANALYZE_FOLDER: Icon = load("/icons/tics-folder-solid.svg")

@JvmField
val CANCEL_TICS: Icon = load("/icons/TI_cancel_analysis.png")
val CANCEL_TICS: Icon = load("/icons/tics-cancel-solid.svg")

@JvmField
val CONFIGURE_TICS: Icon = load("/icons/TI_configuration.png")
val CONFIGURE_TICS: Icon = load("/icons/tics-config-solid.svg")

@JvmField
val INSTALL_TICS: Icon = load("/icons/tics-download-solid.svg")

@JvmField
val TICS_LOGO: Icon = load("/icons/TI_logo.svg")
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<group text="TICS" popup="true">
<reference id="TICS"/>
<action id="TICS.InstallTics" class="com.tiobe.plugins.intellij.actions.InstallTicsAction"
icon="AllIcons.Actions.Install" text="Install TICS"/>
icon="com.tiobe.plugins.intellij.icons.TicsIcons.INSTALL_TICS" text="Install TICS"/>
<add-to-group group-id="ToolsMenu"/>
</group>

Expand Down
Binary file removed src/main/resources/icons/TI_analyze_file.png
Binary file not shown.
Binary file removed src/main/resources/icons/TI_analyze_project.png
Binary file not shown.
Binary file removed src/main/resources/icons/TI_cancel_analysis.png
Binary file not shown.
Binary file removed src/main/resources/icons/TI_configuration.png
Binary file not shown.
Binary file removed src/main/resources/icons/filter-outline.png
Binary file not shown.
Binary file removed src/main/resources/icons/filter.png
Binary file not shown.
Loading