KT-3161 JetCommenter implementation stub
This commit is contained in:
committed by
Mikhael Bogdanov
parent
cacb4b26e4
commit
2ad1bfa743
@@ -16,9 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin;
|
package org.jetbrains.jet.plugin;
|
||||||
|
|
||||||
import com.intellij.lang.Commenter;
|
import com.intellij.lang.CodeDocumentationAwareCommenter;
|
||||||
|
import com.intellij.psi.PsiComment;
|
||||||
|
import com.intellij.psi.tree.IElementType;
|
||||||
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
public class JetCommenter implements Commenter {
|
public class JetCommenter implements CodeDocumentationAwareCommenter {
|
||||||
@Override
|
@Override
|
||||||
public String getLineCommentPrefix() {
|
public String getLineCommentPrefix() {
|
||||||
return "//";
|
return "//";
|
||||||
@@ -43,4 +46,39 @@ public class JetCommenter implements Commenter {
|
|||||||
public String getCommentedBlockCommentSuffix() {
|
public String getCommentedBlockCommentSuffix() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IElementType getLineCommentTokenType() {
|
||||||
|
return JetTokens.EOL_COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IElementType getBlockCommentTokenType() {
|
||||||
|
return JetTokens.BLOCK_COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IElementType getDocumentationCommentTokenType() {
|
||||||
|
return JetTokens.DOC_COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDocumentationCommentPrefix() {
|
||||||
|
return "/**";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDocumentationCommentLinePrefix() {
|
||||||
|
return "*";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDocumentationCommentSuffix() {
|
||||||
|
return "*/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDocumentationComment(PsiComment element) {
|
||||||
|
return element.getTokenType().equals(JetTokens.DOC_COMMENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/**<caret>
|
||||||
|
fun test() = 0
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* <caret>
|
||||||
|
*/
|
||||||
|
fun test() = 0
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* x<caret>
|
||||||
|
*/
|
||||||
|
fun test() = 0
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* x
|
||||||
|
* <caret>
|
||||||
|
*/
|
||||||
|
fun test() = 0
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.editor;
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
|
import com.intellij.testFramework.EditorTestUtil;
|
||||||
|
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||||
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class JetCommenterTest extends LightCodeInsightTestCase {
|
||||||
|
private static final String BASE_PATH =
|
||||||
|
new File(PluginTestCaseBase.getTestDataPathBase(), "/editor/commenter/").getAbsolutePath();
|
||||||
|
|
||||||
|
public void testGenerateDocComment() throws Exception {
|
||||||
|
doNewLineTypingTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNewLineInComment() throws Exception {
|
||||||
|
doNewLineTypingTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doNewLineTypingTest() throws Exception {
|
||||||
|
configure();
|
||||||
|
EditorTestUtil.performTypingAction(getEditor(), '\n');
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configure() throws Exception {
|
||||||
|
configureFromFileText("a.kt", loadFile(getTestName(false) + ".kt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check() throws Exception {
|
||||||
|
checkResultByText(loadFile(getTestName(false) + "_after.kt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String loadFile(String name) throws Exception {
|
||||||
|
String text = FileUtil.loadFile(new File(BASE_PATH, name));
|
||||||
|
text = StringUtil.convertLineSeparators(text);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user