swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.46k stars 10.35k forks source link

[SR-1037] Code completion should consider the transliteration and normalization of identifiers #43649

Open swift-ci opened 8 years ago

swift-ci commented 8 years ago
Previous ID SR-1037
Radar None
Original Reporter maxs (JIRA User)
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | CodeCompletion | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: 287588e11444ae51eaca287f0e6fba64

Issue Description:

If I have the program:

let 日本 = "Japan!"

Then code completion should consider the following as prefix matches for the 日本 identifier by transliteration or normalization:

belkadan commented 8 years ago

I don't think we can do that in this fully general case without a locale to attempt transliteration by. (You put "ni" and "ri" but what about Korean "il"?) But we could try for kana and other characters with standardized romanization*, and almost certainly for accented roman characters. Though this is possibly not something to handle in the Swift project at all; may be better suited to an IDE.

* …although then what gets matched for し: "si" or "shi"? I think anything we do for a non-Roman alphabet should be driven by a native speaker and/or localization expert, not what we think is right.

swift-ci commented 8 years ago

Comment by Maxwell Swadling (JIRA)

I agree it should depend on the user's locale, so code completion options might need a locale setting. A client could use Foundation to guess the locale from the open document and if none is provided default to none. The locale would be passed straight through to ICU. I think ICU's transliterator definition should be sufficient for correctness (and consistent with other applications!).