8.3.2 필드 접근 완성(Field access completion)

8.3.2 필드 접근 완성(Field access completion)

필드 완성은 점 . 문자 뒤에서 촉발되어 주어진 타입에서 사용할 수 있는 필드를 나열합니다. 컴파일러는 완성 지점까지의 모든 것을 파싱·타이핑한 뒤 관련 정보를 stderr로 출력합니다:

class Main {
  public static function main() {
    trace("Hello".|
  }
}

이 파일을 Main.hx로 저장하면, haxe --display Main.hx@0 명령으로 완성을 호출할 수 있어요. 출력은 다음과 비슷합니다(간결함을 위해 여러 필드를 생략하고 가독성을 위해 형식 개선):

n="length">
  Int

    The number of characters in `this` String.

 n="charAt">
  index : Int -> String

    Returns the character at position `index` of `this` String.
    If `index` is negative or exceeds `this.length`, the empty String
    "" is returned.

 n="charCodeAt">
  index : Int -> Null<Int>

    Returns the character code at position `index` of `this` String.
    ...

각 항목은 n(필드 이름)과 그 타입, 그리고 설명을 포함해 IDE가 파싱해 완성 목록을 만들 수 있습니다.

출처: Field access completion

본문

필드 완성

. 뒤에서 haxe --display Main.hx@0로 촉발하면 해당 타입의 사용 가능한 필드가 이름·타입·설명과 함께 stderr로 출력됩니다. IDE는 이를 파싱해 완성 목록을 만듭니다.

더 알아보기