com.intellij.ide.highlighter.HtmlFileType Java Examples
The following examples show how to use
com.intellij.ide.highlighter.HtmlFileType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmtXmlComponent.java From reasonml-idea-plugin with MIT License | 5 votes |
private void addChildren() { PsiFile psiFile = PsiFileFactory.getInstance(m_project).createFileFromText(XHTMLLanguage.INSTANCE, m_xmlDump); Document document = PsiDocumentManager.getInstance(m_project).getDocument(psiFile); if (document != null) { Editor editor = EditorFactory.getInstance().createEditor(document, m_project, HtmlFileType.INSTANCE, true); addToCenter(editor.getComponent()); } }
Example #2
Source File: FluidLanguageSubstitutor.java From idea-php-typo3-plugin with MIT License | 5 votes |
@Nullable @Override public Language getLanguage(@NotNull VirtualFile file, @NotNull Project project) { if (FluidConfig.shouldOpenHtmlAsFluid(project) && file.getFileType() == HtmlFileType.INSTANCE) { if (file instanceof LightVirtualFile) { return null; } return FluidLanguage.INSTANCE; } return null; }
Example #3
Source File: FluidTagNameProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
@Nullable @Override public String[][] getDefaultNamespaces(@NotNull XmlFile file) { return (file.getFileType() == FluidFileType.INSTANCE || file.getFileType() == HtmlFileType.INSTANCE|| file.getFileType() == XmlFileType.INSTANCE) ? new String[][]{ {"f", "http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"}, {"", "http://www.w3.org/1999/html"} } : null; }
Example #4
Source File: QuoteHandler.java From bamboo-soy with Apache License 2.0 | 4 votes |
@Override public Result beforeCharTyped(char charTyped, final Project project, final Editor editor, final PsiFile file, final FileType fileType) { if (file.getFileType() != SoyFileType.INSTANCE && file.getFileType() != HtmlFileType.INSTANCE) { return Result.CONTINUE; } Document document = editor.getDocument(); int caretOffset = editor.getCaretModel().getOffset(); String prevChar = getPreviousChar(document, caretOffset); String nextChar = getNextChar(document, caretOffset); int lineNumber = document.getLineNumber(caretOffset); String textBeforeCaret = document.getText(new TextRange(document.getLineStartOffset(lineNumber), caretOffset)); String textAfterCaret = document.getText(new TextRange(caretOffset, document.getLineEndOffset(lineNumber))); Pair<Character, Character> matchingPairReverse = getMatchingPair(charTyped, p -> p.getSecond()); if (matchingPairReverse != null && nextChar.equals(charTyped + "")) { boolean pairOfEqualChars = (matchingPairReverse.first == matchingPairReverse.second); // Number of opens on the left of the caret. int countLeft = computeCount(textBeforeCaret, matchingPairReverse.first, matchingPairReverse.second); // Number of closes on the right of the caret. int countRight = computeCount(textAfterCaret, matchingPairReverse.second, matchingPairReverse.first); // When the pair is made of equal characters (like quotes) then only trigger if there is // a balance of 1-1 around the caret, which means that the quote is already closed and // inserting a new quote would create an imbalance. if (((!pairOfEqualChars && countLeft <= countRight) || (pairOfEqualChars && countLeft == countRight)) && countRight > 0) { editor.getCaretModel().moveToOffset(caretOffset + 1); return Result.STOP; } } else { Pair<Character, Character> matchingPair = getMatchingPair(charTyped, p -> p.getFirst()); if (matchingPair != null) { if ((alwaysCloseCharacters.contains(matchingPair.first) || (allowedPreviousCharacters .contains(prevChar)) && allowedNextCharacters.contains(nextChar) && !nextChar.equals(matchingPair.second + ""))) { document.insertString(editor.getCaretModel().getOffset(), matchingPair.second + ""); if (editor.getProject() != null) { PsiDocumentManager.getInstance(editor.getProject()).commitDocument(document); } } } } return Result.CONTINUE; }