为 Android Studio 项目添加 JS 和 CSS 支持 [英] Add JS and CSS support to Android Studio project

查看:35
本文介绍了为 Android Studio 项目添加 JS 和 CSS 支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了新的 Android Studio,我正在寻找一种方法来获得对 CSS 和 JS 的支持(自动完成,突出显示错误用法),就像我在 PHPStorm 和 WebStorm 中所做的那样,这两种 IntelliJ 产品.

I just installed the new Android Studio and I'm looking for a way to be able to get support for CSS and JS (autocomplete, highlighting for incorrect usages) as i would in PHPStorm and also WebStorm, both intelliJ products.

我已经用谷歌搜索过,甚至将其添加到文件类型"中,但它们仍然只显示为纯文本文件.

I have googled and even added it to 'File Types', but stil they just display as plain text files.

推荐答案

您可以非常轻松地突出显示语法.

You can get syntax highlighting pretty easy.

在文件 > 设置 > 文件类型中,创建一个 Javascript 文件类型并将 *.js 添加到注册的模式中.您需要添加所有关键字.

In File > Settings > Files Types, create a Javascript file type and add *.js to the registered patterns. You will need to add all the keywords.

或者,您可以直接编辑 XML 文件.在 Ubuntu 中,它存储在/home/"User Name"/.AndroidStudioPreview/config/filetypes,我的看起来像这样:

Alternatively you can edit the XML file directly. In Ubuntu it is stored at /home/"User Name"/.AndroidStudioPreview/config/filetypes, and mine looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="Javascript" name="Javascript">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="//" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="break;case;catch;continue;debugger;default;delete;do;else;finally;for;function;if;in;instanceof;new;return;switch;this;throw;try;typeof;var;void;while;with" ignore_case="false" />
  </highlighting>
  <extensionMap>
    <mapping ext="js" />
  </extensionMap>
</filetype>

至于自动完成,您可能需要查看 File Watcher 但是我还没弄明白.但我认为,如果您拥有 PHPStorm 和 WebStorm,那么您就已经拥有了 IntelliJ 所需的插件.您可以添加自定义插件.也许尝试将免费的 IDEA 插件添加到 WebStorm ...

As for autocompletion you may want to look into File Watcher, but I haven't figured it out yet. But I think if you have PHPStorm and WebStorm you already have the plugins you need for IntelliJ. And you can add custom plugins. Maybe try adding the free IDEA plugins to WebStorm ...

EDIT:在 Windows 上最新的 Android Studio (1.0) 中,这些 XML 的位置如下:

EDIT: In the latest Android Studio (1.0) on Windows, the location of these XMLs is the following:

.AndroidStudio\config\options\filetypes.xml :

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <component name="FileTypeManager" version="11">
    <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;" />
    <extensionMap>
      <mapping ext="js" type="Javascript" />
    </extensionMap>
  </component>
</application>

.AndroidStudio\config\filetypes\Javascript.xml

<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="Javascript Files" name="Javascript Files">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="//" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="break;case;catch;continue;debugger;default;delete;do;else;finally;for;function;if;in;instanceof;new;return;switch;this;throw;try;typeof;var;void;while;with" ignore_case="false" />
  </highlighting>
  <extensionMap>
    <mapping ext="js" />
  </extensionMap>
</filetype>

这篇关于为 Android Studio 项目添加 JS 和 CSS 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆