---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# LinterCheckAstNode - スコープ指定、グローバル

# LinterCheckAstNode - スコープ指定、グローバル {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：4分

LinterCheckAstNode API は、リンターチェックで抽象構文ツリー (AST) ノードの詳細を取得するためのメソッドを提供します。

この API は インスタンススキャン (com.glide.instance_scan) プラグインに含まれており、 `sn_instance_scan` 名前空間で実行されます。詳細については、「 [Instance Scan」](https://www.servicenow.com/docs/access?context=hs-landing-page&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)を参照してください。

このクラスのメソッドを使用して、\[[リンターチェック\] フォーム](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)の \[スクリプト\] フィールドにコードを追加することで、AST ノードタイプのリンターチェックを実行します。詳細については、「 [高度なリンターチェックスクリプト」](https://www.servicenow.com/docs/access?context=hs-linter-check-scripts&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)を参照してください。

リンターチェックを作成して、スクリプトの問題を特定します。リンターチェックがレコードで実行されると、そのコードの抽象構文ツリーが生成されます。抽象構文ツリーを使用して、コードの問題を分析できます。

この API のメソッドにアクセスするには、インスタンススキャン engine.rootNode オブジェクトを使用します。

## LinterCheckAstNode - getNameIdentifier() {#ariaid-title2}

名前ノードタイプの文字列値を取得します。名前ノードは、関数名や変数名など、キーワードではない単純な識別子を表します。
{#LinterCheckAN-getNameIdentifier__table_ckd_hxt_4pb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 1. パラメーター]

{#LinterCheckAN-getNameIdentifier__table_ckd_hxt_4pb} {#LinterCheckAN-getNameIdentifier__table_dkd_hxt_4pb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | リンターオブジェクトが名前ノードタイプの場合は、名前を文字列として返します。それ以外の場合は null です。 |
[表 : 2. 返される内容]

{#LinterCheckAN-getNameIdentifier__table_dkd_hxt_4pb}  
次の例では、リンターチェックで Findings API の [incrementWithNode()](https://servicenow-prod.fluidtopics.net/V4stA35Uwb6CYCitT7JRmQ#Findings-incrementWithNode_O "現在の検出結果がリンターチェックのものである場合、このメソッドは、現在の結果数をインクリメントし、同時にリンターノードオブジェクトを検出結果に渡します。") メソッドを使用しています。このメソッドは、 [リンターチェックフォーム](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)の \[スクリプト\] フィールドで使用します。

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-getNameIdentifier__cBlock-instScan-linter-increment}

## LinterCheckAstNode - getParent() {#ariaid-title3}

アクセスされたノードの親ノードオブジェクトを取得します。
{#LinterCheckAN-getParent__table_ckd_hxt_4pb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 3. パラメーター]

{#LinterCheckAN-getParent__table_ckd_hxt_4pb} {#LinterCheckAN-getParent__table_dkd_hxt_4pb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | アクセスされたノードの親ノードオブジェクト。 |
[表 : 4. 返される内容]

{#LinterCheckAN-getParent__table_dkd_hxt_4pb}  
次の例では、リンターチェックで Findings API の [incrementWithNode()](https://servicenow-prod.fluidtopics.net/V4stA35Uwb6CYCitT7JRmQ#Findings-incrementWithNode_O "現在の検出結果がリンターチェックのものである場合、このメソッドは、現在の結果数をインクリメントし、同時にリンターノードオブジェクトを検出結果に渡します。") メソッドを使用しています。このメソッドは、 [リンターチェックフォーム](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)の \[スクリプト\] フィールドで使用します。

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-getParent__cBlock-instScan-linter-increment}

## LinterCheckAstNode - getTypeName() {#ariaid-title4}

アクセスされたノードのタイプを取得します。
{#LinterCheckAN-getTypeName__table_ckd_hxt_4pb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 5. パラメーター]

{#LinterCheckAN-getTypeName__table_ckd_hxt_4pb} {#LinterCheckAN-getTypeName__table_dkd_hxt_4pb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | アクセスされたノードのタイプ。たとえば、ソースの関数呼び出しは、タイプ名「`CALL`」のノードとしてトークン化されます。 |
[表 : 6. 返される内容]

{#LinterCheckAN-getTypeName__table_dkd_hxt_4pb}  
次の例では、リンターチェックで Findings API の [incrementWithNode()](https://servicenow-prod.fluidtopics.net/V4stA35Uwb6CYCitT7JRmQ#Findings-incrementWithNode_O "現在の検出結果がリンターチェックのものである場合、このメソッドは、現在の結果数をインクリメントし、同時にリンターノードオブジェクトを検出結果に渡します。") メソッドを使用しています。このメソッドは、 [リンターチェックフォーム](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)の \[スクリプト\] フィールドで使用します。

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-getTypeName__cBlock-instScan-linter-increment}

## LinterCheckAstNode - visit(関数 callbackFunction) {#ariaid-title5}

このノードから始まるサブツリー内の各ノードにアクセスし、指定されたコールバック関数を各ノードで実行します。
{#LinterCheckAN-visit_F__table_vjz_t4s_spb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| callbackFunction | 関数 | このノードのサブツリー内の各ノードで実行されるコールバック関数。このコールバック関数は、アクセス先ノードとなるパラメーターとしてノードを取ります。 |
[表 : 7. パラメーター]

{#LinterCheckAN-visit_F__table_vjz_t4s_spb} {#LinterCheckAN-visit_F__table_qky_bxs_spb__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 8. 返される内容]

{#LinterCheckAN-visit_F__table_qky_bxs_spb}  
次の例では、リンターチェックで Findings API の [incrementWithNode()](https://servicenow-prod.fluidtopics.net/V4stA35Uwb6CYCitT7JRmQ#Findings-incrementWithNode_O "現在の検出結果がリンターチェックのものである場合、このメソッドは、現在の結果数をインクリメントし、同時にリンターノードオブジェクトを検出結果に渡します。") メソッドを使用しています。このメソッドは、 [リンターチェックフォーム](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)の \[スクリプト\] フィールドで使用します。

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-visit_F__cBlock-instScan-linter-increment}

