Page MenuHomePhabricator

Add a `getChildrenOfType` method to `AASTNode`
ClosedPublic

Authored by joshuaspence on Sep 24 2014, 11:34 PM.
Tags
None
Referenced Files
F14078829: D10554.id.diff
Fri, Nov 22, 5:24 AM
Unknown Object (File)
Wed, Nov 20, 4:10 PM
Unknown Object (File)
Tue, Nov 12, 5:10 PM
Unknown Object (File)
Tue, Nov 12, 2:05 PM
Unknown Object (File)
Mon, Oct 28, 9:34 PM
Unknown Object (File)
Mon, Oct 28, 4:11 AM
Unknown Object (File)
Oct 21 2024, 7:43 AM
Unknown Object (File)
Oct 19 2024, 9:57 PM
Subscribers

Details

Summary

This method is similar to getChildren() but allows filtering based on $token->getTypeName().

Test Plan

See D10558.

Diff Detail

Repository
rPHU libphutil
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 2630
Build 2634: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

joshuaspence retitled this revision from to Add a `getChildrenOfType` method to `AASTNode`.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
joshuaspence edited edge metadata.

Add some more methods

joshuaspence retitled this revision from Add a `getChildrenOfType` method to `AASTNode` to Add a few methods to `AASTNode`.Sep 25 2014, 2:46 AM

(Let me know if you want me to split this into separate diffs)

joshuaspence retitled this revision from Add a few methods to `AASTNode` to Add a few methods to `AASTNode` and `AASTToken`.Sep 25 2014, 2:57 AM
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
epriestley edited edge metadata.

It looks like D10558 only actually needs something like getNextSemanticToken(). Maybe that's cleaner?

I think you could even getNextToken(), make sure it's isSemantic(), and then use it (i.e., "don't do anything if the next token is whitespace or a comment").

Offhand, one minor issue here is that a semantic token range is potentially the entire file.

These generally seem fine, but maybe consider a simpler approach if there aren't other use cases or you haven't already dismissed it.

This revision is now accepted and ready to land.Sep 25 2014, 1:25 PM

getNextToken() sounds reasonable... possibly I could do the following in D10558 and avoid the need to change AASTNode at all:

$after = last($value->getTokens())->getNextToken();

Actually, getChildrenOfType is still required.

joshuaspence retitled this revision from Add a few methods to `AASTNode` and `AASTToken` to Add a `getChildrenOfType` method to `AASTNode`.Sep 25 2014, 9:16 PM
joshuaspence updated this object.
joshuaspence edited edge metadata.
joshuaspence retitled this revision from Add a `getChildrenOfType` method to `AASTNode` to Add a few methods to `AASTNode` and `AASTToken`.
joshuaspence updated this object.

We only need `getChildrenOfType

joshuaspence retitled this revision from Add a few methods to `AASTNode` and `AASTToken` to Add a `getChildrenOfType` method to `AASTNode`.Sep 25 2014, 9:18 PM
joshuaspence updated this object.
This revision was automatically updated to reflect the committed changes.