Skip to content

Commit 2b3a7e5

Browse files
committed
增加对.cpp/.h/.ts/.tsx扩展名文件的支持
1 parent 113f334 commit 2b3a7e5

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
}
2424

2525
group 'com.haojiyou'
26-
version '1.6.1'
26+
version '1.7.0'
2727

2828
apply plugin: 'org.kordamp.gradle.markdown'
2929
apply plugin: 'java'

docs/CHANGELOG.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<p>---</p>
2+
<h1>1.7.0</h1>
3+
<ul>
4+
<li>增加.cpp,.h,.ts,.tsx扩展名支持</li>
5+
</ul>
26
<h1>1.6.1</h1>
37
<ul>
48
<li>移除过时的api</li>

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
# 1.7.0
3+
* 增加.cpp,.h,.ts,.tsx扩展名支持
4+
25
# 1.6.1
36
* 移除过时的api
47

src/main/java/com/haojiyou/cnchar/CharTypedDocumentLisener.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ public void documentChanged(@NotNull DocumentEvent event) {
5151

5252
public void documentChanged(@NotNull DocumentEvent event, Editor editor) {
5353
if (myEditor == null) {
54-
LOG.info("editor is null");
54+
if(LOG.isDebugEnabled()){
55+
LOG.info("editor is null");
56+
}
5557
return;
5658
}
5759
if (event.getNewLength() > 5 || !(myEditor instanceof EditorImpl)) {
5860
//输入长度大于5,不处理
59-
LOG.info("input char length > 5");
61+
if(LOG.isDebugEnabled()){
62+
LOG.debug("length of the char > 5, do not replace");
63+
}
64+
6065
return;
6166
}
6267

@@ -65,8 +70,6 @@ public void documentChanged(@NotNull DocumentEvent event, Editor editor) {
6570
if (isCanBeReplaced(originalText, replacement, editor.getProject(), editor.getDocument(), editor, this.myFile)) {
6671
CharAutoReplaceAction.INSTANCE.replace(event, editor, originalText, replacement);
6772
}
68-
69-
7073
event.getDocument().removeDocumentListener(CharTypedDocumentLisener.this);
7174

7275
}

src/main/java/com/haojiyou/cnchar/common/CnCharCommentUtil.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ public class CnCharCommentUtil {
2929
COMMENT_START_MAP.put(SupportFileType.JS.getType(), new String[]{"//", "/*"});
3030
COMMENT_END_MAP.put(SupportFileType.JS.getType(), new String[]{"*/"});
3131

32+
COMMENT_START_MAP.put(SupportFileType.TS.getType(), new String[]{"//", "/*"});
33+
COMMENT_END_MAP.put(SupportFileType.TS.getType(), new String[]{"*/"});
34+
35+
COMMENT_START_MAP.put(SupportFileType.TSX.getType(), new String[]{"//", "/*"});
36+
COMMENT_END_MAP.put(SupportFileType.TSX.getType(), new String[]{"*/"});
37+
38+
COMMENT_START_MAP.put(SupportFileType.CPP.getType(), new String[]{"//", "/*"});
39+
COMMENT_END_MAP.put(SupportFileType.CPP.getType(), new String[]{"*/"});
40+
41+
COMMENT_START_MAP.put(SupportFileType.H.getType(), new String[]{"//", "/*"});
42+
COMMENT_END_MAP.put(SupportFileType.H.getType(), new String[]{"*/"});
43+
44+
3245
COMMENT_START_MAP.put(SupportFileType.SQL.getType(), new String[]{"--", "/*"});
3346
COMMENT_END_MAP.put(SupportFileType.SQL.getType(), new String[]{"*/"});
3447

src/main/java/com/haojiyou/cnchar/common/SupportFileType.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ public enum SupportFileType {
1818
HTML("html"),
1919
//js文件
2020
JS("js"),
21+
//c++文件
22+
CPP("cpp"),
23+
//c文件
24+
H("h"),
25+
TS("ts"),
26+
//typescript 文件
27+
TSX("tsx"),
2128
//config file
2229
PROPERTIES("properties"),
2330
//git 忽略文件

src/main/java/com/haojiyou/cnchar/handler/ChineseCharCheckHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ChineseCharCheckHandler extends TypedHandlerDelegate {
2020

2121
@Override
2222
public @NotNull Result beforeCharTyped(char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file, @NotNull FileType fileType) {
23-
LOG.info("your inputed char :" + c);
23+
LOG.info("handler input char: "+ c);
2424
if (StringUtils.isNotBlank(String.valueOf(c))) {
2525
LOG.info("add DocumentListener...CharTypedDocumentLisener");
2626
editor.getDocument().addDocumentListener(new CharTypedDocumentLisener(editor, file));

0 commit comments

Comments
 (0)