Skip to content

Commit 593110b

Browse files
committed
Support format xml and json
1 parent 09ec68d commit 593110b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib-n-ide/src/main/java/com/duy/ide/code/format/CodeFormatProviderImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import com.duy.ide.code.api.CodeFormatProvider;
2424
import com.duy.ide.code.api.CodeFormatter;
25+
import com.duy.ide.code.model.JsonFormatter;
26+
import com.duy.ide.code.model.XmlFormatter;
2527
import com.duy.ide.editor.IEditorDelegate;
2628

2729
import java.io.File;
@@ -38,6 +40,14 @@ public CodeFormatProviderImpl(Context context) {
3840
@Nullable
3941
@Override
4042
public CodeFormatter getFormatterForFile(File file, IEditorDelegate delegate) {
43+
if (!file.exists() || file.isDirectory()) {
44+
return null;
45+
}
46+
if (file.getName().equals(".xml")) {
47+
return new XmlFormatter();
48+
} else if (file.getName().endsWith(".json")) {
49+
return new JsonFormatter();
50+
}
4151
return null;
4252
}
4353

0 commit comments

Comments
 (0)