use of com.perl5.lang.tt2.idea.settings.TemplateToolkitSettings in project Perl5-IDEA by Camelcade.
the class TemplateToolkitEditorNotificationsProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (file.getFileType() == TemplateToolkitFileType.INSTANCE) {
TemplateToolkitSettings settings = TemplateToolkitSettings.getInstance(myProject);
if (!settings.isVirtualFileUnderRoot(file)) {
EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(PerlBundle.message("tt2.error.file.not.in.root"));
panel.createActionLabel("Configure", () -> Perl5SettingsConfigurable.open(myProject));
return panel;
}
}
return null;
}
use of com.perl5.lang.tt2.idea.settings.TemplateToolkitSettings in project Perl5-IDEA by Camelcade.
the class TemplateToolkitEditorTest method testAutocloseTagCustom.
public void testAutocloseTagCustom() {
saveSettings();
TemplateToolkitSettings settings = TemplateToolkitSettings.getInstance(getProject());
settings.START_TAG = "%SOME%=";
settings.END_TAG = "/ENDTAG$";
testSmartKey("%SOME%<caret>", '=', "%SOME%= /ENDTAG$");
restoreSettings();
}
use of com.perl5.lang.tt2.idea.settings.TemplateToolkitSettings in project Perl5-IDEA by Camelcade.
the class TemplateToolkitTypedHandler method processChar.
protected Result processChar(char c, Project project, Editor editor, PsiFile file, FileType fileType) {
FileViewProvider viewProvider = file.getViewProvider();
if (!(viewProvider instanceof TemplateToolkitFileViewProvider)) {
return null;
}
TemplateToolkitSettings settings = TemplateToolkitSettings.getInstance(project);
String openTag = settings.START_TAG;
if (StringUtil.isEmpty(openTag) || c != openTag.charAt(openTag.length() - 1)) {
return null;
}
int offset = editor.getCaretModel().getOffset();
if (offset == 0) {
return null;
}
PsiElement element = viewProvider.findElementAt(offset - 1, TemplateToolkitLanguage.INSTANCE);
if (element == null) {
return null;
}
IElementType tokenType = element.getNode().getElementType();
if (tokenType != TT2_HTML) {
return null;
}
String openTagPrefix = openTag.substring(0, openTag.length() - 1);
if (openTagPrefix.length() == 0) {
return null;
}
int startOffset = offset - openTagPrefix.length();
if (startOffset < 0) {
return null;
}
if (StringUtil.equals(file.getText().subSequence(startOffset, offset), openTagPrefix)) {
EditorModificationUtil.insertStringAtCaret(editor, c + " " + settings.END_TAG, false, true, 2);
return Result.STOP;
}
return null;
}
use of com.perl5.lang.tt2.idea.settings.TemplateToolkitSettings in project Perl5-IDEA by Camelcade.
the class TemplateToolkitTestSettings method tearDown.
public void tearDown() {
TemplateToolkitSettings templateToolkitSettings = TemplateToolkitSettings.getInstance(myProject);
templateToolkitSettings.START_TAG = myOpenTagBackup;
templateToolkitSettings.END_TAG = myCloseTagBackup;
templateToolkitSettings.OUTLINE_TAG = myOutlineTagBackup;
templateToolkitSettings.ENABLE_ANYCASE = myEnableAnyCase;
}
use of com.perl5.lang.tt2.idea.settings.TemplateToolkitSettings in project Perl5-IDEA by Camelcade.
the class TemplateToolkitTestSettings method setUp.
public void setUp() {
TemplateToolkitSettings templateToolkitSettings = TemplateToolkitSettings.getInstance(myProject);
myOpenTagBackup = templateToolkitSettings.START_TAG;
myCloseTagBackup = templateToolkitSettings.END_TAG;
myOutlineTagBackup = templateToolkitSettings.OUTLINE_TAG;
myEnableAnyCase = templateToolkitSettings.ENABLE_ANYCASE;
templateToolkitSettings.START_TAG = TemplateToolkitSettings.DEFAULT_START_TAG;
templateToolkitSettings.END_TAG = TemplateToolkitSettings.DEFAULT_END_TAG;
templateToolkitSettings.OUTLINE_TAG = TemplateToolkitSettings.DEFAULT_OUTLINE_TAG;
templateToolkitSettings.ENABLE_ANYCASE = false;
}
Aggregations