I'm using code-completion to suggest a set of commands for my DSL. However, the language requires a command to be prefixed with the AT @ symbol. This gives some unexpected behavior in the completion which I can work around but I was wondering if there are better ways to do this.
1) empty line -> suggests '@command' -> results in @command :)
2) when at @ -> suggests '@command' -> results in @@command :(
3) when at @com -> suggests '@command' -> results in @@command :(
In line 3 the com part is highlighted in the completion so it does recognize it. However, the @ is not and therefore probably always persisted.
The pattern fires by looking at the position of the placeholder in the psi tree using the PlatformPatterns, based on the parent class of the placeholder the @command is suggested. In all cases the placeholder is IntelliJRulezzz.
My workaround is to use an InsertHandler that will check if the resulting context has '@@' at startOffset -1 to +1 and then uses the PsiDocumentManager to remove the excess @. This looks like it's working but I'm always a bit hesistant when it comes to accessing the document directly with insertString / deleteString.
So the question is, is this the way to do it, or is there an easier way to include the @ symbol in the string that is replaced when the completion intention is invoked?