<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>runtime/queries/ecma/README.md - fork/helix @ 25.07</title>
<meta name="description" content="runtime/queries/ecma/README.md in fork/helix at 25.07.">
<meta property="og:title" content="runtime/queries/ecma/README.md - fork/helix @ 25.07">
<meta property="og:description" content="runtime/queries/ecma/README.md in fork/helix at 25.07.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="25.07" data-tip="5cda70e86637c376bdfaaf3383872e44d7622ff8">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/helix</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/helix</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Gammut</span><span class="commit-message" data-commit="607b426e269b17f4ad32dca9c612c4a9f8541766">Refactor queries for ecma based languages (#7207)</span><span class="snapshot-sha sha" data-commit="607b426e269b17f4ad32dca9c612c4a9f8541766">607b426e</span><time datetime="2023-07-09T11:35:32-05:00" title="2023-07-09 11:35:32 -0500">2023-07-09</time></p>
<header class="topbar"><details class="switcher"><summary>25.07</summary><div class="menu"><strong>branches</strong><a href="/fork/helix/ref/master/">master</a><strong>tags</strong><a href="/fork/helix/ref/23.05/">23.05</a><a href="/fork/helix/ref/23.10/">23.10</a><a href="/fork/helix/ref/24.03/">24.03</a><a href="/fork/helix/ref/24.07/">24.07</a><a href="/fork/helix/ref/25.01/">25.01</a><a href="/fork/helix/ref/25.01.1/">25.01.1</a><a class="current" href="/fork/helix/ref/25.07/">25.07</a><a href="/fork/helix/ref/25.07.1/">25.07.1</a><a class="all" href="/fork/helix/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/helix/">helix</a> / <a href="/fork/helix/ref/25.07/tree/runtime/">runtime</a> / <a href="/fork/helix/ref/25.07/tree/runtime/queries/">queries</a> / <a href="/fork/helix/ref/25.07/tree/runtime/queries/ecma/">ecma</a> / <span class="cur">README.md</span></nav>
<span class="view-stats"><span>1.3 KiB</span><span>14 lines</span></span><span class="actions"><a class="raw" href="/fork/helix/raw/b891f24bbc9344c481d931b8da775c7e9a74c1de/runtime/queries/ecma/README.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1>Inheritance model for ecma-based languages</h1>
<p>Ecma-based languages share many traits. Because of this we want to share as many queries as possible while avoiding nested inheritance that can make query behaviour unpredictable due to unexpected precedence.</p>
<p>To achieve that, there are "public" and "private" versions for javascript, jsx, and typescript query files, that share the same name, but the "private" version name starts with an underscore (with the exception of ecma, that already exists as a sort of base "private" language). This allows the "private" versions to host the specific queries of the language excluding any <code>; inherits</code> statement, in order to make them safe to be inherited by the "public" version of the same language and other languages as well. The tsx language doesn't have a "private" version given that currently it doesn't need to be inherited by other languages.</p>
<table><thead><tr><th>Language</th><th>Inherits from</th></tr></thead><tbody>
<tr><td>javascript</td><td>_javascript, ecma</td></tr>
<tr><td>jsx</td><td>_jsx, _javascript, ecma</td></tr>
<tr><td>typescript</td><td>_typescript, ecma</td></tr>
<tr><td>tsx</td><td>_jsx, _typescript, ecma</td></tr>
</tbody></table>
<p>If you intend to add queries to any of the ecma-based languages above, make sure you add them to the correct private language they belong to, so that other languages down the line can benefit from them.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>Inheritance model for ecma-based languages</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">Ecma-based languages share many traits. Because of this we want to share as many queries as possible while avoiding nested inheritance that can make query behaviour unpredictable due to unexpected precedence.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">To achieve that, there are &quot;public&quot; and &quot;private&quot; versions for javascript, jsx, and typescript query files, that share the same name, but the &quot;private&quot; version name starts with an underscore (with the exception of ecma, that already exists as a sort of base &quot;private&quot; language). This allows the &quot;private&quot; versions to host the specific queries of the language excluding any `; inherits` statement, in order to make them safe to be inherited by the &quot;public&quot; version of the same language and other languages as well. The tsx language doesn&#39;t have a &quot;private&quot; version given that currently it doesn&#39;t need to be inherited by other languages.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">| Language   | Inherits from           |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">| ---------- | ----------------------- |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">| javascript | _javascript, ecma       |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text">| jsx        | _jsx, _javascript, ecma |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">| typescript | _typescript, ecma       |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">| tsx        | _jsx, _typescript, ecma |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text">If you intend to add queries to any of the ecma-based languages above, make sure you add them to the correct private language they belong to, so that other languages down the line can benefit from them.</span></span></pre></div></div>
</main>
</body>
</html>
