<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Updating Autocomplete Definitions: Best Practices?]]></title><description><![CDATA[<p dir="auto">I’m compiling a new autocomplete XML file for PHP. The current one that’s still bundled in was <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/installer/APIs/php.xml" rel="nofollow ugc">compiled in 2010</a>, which puts it two major versions behind (PHP 5.3.1 to be exact). I notice that there have been some additions. Still, on a quick diff of what I’ve parsed from the current manual and the old definitions, there are ~1000 removed and ~1500 added functions. So that’s a lot of missed suggestions there.</p>
<p dir="auto">I still need add in control structures and magic methods (that are not included, <code>switch, return, __construct()</code>  et al), and scrape up all the functions that are not listed under <code>function.*</code> but in the likes of <a href="https://www.php.net/mysqli_query" rel="nofollow ugc">mysqli::query, mysqli_query</a> as “object-oriented style” and “procedural style”, so-called. Which brings me to my question. I’m reading the <a href="https://npp-user-manual.org/docs/auto-completion/" rel="nofollow ugc">auto-completion docs</a> and there’s this:</p>
<blockquote>
<p dir="auto">The basic character set used to recognize keywords is made of letters a-z, A-Z, digits 0-9, and the underscore _. Punctuation might work for auto-completion; however, if you want to use the parameter hints, you should not use punctuation in the keyword name.</p>
</blockquote>
<p dir="auto">An example from the PHP manual on <code>mysqli_query</code>:</p>
<pre><code>// Object-oriented style
public mysqli::query( string $query, int $result_mode = MYSQLI_STORE_RESULT) : mysqli_result|bool

// Procedural style
mysqli_query( mysqli $mysql, string $query, int $result_mode = MYSQLI_STORE_RESULT) : mysqli_result|bool
</code></pre>
<p dir="auto">Obviously <code>::</code> are punctuation. This would mean that e.g. <code>mysqli::query</code> as a keyword would disable parameter hints. Tested and indeed so it does. Also to note, the “procedural” variant typically has a different signature (with an object passed as the first argument).</p>
<p dir="auto">Then, what’s the preferred way of handling these situations? Ignore the <code>::</code> variant? Or include it and let the hints not be shown? In any case,  the <code>::</code> versions are rarely (I think?) used for static calls with the literal class name, and it’s really only the class name (and constructor signature?) that’s conceivably helpful to include in autocomplete.</p>
<p dir="auto">Also, there are any number of built-in classes with their methods that don’t have an “alternative access” variant. Example:</p>
<pre><code>public PDOStatement::bindParam( string|int $param, mixed &amp;$var, int $type = PDO::PARAM_STR, int $maxLength = 0, mixed $driverOptions = null) : bool
</code></pre>
<p dir="auto">I’d be inclined to add <code>PDOStatement</code> as a separate keyword. This leaves the question of what to do with <code>bindParam()</code>. In this case there’s no collision, so it <em>could</em> go in, an orphan with its parameter hints.  However e.g. <code>PDO::prepare</code> and <code>mysqli::prepare</code> have different signatures, and doubtless there are plenty more like that. And damned if I’ll be manually curating collisions for this. Also, adding in each method from each built-in class would conceivably create a lot of suggestion noise.</p>
<p dir="auto">In any case, it seems that all the built-in class names (<a href="https://www.php.net/manual/en/book.spl.php" rel="nofollow ugc">SPL</a>) deserve to be included in the definitions on their own. Anybody feel like typing <a href="https://www.php.net/manual/en/class.recursivecallbackfilteriterator.php" rel="nofollow ugc"><code>new RecursiveCallbackFilterIterator()</code></a> a couple of times over huh?</p>
<p dir="auto"><strong>Then, any feedback welcome on best practices here.</strong> While I’m at it and the scripts are still warm, I might as well scrape up current CSS and JS/ES6 definitions and update them. Seem a bit dated as well. To be continued. Thanks for all the great work with NP++.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22418/updating-autocomplete-definitions-best-practices</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 06:16:15 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22418.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Jan 2022 16:12:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Updating Autocomplete Definitions: Best Practices? on Tue, 25 Jan 2022 14:02:27 GMT]]></title><description><![CDATA[<p dir="auto">Vote to adding <a href="https://community.notepad-plus-plus.org/topic/22389/custom-user-adapters-for-autocompletion/">Custom/user adapters for autocompletion</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/73284</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73284</guid><dc:creator><![CDATA[WinterSilence]]></dc:creator><pubDate>Tue, 25 Jan 2022 14:02:27 GMT</pubDate></item><item><title><![CDATA[Reply to Updating Autocomplete Definitions: Best Practices? on Mon, 24 Jan 2022 11:21:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cmswares" aria-label="Profile: cmswares">@<bdi>cmswares</bdi></a> said in <a href="/post/73186">Updating Autocomplete Definitions: Best Practices?</a>:</p>
<blockquote>
<p dir="auto">Obviously <code>::</code> are punctuation. This would mean that e.g. <code>mysqli::query</code> as a keyword would disable parameter hints. Tested and indeed so it does. Also to note, the “procedural” variant typically has a different signature (with an object passed as the first argument).</p>
</blockquote>
<p dir="auto">If you did not set the <code>Environment</code> tag, then <code>:</code> is not matched. Set <code>additionalWordChar=":"</code> attribute to include the <code>:</code> as a autocomplete character. I also set <code>ignoreCase="no"</code> as PHP is case sensitive IIRC. Remove <code>ignoreCase="no"</code> if you like as it was not set previously.</p>
<p dir="auto">Try this example as <code>php.xml</code>:</p>
<pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;NotepadPlus&gt;
	&lt;AutoComplete&gt;
		&lt;Environment ignoreCase="no" additionalWordChar=":"/&gt;
		&lt;KeyWord name="mysqli::query" func="yes"&gt;
			&lt;Overload retVal="mysqli_result|bool"&gt;
				&lt;Param name="string $query"/&gt;
				&lt;Param name="int $result_mode = MYSQLI_STORE_RESULT"/&gt;
			&lt;/Overload&gt;
		&lt;/KeyWord&gt;
		&lt;KeyWord name="mysqli_query" func="yes"&gt;
			&lt;Overload retVal="mysqli_result|bool"&gt;
				&lt;Param name="mysqli $mysql"/&gt;
				&lt;Param name="string $query"/&gt;
				&lt;Param name="int $result_mode = MYSQLI_STORE_RESULT"/&gt;
			&lt;/Overload&gt;
		&lt;/KeyWord&gt;
	&lt;/AutoComplete&gt;
&lt;/NotepadPlus&gt;
</code></pre>
<p dir="auto">Both object oriented and procedural may cause confusion. The current <code>php.xml</code> seems to be procedural. I rarely use PHP so do not have a worthy opinion.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73216</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73216</guid><dc:creator><![CDATA[mpheath]]></dc:creator><pubDate>Mon, 24 Jan 2022 11:21:47 GMT</pubDate></item><item><title><![CDATA[Reply to Updating Autocomplete Definitions: Best Practices? on Sun, 23 Jan 2022 22:16:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cmswares" aria-label="Profile: cmswares">@<bdi>cmswares</bdi></a> said in <a href="/post/73186">Updating Autocomplete Definitions: Best Practices?</a>:</p>
<blockquote>
<p dir="auto">Also to note, the “procedural” variant typically has a different signature (with an object passed as the first argument).</p>
</blockquote>
<p dir="auto">That’s not a problem.  You can have multiple entries for a given function:<br />
<img src="/assets/uploads/files/1642975970869-8c8f8442-cae0-4713-a725-c5254f03c401-image.png" alt="8c8f8442-cae0-4713-a725-c5254f03c401-image.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1642975980467-6da00f0d-5a89-462a-ab12-c1a459153493-image.png" alt="6da00f0d-5a89-462a-ab12-c1a459153493-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">It might be that you’d be better served by an LSP feature, maybe like the one in development <a href="https://community.notepad-plus-plus.org/post/72225">mentioned here</a> – I am not an LSP expert, but I think that function-argument hints are one of the things they are supposed to handle.</p>
<p dir="auto">But yes, in general, as implemented today, I don’t know that you’ll be able to get around the <code>::</code> being punctuation.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73204</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73204</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sun, 23 Jan 2022 22:16:12 GMT</pubDate></item></channel></rss>