How can I get cm to parse its contents as the inner part of a class?

Hello,

I want to implement an editor where only the contents of a Java class (the members) are typed into cm (for educational purposes):

class A { <— some Label

|… … … …|
|… … … …| <— CodeMirror
|… … … …|

} <— some Label

How can I get the cm-component to parse its contents as the inner part of class A?

Thank you very much!

I’ve defined a new top rule for this in the Java grammar and released 1.1.0. You should now be able to do javaLanguage.configure({top: "ClassContent"}) to get a language that parses class content.

Ingenious! Thank you very much. Is your solution usable in general? Is is possible to write javaLanguage.configure({top: “MethodContent”}) for instance?

No. Only rules explicitly declared as @top can be used as a start rule.