use of com.intellij.psi.MultiplePsiFilesPerDocumentFileViewProvider in project scss-lint-plugin by idok.
the class ScssLintAnnotationResult method collectInformation.
@Nullable
private static ScssLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) {
if (psiFile.getContext() != null || !isScssFile(psiFile)) {
return null;
}
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null || !virtualFile.isInLocalFileSystem()) {
return null;
}
if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) {
return null;
}
Project project = psiFile.getProject();
// ScssLintProjectComponent component = project.getComponent(ScssLintProjectComponent.class);
// if (!component.isSettingsValid() || !component.isEnabled()) {
// return new ScssLintAnnotationInput(project, psiFile, null, null, "Invalid settings!");
// }
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if (document == null) {
return null;
}
String fileContent = document.getText();
if (StringUtil.isEmptyOrSpaces(fileContent)) {
return null;
}
EditorColorsScheme colorsScheme = editor == null ? null : editor.getColorsScheme();
return new ScssLintAnnotationInput(project, psiFile, fileContent, colorsScheme);
}
use of com.intellij.psi.MultiplePsiFilesPerDocumentFileViewProvider in project intellij-plugins by JetBrains.
the class AngularBracesInterpolationTypedHandler method beforeCharTyped.
@Override
public Result beforeCharTyped(char c, Project project, Editor editor, PsiFile file, FileType fileType) {
if (file.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider || DumbService.isDumb(project))
return Result.CONTINUE;
if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET)
return Result.DEFAULT;
// we should use AngularJSBracesUtil here
if (file.getFileType() == HtmlFileType.INSTANCE) {
final Document document = editor.getDocument();
if (c == '{') {
if (!AngularJSBracesUtil.DEFAULT_START.equals(AngularJSBracesUtil.getInjectionStart(project)) || !AngularJSBracesUtil.DEFAULT_END.equals(AngularJSBracesUtil.getInjectionEnd(project)))
return Result.CONTINUE;
JSCodeStyleSettings jsSettings = JSCodeStyleSettings.getSettings(file);
boolean addWhiteSpaceBetweenBraces = jsSettings.SPACES_WITHIN_INTERPOLATION_EXPRESSIONS;
int offset = editor.getCaretModel().getOffset();
String chars = document.getText();
if (offset > 0 && (chars.charAt(offset - 1)) == '{') {
if (offset < 2 || (chars.charAt(offset - 2)) != '{') {
if (alreadyHasEnding(chars, offset)) {
return Result.CONTINUE;
} else {
String interpolation = addWhiteSpaceBetweenBraces ? "{ }" : "{}";
if (offset == chars.length() || (offset < chars.length() && chars.charAt(offset) != '}')) {
interpolation += "}";
}
EditorModificationUtil.insertStringAtCaret(editor, interpolation, true, addWhiteSpaceBetweenBraces ? 2 : 1);
return Result.STOP;
}
}
}
}
if (c == '}') {
if (!AngularJSBracesUtil.DEFAULT_END.equals(AngularJSBracesUtil.getInjectionEnd(project)))
return Result.CONTINUE;
final int offset = editor.getCaretModel().getOffset();
final char charAt;
if (offset < document.getTextLength()) {
charAt = document.getCharsSequence().charAt(offset);
if (charAt == '}') {
editor.getCaretModel().moveCaretRelatively(1, 0, false, false, true);
return Result.STOP;
}
} else if (offset > 0) {
charAt = document.getCharsSequence().charAt(offset - 1);
if (charAt != '}') {
EditorModificationUtil.insertStringAtCaret(editor, "}}", true, 2);
return Result.STOP;
}
}
}
}
return Result.CONTINUE;
}
Aggregations