Skip to content

Commit

Permalink
[ #194 ] varinfo enhance, add support for 1D array
Browse files Browse the repository at this point in the history
  • Loading branch information
zxj5470 committed Dec 14, 2018
1 parent 2afcc7d commit 9aead10
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
12 changes: 10 additions & 2 deletions res/org/ice1000/julia/lang/action/IntelliJ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ else
please add PyCall and install matplotlib.pyplot package.""")
end

const _intellij_plot_key = "JULIA_INTELLIJ_PLOT_PORT"
const _intellij_full_angle_space_key = " "

_intellij_filter_names(v) = string(v) ["Base", "Core", "Main", "InteractiveUtils", "matplotlib"]

Expand All @@ -55,14 +55,22 @@ function _intellij_send_to(rows)
end
end

function _intellij_stringfy(value)
if isa(value,Array)
"$(join(value,_intellij_full_angle_space_key))"
else
repr(value)
end
end

function _intellij_varinfo(m=Main)
@eval using Base:summarysize, format_bytes
pattern="_intellij_"
rows = Array[ let value = getfield(m, v)
name = string(v)
size = value === Main || value === Base || value === Core ? "" : format_bytes(summarysize(value))
summary_info = summary(value)
info = repr(repr(value))
info = repr(_intellij_stringfy(value))
if size == "0 bytes" && summary_info == "typeof($(name))"
summary_info = "function"
end
Expand Down
2 changes: 1 addition & 1 deletion src/org/ice1000/julia/lang/julia-constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const val JULIA_IN_EXPR_STARTING_AT_LEN = JULIA_IN_EXPR_STARTING_AT.length
))$"""
@NonNls const val JULIA_DEFAULT_MODULE_NAME = "MyBizarreJuliaModule"
@NonNls const val JULIA_WEBSITE = "https://julialang.org/downloads/"

@NonNls const val FULL_ANGLE_SPACE = " "
@NonNls const val MAC_APPLICATIONS = "/Applications"

@NonNls val JULIA_TABLE_HEADER_COLUMN = arrayOf("Package", "Version", "Latest")
Expand Down
23 changes: 17 additions & 6 deletions src/org/ice1000/julia/lang/module/julia-sci-mode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ class JuliaConsoleView(project: Project, title: String) : LanguageConsoleImpl(pr
val valuePresentation = value.removeSurrounding("\"\"\"")
val container = when {
typeSummary.contains("EnvDict") -> true
typeSummary.contains("Array{") -> true
else -> false
}
JuliaDebugValue(name, typeSummary, valuePresentation, container)
Expand All @@ -493,7 +494,6 @@ class JuliaConsoleView(project: Project, title: String) : LanguageConsoleImpl(pr
consoleEditor.gutterComponentEx.background = consoleEditor.backgroundColor
consoleEditor.gutterComponentEx.revalidate()
consoleEditor.colorsScheme.setColor(EditorColors.GUTTER_BACKGROUND, consoleEditor.backgroundColor)
// settings.set
return centerComponent
}
}
Expand All @@ -515,14 +515,19 @@ class JuliaDebugValue(name: String,
var container: Boolean = false,
var parent: JuliaDebugValue? = null) : XNamedValue(name) {
override fun computePresentation(node: XValueNode, place: XValuePlace) {
var valuePresentation = value
val icon =
when (type) {
"function" -> JuliaIcons.JULIA_FUNCTION_ICON
when {
type == "function" -> JuliaIcons.JULIA_FUNCTION_ICON
type.contains("Array{") -> {
valuePresentation = "[${value.replace(FULL_ANGLE_SPACE, ", ")}]"
JuliaIcons.JULIA_VARIABLE_ICON
}
else -> JuliaIcons.JULIA_VARIABLE_ICON
}
// if type is not empty, presentation is `{$type}`, otherwise it won't show bracket pairs.
val typePresentation = if (type.isEmpty()) null else type
node.setPresentation(icon, typePresentation, value, container)
node.setPresentation(icon, typePresentation, valuePresentation, container)
}

override fun computeChildren(node: XCompositeNode) {
Expand All @@ -535,8 +540,14 @@ class JuliaDebugValue(name: String,
value = it.substringAfter("="),
parent = this))
}
type.contains("Array") -> {
// TODO
type.contains("Array{") -> {
value.split(FULL_ANGLE_SPACE).forEachIndexed { index, it ->
childrenList.add(
JuliaDebugValue(
name = "[${index + 1}]",
value = it,
parent = this))
}
}
type.contains("Dict{") -> {
// TODO
Expand Down

0 comments on commit 9aead10

Please sign in to comment.