Language Injection#
Noctule supports language injections in string literals to help you edit embedded code. Please refer to the JetBrains Help to learn how this feature works.
Language injections are available in plain strings and multi-line strings. Noctule takes care of escaping special characters when you update the injected code with the fragment editor.
If you enable the bundled IntelliLang plugin,
then comments like // language=JSON are used to automatically infer the language to inject into the following string literal.
Swift String Literals#
Language injection is available in string literals.
// language=JSON
let json = "{\"key\": \"value\"}"The same with escaped line breaks:
// language=JSON
let json = "{\n \"key\": \"value\"\n}"Use extended string delimiters to avoid escaping double quotes and other special characters:
// language=JSON let json = #"{"key": "value"}"#
Swift Multi-line String Literals#
Multi-line string literals can contain line breaks and make embedded code more readable.
// language=JSON
let json = """
{
"key": "value"
}
"""If you invoke the fragment editor for the embedded code via Edit Fragment...,
then Noctule handles the indentation automatically.
The code inside the fragment editor does not show the indentation, as it’s not part of the string value.
Objective-C String Literals#
Language injection into string literals of Objective-C is supported.
void demo() {
// language=JSON
char* names = @"{\n \"names\": [\n \"Jane\",\n \"Joe\"\n ]\n}";
}