From a669ed1f9dfdf09d9251495103f7399c7fb5bfdd Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Mon, 10 Mar 2014 12:10:17 -0700 Subject: [PATCH] Register a new smali file type --- smalidea/META-INF/plugin.xml | 1 + smalidea/smalidea.iml | 2 + .../java/org/jf/smalidea/SmaliFileType.java | 66 ++++++++++++++++++ .../org/jf/smalidea/SmaliFileTypeFactory.java | 43 ++++++++++++ .../main/java/org/jf/smalidea/SmaliIcons.java | 40 +++++++++++ .../java/org/jf/smalidea/SmaliLanguage.java | 46 ++++++++++++ smalidea/src/main/resources/icons/smali.png | Bin 0 -> 261 bytes .../org/jf/smalidea/SmaliFileTypeTest.java | 47 +++++++++++++ 8 files changed, 245 insertions(+) create mode 100644 smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java create mode 100644 smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java create mode 100644 smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java create mode 100644 smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java create mode 100644 smalidea/src/main/resources/icons/smali.png create mode 100644 smalidea/src/test/java/org/jf/smalidea/SmaliFileTypeTest.java diff --git a/smalidea/META-INF/plugin.xml b/smalidea/META-INF/plugin.xml index 4b42f0c1..8b142a37 100644 --- a/smalidea/META-INF/plugin.xml +++ b/smalidea/META-INF/plugin.xml @@ -15,6 +15,7 @@ + diff --git a/smalidea/smalidea.iml b/smalidea/smalidea.iml index c1f22d21..3411cee0 100644 --- a/smalidea/smalidea.iml +++ b/smalidea/smalidea.iml @@ -5,6 +5,8 @@ + + diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java b/smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java new file mode 100644 index 00000000..e840bb8d --- /dev/null +++ b/smalidea/src/main/java/org/jf/smalidea/SmaliFileType.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.smalidea; + +import com.intellij.openapi.fileTypes.LanguageFileType; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +public class SmaliFileType extends LanguageFileType { + public static final SmaliFileType INSTANCE = new SmaliFileType(); + public static final String DEFAULT_EXTENSION = "smali"; + + private SmaliFileType() { + super(SmaliLanguage.INSTANCE); + } + + @NotNull @Override public String getName() { + return "smali"; + } + + @NotNull @Override public String getDescription() { + return "smali Files"; + } + + @NotNull @Override public String getDefaultExtension() { + return DEFAULT_EXTENSION; + } + + @Override public Icon getIcon() { + return SmaliIcons.SmaliIcon; + } + + @Override public boolean isJVMDebuggingSupported() { + return true; + } +} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java b/smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java new file mode 100644 index 00000000..b5834c18 --- /dev/null +++ b/smalidea/src/main/java/org/jf/smalidea/SmaliFileTypeFactory.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.smalidea; + +import com.intellij.openapi.fileTypes.FileTypeConsumer; +import com.intellij.openapi.fileTypes.FileTypeFactory; +import org.jetbrains.annotations.NotNull; + +public class SmaliFileTypeFactory extends FileTypeFactory { + @Override + public void createFileTypes(@NotNull FileTypeConsumer consumer) { + consumer.consume(SmaliFileType.INSTANCE, SmaliFileType.DEFAULT_EXTENSION); + } +} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java b/smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java new file mode 100644 index 00000000..449e71b5 --- /dev/null +++ b/smalidea/src/main/java/org/jf/smalidea/SmaliIcons.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.smalidea; + +import com.intellij.openapi.util.IconLoader; + +import javax.swing.*; + +public class SmaliIcons { + public static final Icon SmaliIcon = IconLoader.getIcon("/icons/smali.png"); +} diff --git a/smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java b/smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java new file mode 100644 index 00000000..f437ec27 --- /dev/null +++ b/smalidea/src/main/java/org/jf/smalidea/SmaliLanguage.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.smalidea; + +import com.intellij.lang.Language; + +public class SmaliLanguage extends Language { + public static final SmaliLanguage INSTANCE = new SmaliLanguage(); + + private SmaliLanguage() { + super("smali", "text/smali"); + } + + @Override public boolean isCaseSensitive() { + return true; + } +} diff --git a/smalidea/src/main/resources/icons/smali.png b/smalidea/src/main/resources/icons/smali.png new file mode 100644 index 0000000000000000000000000000000000000000..e60efc5614d052881378579d22ae09b6266c733d GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf<4p|Wiy}FY+zCfW?PZ!4!i_>o} z8uBp~3LJf?FVbBl%o&(@$LajM6P#v+tm+GnuzFm{+8edPOzUh(&Le;Ix~D16&Yr3M zqf@)4z_C@fOQg}(t7KwgPj1%%*|+6VvrWHpx>+2RKKW(C0ZDTm!yi{J$P~-$^IR&t z&*tI^$r~-7*X~GYOFnfhGbR3EmucI-Jx>^KZxywZ%vp2|=pY79S3j3^P6