Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProB 2 Jupyter Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB 2 Jupyter Kernel
Commits
d9cd8522
Commit
d9cd8522
authored
5 years ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Refactor CommandUtils.inspectInBExpression slightly
parent
e28b8054
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/prob2/jupyter/CommandUtils.java
+16
-12
16 additions, 12 deletions
src/main/java/de/prob2/jupyter/CommandUtils.java
with
16 additions
and
12 deletions
src/main/java/de/prob2/jupyter/CommandUtils.java
+
16
−
12
View file @
d9cd8522
...
...
@@ -358,14 +358,7 @@ public final class CommandUtils {
return
null
;
}
public
static
@Nullable
DisplayData
inspectInBExpression
(
final
@NotNull
Trace
trace
,
final
@NotNull
String
code
,
final
int
at
)
{
final
Matcher
identifierMatcher
=
CommandUtils
.
matchBIdentifierAt
(
code
,
at
);
if
(
identifierMatcher
==
null
)
{
return
null
;
}
final
String
identifier
=
identifierMatcher
.
group
();
final
IEvalElement
formula
=
trace
.
getModel
().
parseFormula
(
identifier
,
FormulaExpand
.
TRUNCATE
);
private
static
@NotNull
DisplayData
formatBExpressionInspectText
(
final
String
identifier
,
final
TypeCheckResult
type
,
final
AbstractEvalResult
currentValue
)
{
final
StringBuilder
sbPlain
=
new
StringBuilder
();
final
StringBuilder
sbMarkdown
=
new
StringBuilder
();
sbPlain
.
append
(
UnicodeTranslator
.
toUnicode
(
identifier
));
...
...
@@ -374,7 +367,6 @@ public final class CommandUtils {
sbMarkdown
.
append
(
UnicodeTranslator
.
toLatex
(
identifier
));
sbMarkdown
.
append
(
"$ \n"
);
final
TypeCheckResult
type
=
trace
.
getStateSpace
().
typeCheck
(
formula
);
sbPlain
.
append
(
"Type: "
);
sbMarkdown
.
append
(
"**Type:** "
);
if
(
type
.
isOk
())
{
...
...
@@ -391,17 +383,29 @@ public final class CommandUtils {
sbPlain
.
append
(
'\n'
);
sbMarkdown
.
append
(
" \n"
);
final
AbstractEvalResult
aer
=
trace
.
evalCurrent
(
formula
);
sbPlain
.
append
(
"Current value: "
);
sbPlain
.
append
(
CommandUtils
.
inlinePlainTextForEvalResult
(
aer
));
sbPlain
.
append
(
CommandUtils
.
inlinePlainTextForEvalResult
(
currentValue
));
sbMarkdown
.
append
(
"**Current value:** "
);
sbMarkdown
.
append
(
inlineMarkdownForEvalResult
(
aer
));
sbMarkdown
.
append
(
inlineMarkdownForEvalResult
(
currentValue
));
final
DisplayData
result
=
new
DisplayData
(
sbPlain
.
toString
());
result
.
putMarkdown
(
sbMarkdown
.
toString
());
return
result
;
}
public
static
@Nullable
DisplayData
inspectInBExpression
(
final
@NotNull
Trace
trace
,
final
@NotNull
String
code
,
final
int
at
)
{
final
Matcher
identifierMatcher
=
CommandUtils
.
matchBIdentifierAt
(
code
,
at
);
if
(
identifierMatcher
==
null
)
{
return
null
;
}
final
String
identifier
=
identifierMatcher
.
group
();
final
IEvalElement
formula
=
trace
.
getModel
().
parseFormula
(
identifier
,
FormulaExpand
.
TRUNCATE
);
final
TypeCheckResult
type
=
trace
.
getStateSpace
().
typeCheck
(
formula
);
final
AbstractEvalResult
currentValue
=
trace
.
evalCurrent
(
formula
);
return
formatBExpressionInspectText
(
identifier
,
type
,
currentValue
);
}
public
static
@NotNull
Inspector
bExpressionInspector
(
final
@NotNull
Trace
trace
)
{
return
(
code
,
at
)
->
inspectInBExpression
(
trace
,
code
,
at
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment