use of com.intellij.coldFusion.UI.editorActions.matchers.CfmlBraceMatcher in project intellij-plugins by JetBrains.
the class CfmlTypedHandler method beforeCharTyped.
public Result beforeCharTyped(final char c, final Project project, final Editor editor, final PsiFile file, final FileType fileType) {
PsiFile cfmlFile = file.getViewProvider().getPsi(CfmlLanguage.INSTANCE);
if (isNotCfmlFile(cfmlFile, editor)) {
return Result.CONTINUE;
}
int offset = editor.getCaretModel().getOffset();
if (c == '{') {
CfmlBraceMatcher braceMatcher = new CfmlBraceMatcher();
HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset);
if (!braceMatcher.isLBraceToken(iterator, editor.getDocument().getCharsSequence(), fileType)) {
EditorModificationUtil.insertStringAtCaret(editor, "}", true, 0);
// return Result.STOP;
}
return Result.CONTINUE;
}
if (c == '#') {
if (ourEnableDoublePoundInsertion && CfmlEditorUtil.countSharpsBalance(editor) == 0) {
char charAtOffset = DocumentUtils.getCharAt(editor.getDocument(), offset);
if (charAtOffset == '#') {
EditorModificationUtil.moveCaretRelatively(editor, 1);
return Result.STOP;
}
EditorModificationUtil.insertStringAtCaret(editor, "#", true, 0);
}
} else if (c == '>') {
if (((EditorEx) editor).getHighlighter().createIterator(editor.getCaretModel().getOffset()).getTokenType() == CfmlTokenTypes.COMMENT || ((EditorEx) editor).getHighlighter().createIterator(editor.getCaretModel().getOffset()).getTokenType().getLanguage() != CfmlLanguage.INSTANCE) {
return Result.CONTINUE;
}
insertCloseTagIfNeeded(editor, cfmlFile, project);
return Result.STOP;
}
return Result.CONTINUE;
}
Aggregations