Skip to content

Replace deprecated nme and tpnme with termNames and typeNames #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions _ja/overviews/reflection/annotations-names-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ Scala または Java アノテーションに対しては `scalaArgs` は空で
Scala のプログラムにおいて、「`_root_`」のような特定の名前は特殊な意味を持つ。
そのため、それらは Scala の構造物をリフレクションを用いてアクセスするのに欠かすことができない。
例えば、リフレクションを用いてコンストラクタを呼び出すには**標準名** (standard name)
`universe.nme.CONSTRUCTOR` を用いる。これは、JVM 上でのコンストラクタ名である項名「`<init>`」を指す。
`universe.termNames.CONSTRUCTOR` を用いる。これは、JVM 上でのコンストラクタ名である項名「`<init>`」を指す。

- 「`<init>`」、「`package`」、「`_root_`」のような**標準項名** (standard term names) と
- 「`<error>`」、「`_`」、「`_*`」のような**標準型名** (standard type names)

の両方が存在する。

「`package`」のようないくつかの名前は型名と項名の両方が存在する。
標準名は `Universe` クラスの `nme` と `tpnme` というメンバとして公開されている。
標準名は `Universe` クラスの `termNames` と `typeNames` というメンバとして公開されている。
全ての標準名の仕様は [API doc](http://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/StandardNames.html) を参照。

## スコープ
Expand Down Expand Up @@ -307,9 +307,9 @@ Java の列挙要素への参照はシンボル (`scala.reflect.api.Symbols#Symb
List(Ident(TypeName("AnyRef"))),
emptyValDef,
List(
DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(),
DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(),
Block(List(
Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())),
Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())),
Literal(Constant(())))),
DefDef(Modifiers(), TermName("x"), List(), List(), TypeTree(),
Literal(Constant(2))))))),
Expand All @@ -329,9 +329,9 @@ Java の列挙要素への参照はシンボル (`scala.reflect.api.Symbols#Symb
List(Ident[4](TypeName("AnyRef"))),
emptyValDef,
List(
DefDef[2](Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree[3](),
DefDef[2](Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree[3](),
Block[1](List(
Apply[4](Select[5](Super[6](This[3](TypeName("C")), tpnme.EMPTY), ...))),
Apply[4](Select[5](Super[6](This[3](TypeName("C")), typeNames.EMPTY), ...))),
Literal[1](Constant(())))),
DefDef[2](Modifiers(), TermName("x"), List(), List(), TypeTree[7](),
Literal[8](Constant(2))))))),
Expand Down
2 changes: 1 addition & 1 deletion _ja/overviews/reflection/environment-universes-mirrors.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ invoker ミラーを作成することができる。
scala> val cm = m.reflectClass(classC)
cm: scala.reflect.runtime.universe.ClassMirror = class mirror for C (bound to null)

scala> val ctorC = ru.typeOf[C].decl(ru.nme.CONSTRUCTOR).asMethod
scala> val ctorC = ru.typeOf[C].decl(ru.termNames.CONSTRUCTOR).asMethod
ctorC: scala.reflect.runtime.universe.MethodSymbol = constructor C

scala> val ctorm = cm.reflectConstructor(ctorC)
Expand Down
2 changes: 1 addition & 1 deletion _ja/overviews/reflection/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Scala コンパイラが持つ型情報を全ては入手できない可能性
次に、`reflectClass` メソッドを使って `Person` クラスの `ClassMirror` を取得する。
`ClassMirror` は `Person` クラスのコンストラクタへのアクセスを提供する。

scala> val ctor = ru.typeOf[Person].decl(ru.nme.CONSTRUCTOR).asMethod
scala> val ctor = ru.typeOf[Person].decl(ru.termNames.CONSTRUCTOR).asMethod
ctor: scala.reflect.runtime.universe.MethodSymbol = constructor Person

`Person` のコンストラクタのシンボルは実行時ユニバース `ru` を用いて `Person` 型の宣言から照会することによってのみ得られる。
Expand Down
2 changes: 1 addition & 1 deletion _ja/overviews/reflection/symbols-trees-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Scala リフレクションは、ユニバース経由で構文木を視覚化
生の構文木の内部構造をインスペクトするには以下のように行う:

scala> showRaw(tree)
res1: String = Block(List(ClassDef(Modifiers(), TypeName("Flower"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), DefDef(Modifiers(), TermName("name"), List(), List(), TypeTree(), Literal(Constant("Rose"))))))), Literal(Constant(())))
res1: String = Block(List(ClassDef(Modifiers(), TypeName("Flower"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())), Literal(Constant(())))), DefDef(Modifiers(), TermName("name"), List(), List(), TypeTree(), Literal(Constant("Rose"))))))), Literal(Constant(())))

### 構文木の走査

Expand Down
12 changes: 6 additions & 6 deletions _overviews/reflection/annotations-names-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ convert between strings and term or type names:
Certain names, such as "`_root_`", have special meanings in Scala programs. As
such they are essential for reflectively accessing certain Scala constructs.
For example, reflectively invoking a constructor requires using the
*standard name* `universe.nme.CONSTRUCTOR`, the term name `<init>` which represents the
*standard name* `universe.termNames.CONSTRUCTOR`, the term name `<init>` which represents the
constructor name on the JVM.

There are both
Expand All @@ -109,7 +109,7 @@ There are both
- *standard type names,* _e.g.,_ "`<error>`", "`_`", and "`_*`".

Some names, such as "package", exist both as a type name and a term name.
Standard names are made available through the `nme` and `tpnme` members of
Standard names are made available through the `termNames` and `typeNames` members of
class `Universe`. For a complete specification of all standard names, see the
[API documentation](http://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/StandardNames.html).

Expand Down Expand Up @@ -337,9 +337,9 @@ valid Scala code.
List(Ident(TypeName("AnyRef"))),
emptyValDef,
List(
DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(),
DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(),
Block(List(
Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())),
Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())),
Literal(Constant(())))),
DefDef(Modifiers(), TermName("x"), List(), List(), TypeTree(),
Literal(Constant(2))))))),
Expand All @@ -359,9 +359,9 @@ The method `showRaw` can also print `scala.reflect.api.Types` next to the artifa
List(Ident[4](TypeName("AnyRef"))),
emptyValDef,
List(
DefDef[2](Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree[3](),
DefDef[2](Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree[3](),
Block[1](List(
Apply[4](Select[5](Super[6](This[3](TypeName("C")), tpnme.EMPTY), ...))),
Apply[4](Select[5](Super[6](This[3](TypeName("C")), typeNames.EMPTY), ...))),
Literal[1](Constant(())))),
DefDef[2](Modifiers(), TermName("x"), List(), List(), TypeTree[7](),
Literal[8](Constant(2))))))),
Expand Down
2 changes: 1 addition & 1 deletion _overviews/reflection/environment-universes-mirrors.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ A `ClassMirror` is used for creating invoker mirrors for constructors. Entry poi
scala> val cm = m.reflectClass(classC)
cm: scala.reflect.runtime.universe.ClassMirror = class mirror for C (bound to null)

scala> val ctorC = ru.typeOf[C].decl(ru.nme.CONSTRUCTOR).asMethod
scala> val ctorC = ru.typeOf[C].decl(ru.termNames.CONSTRUCTOR).asMethod
ctorC: scala.reflect.runtime.universe.MethodSymbol = constructor C

scala> val ctorm = cm.reflectConstructor(ctorC)
Expand Down
2 changes: 1 addition & 1 deletion _overviews/reflection/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ The second step involves obtaining a `ClassMirror` for class `Person` using
the `reflectClass` method. The `ClassMirror` provides access to the
constructor of class `Person`.

scala> val ctor = ru.typeOf[Person].decl(ru.nme.CONSTRUCTOR).asMethod
scala> val ctor = ru.typeOf[Person].decl(ru.termNames.CONSTRUCTOR).asMethod
ctor: scala.reflect.runtime.universe.MethodSymbol = constructor Person

The symbol for `Person`s constructor can be obtained using only the runtime
Expand Down
2 changes: 1 addition & 1 deletion _overviews/reflection/symbols-trees-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ the tree that `expr` contains by:
And we can inspect the raw tree by simply doing:

scala> showRaw(tree)
res1: String = Block(List(ClassDef(Modifiers(), TypeName("Flower"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), DefDef(Modifiers(), TermName("name"), List(), List(), TypeTree(), Literal(Constant("Rose"))))))), Literal(Constant(())))
res1: String = Block(List(ClassDef(Modifiers(), TypeName("Flower"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())), Literal(Constant(())))), DefDef(Modifiers(), TermName("name"), List(), List(), TypeTree(), Literal(Constant("Rose"))))))), Literal(Constant(())))

### Traversing Trees

Expand Down