jberkel / android-plugin

An sbt plugin for Android development in Scala
https://groups.google.com/forum/#!forum/scala-on-android
Other
476 stars 113 forks source link

Escapes resource names in TypedResources which are reserved words #183

Closed taku0 closed 11 years ago

taku0 commented 11 years ago

Reserved words can be used as identifiers if backquoted. This patch quotes reserved words instead of just eliminating them.

Reserved words are taken from the section 1.1 of the language specification.

Here is a sample layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">
  <TextView android:id="@+id/lazy"/>
  <TextView android:id="@+id/object"/>
  <TextView android:id="@+id/override"/>
  <TextView android:id="@+id/sealed"/>
  <TextView android:id="@+id/trait"/>
  <TextView android:id="@+id/var"/>
  <TextView android:id="@+id/forSome"/>
  <TextView android:id="@+id/match"/>
  <TextView android:id="@+id/type"/>
  <TextView android:id="@+id/with"/>
  <TextView android:id="@+id/yield"/>
  <TextView android:id="@+id/def"/>
  <TextView android:id="@+id/implicit"/>
  <TextView android:id="@+id/val"/>
</LinearLayout>

Note that we cannot use Java reserved words anyway.

appamatto commented 11 years ago

@taku0, I noticed there is some duplication with TypedLayouts.scala. Do you mind refactoring this and submitting another PR?