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

Create latex expression rendered within Eclipse JDT editor #29

Closed
crowlogic opened this issue May 20, 2022 · 1 comment
Closed

Create latex expression rendered within Eclipse JDT editor #29

crowlogic opened this issue May 20, 2022 · 1 comment

Comments

@crowlogic
Copy link
Owner Author

On Fri, May 20, 2022 at 8:21 AM Stephen Crowley <stephencrowley214@gmail.com> wrote:

Hi Mickael, thanks for the answer however that isn't quite what I had in mind. I want the mathematically typeset formulas to appear inline along with the java code

That's a very fun but not trivial topic!
As Alex mentioned, you can try using code-minings for that. Code Minings are attached to a some ranges of code in your editor, and can be used to draw extra things; they are more or less a combination for SWT's StyleRange & GlyphMetrics class which already allows to replace some text ranges by blank area, and of extra painting instructions to add your content in here. I think you can implement something similar for latex expressions, detect them,replace the text by a StyleRange/GlyphMetrics and draw a rendered image in place.
Snippet205 is probably the best source of inspiration.

This would most likely mean that the lines which do have  formulas to render with latex would probably have to be a bit taller to make them visible which might break the existing display code which I presume requires a fixed vertical spacing of lines?

The underlying StyledText widget doesn't mandate fixed vertical spacing of lines. it has a lot of flexibility: allow some vertical indent per line, and even characters/areas of different sizes on one line... See for example SWT's Snippet205 and Snippet211, and some others. Basically the low-level API is really capable of anything, the harder work is to interfere safely with lower level widget when coming from an editor.

An alternative would be to develop a convention, so that latex formulas would be represented as being within a Javadoc and within a special tag

called <math>

whichCouldSpanSeveralLines(x)=

like{\sup}.this()\int\someLatexStuff

</math>

Sorry, I don't know whether the Javadoc processor is extensible or customizable. That's something you should ask to the jdt-dev@eclipse.org mailing-list.

crowlogic pushed a commit that referenced this issue Mar 13, 2024
Exception Details:
  Location:
    nzToThePowerOfnTimesProdkαknk1pDividedBynBangTimesProdkβknk1q.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object;
@158: invokevirtual
  Reason:
    Type 'java/lang/Object' (current frame, stack[1]) is not assignable
to 'arb/Real'
  Current Frame:
    bci: @158
    flags: { }
    locals: {
'nzToThePowerOfnTimesProdkαknk1pDividedBynBangTimesProdkβknk1q',
'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/Real', 'java/lang/Object', 'arb/Integer', integer,
'arb/Real' }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122a b400 162b
    0000010: c000 181d 2ab4 001b b600 212a b400 252b
    0000020: c000 18b5 002a 2ab4 002d b600 3157 2ab4
    0000030: 0034 2ab4 0037 b600 3b57 2ab4 003e 2ab4
    0000040: 0041 b600 3b57 2ab4 002d 2ab4 0025 2ab4
    0000050: 0034 1d2a b400 44b9 0047 0400 c000 1d1d
    0000060: b600 4b57 2ab4 0034 b600 4f2a b400 3eb6
    0000070: 0053 9eff d42a b400 2d1d 2ab4 0056 b600
    0000080: 5919 042b c000 181d 2ab4 005c b600 602a
    0000090: b400 63c0 001d b600 661d 2ab4 0069 b600
    00000a0: 6c2a b400 702b c000 18b5 0072 2ab4 0075
    00000b0: b600 3157 2ab4 0034 2ab4 0037 b600 3b57
    00000c0: 2ab4 0078 2ab4 007b b600 3b57 2ab4 0075
    00000d0: 2ab4 0070 2ab4 0034 1d2a b400 7eb9 0047
    00000e0: 0400 c000 1d1d b600 4b57 2ab4 0034 b600
    00000f0: 4f2a b400 78b6 0053 9eff d42a b400 751d
    0000100: 1904 c000 1db6 0059 b0
  Stackmap Table:
    same_frame(@11)
    same_locals_1_stack_item_frame(@70,Object[#29])
    full_frame(@204,{Object[#2],Object[#5],Integer,Integer,Object[#5]},{Object[#29],Object[#29]})

	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
	at java.base/java.lang.Class.getConstructor0(Class.java:3754)
	at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
	at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1179)
	at arb4j/arb.expressions.Expression.instantiate(Expression.java:1167)
	at arb4j/arb.expressions.Expression.instantiate(Expression.java:156)
	at arb4j/arb.functions.Function.express(Function.java:161)
	at arb4j/arb.functions.polynomials.HypergeometricPolynomialTest.testSummand(HypergeometricPolynomialTest.java:29)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at junit@4.13.2/junit.framework.TestCase.runTest(TestCase.java:177)
	at junit@4.13.2/junit.framework.TestCase.runBare(TestCase.java:142)
	at junit@4.13.2/junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit@4.13.2/junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit@4.13.2/junit.framework.TestResult.run(TestResult.java:125)
	at junit@4.13.2/junit.framework.TestCase.run(TestCase.java:130)
	at junit@4.13.2/junit.framework.TestSuite.runTest(TestSuite.java:241)
	at junit@4.13.2/junit.framework.TestSuite.run(TestSuite.java:236)
	at junit@4.13.2/org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
crowlogic pushed a commit that referenced this issue Mar 18, 2024
Exception Details:
  Location:
    nzⁿTimesProdkαSubknWherekEquals1TopOvernBangTimesProdkβSubknWherekEquals1Toq.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object;
@70: aload_0
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @70
    flags: { }
    locals: {
'nzⁿTimesProdkαSubknWherekEquals1TopOvernBangTimesProdkβSubknWherekEquals1Toq',
'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/Real' }
  Stackmap Frame:
    bci: @70
    flags: { }
    locals: {
'nzⁿTimesProdkαSubknWherekEquals1TopOvernBangTimesProdkβSubknWherekEquals1Toq',
'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122a b400 162b
    0000010: c000 181d 2ab4 001b b600 212a b400 252b
    0000020: c000 18b5 002a 2ab4 002d b600 3157 2ab4
    0000030: 0034 2ab4 0037 b600 3b57 2ab4 003e 2ab4
    0000040: 0041 b600 3b57 2ab4 002d 2ab4 0025 2ab4
    0000050: 0034 1d2a b400 44b9 0047 0400 c000 1d1d
    0000060: b600 4b57 2ab4 0034 b600 4f2a b400 3eb6
    0000070: 0053 9eff d42a b400 2d1d 2ab4 0056 b600
    0000080: 592b c000 181d 2ab4 005c b600 602a b400
    0000090: 642b c000 18b5 0066 2ab4 0069 b600 3157
    00000a0: 2ab4 0034 2ab4 0037 b600 3b57 2ab4 006c
    00000b0: 2ab4 006f b600 3b57 2ab4 0069 2ab4 0064
    00000c0: 2ab4 0034 1d2a b400 72b9 0047 0400 c000
    00000d0: 1d1d b600 4b57 2ab4 0034 b600 4f2a b400
    00000e0: 6cb6 0053 9eff d42a b400 691d 2ab4 0075
    00000f0: b600 761d 1904 c000 1db6 0079 b0
  Stackmap Table:
    same_frame(@11)
    same_frame(@70)
    same_locals_1_stack_item_extended(@184,Object[#29])

	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
	at java.base/java.lang.Class.getConstructor0(Class.java:3754)
	at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
	at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1164)
	at arb4j/arb.expressions.Expression.instantiate(Expression.java:1152)
	at arb4j/arb.expressions.Expression.instantiate(Expression.java:164)
	at arb4j/arb.functions.Function.express(Function.java:162)
	at arb4j/arb.functions.polynomials.HypergeometricPolynomialTest.testSummand(HypergeometricPolynomialTest.java:85)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at junit@4.13.2/junit.framework.TestCase.runTest(TestCase.java:177)
	at junit@4.13.2/junit.framework.TestCase.runBare(TestCase.java:142)
	at junit@4.13.2/junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit@4.13.2/junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit@4.13.2/junit.framework.TestResult.run(TestResult.java:125)
	at junit@4.13.2/junit.framework.TestCase.run(TestCase.java:130)
	at junit@4.13.2/junit.framework.TestSuite.runTest(TestSuite.java:241)
	at junit@4.13.2/junit.framework.TestSuite.run(TestSuite.java:236)
	at junit@4.13.2/org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
crowlogic added a commit that referenced this issue Mar 19, 2024
java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    nzⁿTimesProdkαSubknWherekEquals1TopOvernBangTimesProdkβSubknWherekEquals1Toq.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object;
@184: aload_0
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @184
    flags: { }
    locals: {
'nzⁿTimesProdkαSubknWherekEquals1TopOvernBangTimesProdkβSubknWherekEquals1Toq',
'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/Real', 'arb/Integer' }
  Stackmap Frame:
    bci: @184
    flags: { }
    locals: {
'nzⁿTimesProdkαSubknWherekEquals1TopOvernBangTimesProdkβSubknWherekEquals1Toq',
'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/Real' }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122a b400 162b
    0000010: c000 181d 2ab4 001b b600 212a b400 252b
    0000020: c000 18b5 002a 2ab4 002d b600 3157 2ab4
    0000030: 0034 2ab4 0037 b600 3b57 2ab4 003e 2ab4
    0000040: 0041 b600 3b57 2ab4 002d 2ab4 0025 2ab4
    0000050: 0034 1d2a b400 44b9 0047 0400 c000 1d1d
    0000060: b600 4b57 2ab4 0034 b600 4f2a b400 3eb6
    0000070: 0053 9eff d42a b400 2d1d 2ab4 0056 b600
    0000080: 592b c000 181d 2ab4 005c b600 602a b400
    0000090: 642b c000 18b5 0066 2ab4 0069 b600 3157
    00000a0: 2ab4 0034 2ab4 0037 b600 3b57 2ab4 006c
    00000b0: 2ab4 006f b600 3b57 2ab4 0069 2ab4 0064
    00000c0: 2ab4 0034 1d2a b400 72b9 0047 0400 c000
    00000d0: 1d1d b600 4b57 2ab4 0034 b600 4f2a b400
    00000e0: 6cb6 0053 9eff d42a b400 691d 2ab4 0075
    00000f0: b600 761d 1904 c000 1db6 0079 b0
  Stackmap Table:
    same_frame(@11)
    same_locals_1_stack_item_frame(@70,Object[#29])
    same_locals_1_stack_item_extended(@184,Object[#29])

	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
	at java.base/java.lang.Class.getConstructor0(Class.java:3754)
	at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
	at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1164)
	at arb4j/arb.expressions.Expression.instantiate(Expression.java:1152)
	at arb4j/arb.expressions.Expression.instantiate(Expression.java:164)
	at arb4j/arb.functions.Function.express(Function.java:162)
	at arb4j/arb.functions.polynomials.HypergeometricPolynomialTest.testSummand(HypergeometricPolynomialTest.java:85)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at junit@4.13.2/junit.framework.TestCase.runTest(TestCase.java:177)
	at junit@4.13.2/junit.framework.TestCase.runBare(TestCase.java:142)
	at junit@4.13.2/junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit@4.13.2/junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit@4.13.2/junit.framework.TestResult.run(TestResult.java:125)
	at junit@4.13.2/junit.framework.TestCase.run(TestCase.java:130)
	at junit@4.13.2/junit.framework.TestSuite.runTest(TestSuite.java:241)
	at junit@4.13.2/junit.framework.TestSuite.run(TestSuite.java:236)
	at junit@4.13.2/org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant