Skip to content

Fix 404s #2937

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 20, 2023
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
22 changes: 11 additions & 11 deletions _ja/overviews/reflection/annotations-names-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Scala または Java アノテーションに対しては `scalaArgs` は空で
## 名前

**名前** (name) は文字列の簡単なラッパーだ。
[`Name`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Names$NameApi.html)
[`Name`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Names$NameApi.html)
には 2つのサブタイプ `TermName` と `TypeName` があり (オブジェクトやメンバーのような) 項の名前と
(クラス、トレイト、型メンバのような) 型の名前を区別する。同じオブジェクト内に同名の項と型が共存することができる。別の言い方をすると、型と項は別の名前空間を持つ。

Expand Down Expand Up @@ -96,19 +96,19 @@ Scala のプログラムにおいて、「`_root_`」のような特定の名前

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

## スコープ

**スコープ** (scope) は一般にある構文スコープ内の名前をシンボルに関連付ける。
スコープは入れ子にすることもできる。リフレクション API
で公開されているスコープの基底型は [Symbol](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Symbols$Symbol.html) の iterable という最小限のインターフェイスのみを公開する。
で公開されているスコープの基底型は [Symbol](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Symbols$Symbol.html) の iterable という最小限のインターフェイスのみを公開する。

追加機能は
[scala.reflect.api.Types#TypeApi](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Types$TypeApi.html)
[scala.reflect.api.Types#TypeApi](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Types$TypeApi.html)
内で定義されている `member` と `decls`
が返す**メンバスコープ** (member scope) にて公開される。
[scala.reflect.api.Scopes#MemberScope](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Scopes$MemberScope.html)
[scala.reflect.api.Scopes#MemberScope](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Scopes$MemberScope.html)
は `sorted` メソッドをサポートしており、これはメンバを**宣言順に**ソートする。

以下に `List` クラスでオーバーライドされている全てのシンボルのリストを宣言順に返す具体例をみてみよう:
Expand All @@ -119,7 +119,7 @@ Scala のプログラムにおいて、「`_root_`」のような特定の名前
## Expr

構文木の基底型である `scala.reflect.api.Trees#Tree` の他に、型付けされた構文木は
[`scala.reflect.api.Exprs#Expr`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Exprs$Expr.html) 型によっても表すことができる。
[`scala.reflect.api.Exprs#Expr`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Exprs$Expr.html) 型によっても表すことができる。
`Expr` は構文木と、その構文木の型に対するアクセスを提供するための型タグをラッピングする。
`Expr` は主にマクロのために便宜的に型付けられた構文木を作るために使われる。多くの場合、これは
`reify` と `splice` メソッドが関わってくる。
Expand Down Expand Up @@ -175,8 +175,8 @@ Scala コンパイラによってコンパイル時に評価することがで

1. プリミティブ値クラスのリテラル ([Byte](https://www.scala-lang.org/api/current/index.html#scala.Byte)、 [Short](https://www.scala-lang.org/api/current/index.html#scala.Short)、 [Int](https://www.scala-lang.org/api/current/index.html#scala.Int)、 [Long](https://www.scala-lang.org/api/current/index.html#scala.Long)、 [Float](https://www.scala-lang.org/api/current/index.html#scala.Float)、 [Double](https://www.scala-lang.org/api/current/index.html#scala.Double)、 [Char](https://www.scala-lang.org/api/current/index.html#scala.Char)、 [Boolean](https://www.scala-lang.org/api/current/index.html#scala.Boolean) および [Unit](https://www.scala-lang.org/api/current/index.html#scala.Unit))。これは直接対応する型で表される。
2. 文字列リテラル。これは文字列のインスタンスとして表される。
3. 一般に [scala.Predef#classOf](https://www.scala-lang.org/api/current/index.html#scala.Predef$@classOf[T]:Class[T]) で構築されるクラスへの参照。[型](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Types$Type.html)として表される。
4. Java の列挙要素。[シンボル](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Symbols$Symbol.html)として表される。
3. 一般に [scala.Predef#classOf](https://www.scala-lang.org/api/current/index.html#scala.Predef$@classOf[T]:Class[T]) で構築されるクラスへの参照。[型](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Types$Type.html)として表される。
4. Java の列挙要素。[シンボル](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Symbols$Symbol.html)として表される。

定数式の用例としては

Expand Down Expand Up @@ -264,8 +264,8 @@ Java の列挙要素への参照はシンボル (`scala.reflect.api.Symbols#Symb

## プリティプリンタ

[`Trees`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Trees.html) と
[`Types`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Types.html)
[`Trees`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Trees.html) と
[`Types`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Types.html)
を整形して表示するユーティリティを説明しよう。

### 構文木の表示
Expand Down Expand Up @@ -380,7 +380,7 @@ Java の列挙要素への参照はシンボル (`scala.reflect.api.Symbols#Symb

## 位置情報

**位置情報** ([`Position`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Position.html))
**位置情報** ([`Position`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Position.html))
はシンボルや構文木のノードの出処を追跡するのに使われる。警告やエラーの表示でよく使われ、プログラムのどこが間違ったのかを正確に表示することができる。位置情報はソースファイルの列と行を表す。
(ソースファイルの初めからのオフセットは「ポイント」と呼ばれるが、これは便利ではないことがある)
位置情報はそれが指す行の内容も保持する。全ての構文木やシンボルが位置情報を持つわけではなく、ない場合は
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 @@ -167,7 +167,7 @@ title: シンボル、構文木、型
scala> val intTpe = universe.definitions.IntTpe
intTpe: scala.reflect.runtime.universe.Type = Int

標準型のリストは [`scala.reflect.api.StandardDefinitions`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/StandardDefinitions$StandardTypes.html) 内の `StandardTypes`
標準型のリストは [`scala.reflect.api.StandardDefinitions`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/StandardDefinitions$StandardTypes.html) 内の `StandardTypes`
トレイトにて定義されている。

### 型の一般的な演算
Expand Down
22 changes: 11 additions & 11 deletions _overviews/reflection/annotations-names-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ represent different kinds of Java annotation arguments:
## Names

Names are simple wrappers for strings.
[Name](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Names$NameApi.html)
[Name](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Names$NameApi.html)
has two subtypes `TermName` and `TypeName` which distinguish names of terms (like
objects or members) and types (like classes, traits, and type members). A term
and a type of the same name can co-exist in the same object. In other words,
Expand Down Expand Up @@ -104,19 +104,19 @@ There are both
Some names, such as "package", exist both as a type name and a term name.
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](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/StandardNames.html).
[API documentation](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/StandardNames.html).

## Scopes

A scope object generally maps names to symbols available in a corresponding
lexical scope. Scopes can be nested. The base type exposed in the reflection
API, however, only exposes a minimal interface, representing a scope as an
iterable of [Symbol](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Symbols$Symbol.html)s.
iterable of [Symbol](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Symbols$Symbol.html)s.

Additional functionality is exposed in *member scopes* that are returned by
`members` and `decls` defined in
[scala.reflect.api.Types#TypeApi](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Types$TypeApi.html).
[scala.reflect.api.Scopes#MemberScope](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Scopes$MemberScope.html)
[scala.reflect.api.Types#TypeApi](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Types$TypeApi.html).
[scala.reflect.api.Scopes#MemberScope](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Scopes$MemberScope.html)
supports the `sorted` method, which sorts members *in declaration order*.

The following example returns a list of the symbols of all final members
Expand All @@ -129,7 +129,7 @@ of the `List` class, in declaration order:

In addition to type `scala.reflect.api.Trees#Tree`, the base type of abstract
syntax trees, typed trees can also be represented as instances of type
[`scala.reflect.api.Exprs#Expr`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Exprs$Expr.html).
[`scala.reflect.api.Exprs#Expr`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Exprs$Expr.html).
An `Expr` wraps
an abstract syntax tree and an internal type tag to provide access to the type
of the tree. `Expr`s are mainly used to simply and conveniently create typed
Expand Down Expand Up @@ -189,9 +189,9 @@ expressions are compile-time constants (see [section 6.24 of the Scala language

2. String literals - represented as instances of the string.

3. References to classes, typically constructed with [scala.Predef#classOf](https://www.scala-lang.org/api/current/index.html#scala.Predef$@classOf[T]:Class[T]) - represented as [types](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Types$Type.html).
3. References to classes, typically constructed with [scala.Predef#classOf](https://www.scala-lang.org/api/current/index.html#scala.Predef$@classOf[T]:Class[T]) - represented as [types](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Types$Type.html).

4. References to Java enumeration values - represented as [symbols](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Symbols$Symbol.html).
4. References to Java enumeration values - represented as [symbols](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Symbols$Symbol.html).

Constant expressions are used to represent

Expand Down Expand Up @@ -287,8 +287,8 @@ Example:
## Printers

Utilities for nicely printing
[`Trees`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Trees.html) and
[`Types`](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Types.html).
[`Trees`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Trees.html) and
[`Types`](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Types.html).

### Printing Trees

Expand Down Expand Up @@ -408,7 +408,7 @@ additionally shows the unique identifiers of symbols, as well as their kind
## Positions

Positions (instances of the
[Position](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Position.html) trait)
[Position](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Position.html) trait)
are used to track the origin of symbols and tree nodes. They are commonly used when
displaying warnings and errors, to indicate the incorrect point in the
program. Positions indicate a column and line in a source file (the offset
Expand Down
4 changes: 2 additions & 2 deletions _overviews/reflection/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ reflection, such as `Types`, `Trees`, and `Annotations`. For more details, see
the section of this guide on
[Universes]({{ site.baseurl}}/overviews/reflection/environment-universes-mirrors.html),
or the
[Universes API docs](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Universe.html)
[Universes API docs](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Universe.html)
in package `scala.reflect.api`.

To use most aspects of Scala reflection, including most code examples provided
Expand All @@ -345,5 +345,5 @@ different flavors of mirrors must be used.
For more details, see the section of this guide on
[Mirrors]({{ site.baseurl}}/overviews/reflection/environment-universes-mirrors.html),
or the
[Mirrors API docs](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Mirrors.html)
[Mirrors API docs](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Mirrors.html)
in package `scala.reflect.api`.
4 changes: 2 additions & 2 deletions _sips/sips/scala-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Last section of this proposal is the list of options that each sub-command MUST



Scala CLI can also be configured with ["using directives"](https://scala-cli.virtuslab.org/docs/guides/using-directives) - a comment-based configuration syntax that should be placed at the top of Scala files. This allows for self-containing examples within one file since most of the configuration can be provided either from the command line or via using directives (command line has precedence). This is a game changer for use cases like scripting, reproduction, or within the academic scope.
Scala CLI can also be configured with ["using directives"](https://scala-cli.virtuslab.org/docs/guides/introduction/using-directives/) - a comment-based configuration syntax that should be placed at the top of Scala files. This allows for self-containing examples within one file since most of the configuration can be provided either from the command line or via using directives (command line has precedence). This is a game changer for use cases like scripting, reproduction, or within the academic scope.

We have described the motivation, syntax and implementation basis in the [dedicated pre-SIP](https://contributors.scala-lang.org/t/pre-sip-using-directives/5700). Currently, we recommend to write using directives as comments, so making them part of the language specification is not necessary at this stage. Moreover, the new `scala` command could ignore using directives in the initial version, however we strongly suggest to include comment-based using directives from the start.

Expand All @@ -149,7 +149,7 @@ Adopting Scala CLI as the new `scala` command, as is, will change some of the be

### Other concerns

Scala CLI brings [using directives](https://scala-cli.virtuslab.org/docs/guides/using-directives) and [conventions to mark the test files](https://scala-cli.virtuslab.org/docs/commands/test#test-sources). We suggest to accept both accepted as a part of this SIP but we are ready to open dedicated SIPs for both (we have opened a [pre-SIP for using directives](https://contributors.scala-lang.org/t/pre-sip-using-directives/5700/15))
Scala CLI brings [using directives](https://scala-cli.virtuslab.org/docs/guides/introduction/using-directives/) and [conventions to mark the test files](https://scala-cli.virtuslab.org/docs/commands/test#test-sources). We suggest to accept both accepted as a part of this SIP but we are ready to open dedicated SIPs for both (we have opened a [pre-SIP for using directives](https://contributors.scala-lang.org/t/pre-sip-using-directives/5700/15))

Scala CLI is an ambitious project and may seem hard to maintain in the long-run.

Expand Down
4 changes: 2 additions & 2 deletions _zh-cn/overviews/reflection/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Scala反射实现了允许在编译阶段就对程序进行修改的一种元编
`Universe`是Scala反射的切入点。

`universe`提供了使用反射所关联的很多核心概念,比如`Types`,`Trees`,以及`Annotations`。
更多细节请参阅指南中[Universes](https://docs.scala-lang.org/overviews/reflection/environment-universes-mirrors.html)部分,或者看`scala.reflect.api`包的[Universes API文档](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Universe.html)。
更多细节请参阅指南中[Universes](https://docs.scala-lang.org/overviews/reflection/environment-universes-mirrors.html)部分,或者看`scala.reflect.api`包的[Universes API文档](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Universe.html)。

本指南中提供了大多数情况下Scala反射要用到的部分,一般在使用运行时反射的场景下,直接导入所有`universe`成员去用即可:

Expand All @@ -293,4 +293,4 @@ import scala.reflect.runtime.universe._
反射所能提供的信息都是通过镜像去访问的。
根据不同的类型信息或不同的反射操作,必须要使用不同类型的镜像。

更多细节请参阅指南中[Mirros](https://docs.scala-lang.org/overviews/reflection/environment-universes-mirrors.html)部分,或者看`scala.reflect.api`包的[Mirrors API文档](https://www.scala-lang.org/api/current/scala-reflect/scala/reflect/api/Mirrors.html)。
更多细节请参阅指南中[Mirros](https://docs.scala-lang.org/overviews/reflection/environment-universes-mirrors.html)部分,或者看`scala.reflect.api`包的[Mirrors API文档](https://www.scala-lang.org/api/2.x/scala-reflect/scala/reflect/api/Mirrors.html)。