-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 16 additions & 6 deletions
22
src/main/java/org/nixos/idea/psi/impl/AbstractNixString.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
package org.nixos.idea.psi.impl | ||
|
||
import com.intellij.lang.ASTNode | ||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.psi.PsiLanguageInjectionHost | ||
import com.intellij.psi.impl.source.tree.LeafElement | ||
import com.intellij.util.IncorrectOperationException | ||
import org.nixos.idea.psi.NixIndString | ||
import org.nixos.idea.psi.NixString | ||
import org.nixos.idea.psi.NixStringLiteralEscaper | ||
|
||
|
||
abstract class AbstractNixString(node: ASTNode) : PsiLanguageInjectionHost, AbstractNixPsiElement(node), NixString { | ||
abstract class AbstractNixString(private val astNode: ASTNode) : PsiLanguageInjectionHost, AbstractNixPsiElement(astNode),NixString { | ||
|
||
override fun isValidHost() = true | ||
|
||
override fun updateText(text: String): NixString { | ||
// TODO implement. This is called when you edit the injected file in | ||
// order for the final Nix string to get updated | ||
// It is not necessary for syntax highlighting in injections | ||
// but is a nice to have | ||
override fun updateText(s: String): NixString { | ||
// TODO also support single-line strings | ||
if (this !is NixIndString) { | ||
LOG.info("not a nix ind string") | ||
return this | ||
} | ||
(astNode.firstChildNode as LeafElement).replaceWithText(s) | ||
return this | ||
} | ||
|
||
override fun createLiteralTextEscaper() = NixStringLiteralEscaper(this) | ||
|
||
companion object { | ||
val LOG = Logger.getInstance(AbstractNixString::class.java) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters