-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 10fa96b
Showing
11 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Kotlin template | ||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
.idea/misc.xml | ||
.idea/inspectionProfiles/ | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# CMake | ||
cmake-build-debug/ | ||
cmake-build-release/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="PLUGIN_MODULE" version="4"> | ||
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" /> | ||
<component name="NewModuleRootManager"> | ||
<output url="file://$MODULE_DIR$/out/production/KotlinIcon" /> | ||
<output-test url="file://$MODULE_DIR$/out/test/KotlinIcon" /> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<idea-plugin> | ||
<id>nl.rubensten.kotlinicon</id> | ||
<name>Kotlin Icon</name> | ||
<version>1.1</version> | ||
<idea-version since-build="141.0"/> | ||
<vendor url="http://ruben-sten.github.io">Ruben-Sten</vendor> | ||
|
||
<description><![CDATA[ | ||
Adds a nice icon to global kotlin files. Because now it's ugly. | ||
]]></description> | ||
|
||
<change-notes><![CDATA[ | ||
Please check out our other plugin, TeXiFy-IDEA! | ||
]]> | ||
</change-notes> | ||
|
||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<projectViewNodeDecorator implementation="nl.rubensten.kotlinicon.KotlinIconDecorator"/> | ||
<fileIconProvider implementation="nl.rubensten.kotlinicon.KotlinIconDecorator"/> | ||
<iconProvider implementation="nl.rubensten.kotlinicon.KotlinIconDecorator"/> | ||
</extensions> | ||
|
||
<actions> | ||
</actions> | ||
</idea-plugin> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package nl.rubensten.kotlinicon | ||
|
||
import com.intellij.psi.PsiFile | ||
|
||
val PsiFile.hasTopLevelCallables: Boolean | ||
get() { | ||
val hasTopLevelCallablesField = javaClass.getDeclaredField("hasTopLevelCallables") | ||
hasTopLevelCallablesField.isAccessible = true | ||
return hasTopLevelCallablesField.get(this) == true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package nl.rubensten.kotlinicon | ||
|
||
import com.intellij.ide.FileIconProvider | ||
import com.intellij.ide.IconProvider | ||
import com.intellij.ide.projectView.PresentationData | ||
import com.intellij.ide.projectView.ProjectViewNode | ||
import com.intellij.ide.projectView.ProjectViewNodeDecorator | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.util.IconLoader | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.intellij.packageDependencies.ui.PackageDependenciesNode | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiFile | ||
import com.intellij.ui.ColoredTreeCellRenderer | ||
import javax.swing.Icon | ||
|
||
/** | ||
* @author Ruben Schellekens | ||
*/ | ||
class KotlinIconDecorator : IconProvider(), ProjectViewNodeDecorator, FileIconProvider { | ||
|
||
companion object { | ||
val KOTLIN_ICON = IconLoader.getIcon("/icon.png") | ||
} | ||
|
||
override fun getIcon(element: PsiElement, flags: Int): Icon? { | ||
if (element is PsiFile && element.name.endsWith(".kt") && element.hasTopLevelCallables) { | ||
return KOTLIN_ICON | ||
} | ||
|
||
return null | ||
} | ||
|
||
override fun decorate(node: ProjectViewNode<*>?, presentation: PresentationData?) { | ||
val file = node?.virtualFile ?: return | ||
if (file.isDirectory) { | ||
return | ||
} | ||
|
||
val extension: String = file.extension ?: return | ||
when (extension) { | ||
"kt" -> { | ||
presentation?.setIcon(KOTLIN_ICON) | ||
presentation?.presentableText = file.nameWithoutExtension | ||
} | ||
} | ||
} | ||
|
||
override fun decorate(node: PackageDependenciesNode?, cellRenderer: ColoredTreeCellRenderer?) { | ||
// Do nothing. | ||
} | ||
|
||
override fun getIcon(file: VirtualFile, flags: Int, project: Project?): Icon? { | ||
if (file.extension == "kt") { | ||
return KOTLIN_ICON | ||
} | ||
|
||
return null | ||
} | ||
} |