Page MenuHomePhabricator

Add a `getChildrenOfType` method to `AASTNode`
ClosedPublic

Authored by joshuaspence on Sep 24 2014, 11:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 10:45 PM
Unknown Object (File)
Fri, Nov 22, 7:32 PM
Unknown Object (File)
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
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 2631
Build 2635: [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.