From cb087a50ada298b3feb88e9045950636da62f25e Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Sun, 20 Jan 2013 20:50:30 +0400 Subject: [PATCH] added initial reflow for ReStructredText --- python/rest/resources/META-INF/rest.xml | 2 +- .../actions/RestFillParagraphHandler.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 python/rest/src/com/jetbrains/rest/actions/RestFillParagraphHandler.java diff --git a/python/rest/resources/META-INF/rest.xml b/python/rest/resources/META-INF/rest.xml index 0887f8ca65e5..100387e906d9 100644 --- a/python/rest/resources/META-INF/rest.xml +++ b/python/rest/resources/META-INF/rest.xml @@ -15,7 +15,7 @@ implementationClass="com.jetbrains.rest.structureView.RestStructureViewFactory"/> - + diff --git a/python/rest/src/com/jetbrains/rest/actions/RestFillParagraphHandler.java b/python/rest/src/com/jetbrains/rest/actions/RestFillParagraphHandler.java new file mode 100644 index 000000000000..171d0e4960a1 --- /dev/null +++ b/python/rest/src/com/jetbrains/rest/actions/RestFillParagraphHandler.java @@ -0,0 +1,30 @@ +package com.jetbrains.rest.actions; + +import com.intellij.codeInsight.editorActions.fillParagraph.ParagraphFillHandler; +import com.intellij.psi.PsiComment; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.jetbrains.rest.RestFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * User : ktisha + */ +public class RestFillParagraphHandler extends ParagraphFillHandler { + + @NotNull + protected String getPrefix(@NotNull final PsiElement element) { + return element instanceof PsiComment? ".. " : ""; + } + + @Override + protected boolean isAvailableForFile(@Nullable PsiFile psiFile) { + return psiFile instanceof RestFile; + } + + @Override + protected boolean isBunchOfElement(PsiElement element) { + return true; + } +}