Commit graph

230 commits

Author SHA1 Message Date
Jimmy Lai
3965e4601b [doc] add docstring to QualifiedName 2019-10-09 11:32:08 -07:00
Jimmy Lai
5f8f5c5624 address review feedback form #94 2019-10-08 15:48:59 -07:00
Jimmy Lai
b690c591e5 [doc] add Scope Analysis tutorial 2019-10-08 15:48:59 -07:00
Jimmy Lai
9e7a9879ea [doc] fix expression context usage in scope api and explain access don't handle simple string typing access 2019-10-08 15:48:59 -07:00
Jimmy Lai
dea7c20794 add warning box to clarify Scope metadata only handles local variable 2019-10-08 15:48:59 -07:00
Jimmy Lai
9f8e69b1b3 [doc] use libcst.metadata for referencing metadata classes and add docstring for Scope magic functions 2019-10-08 15:48:59 -07:00
Jimmy Lai
c9dc3bfa70 address review feedback in #94 2019-10-08 15:48:59 -07:00
Jimmy Lai
13637b7d58 add docs for Assignments and Accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
855232e24f test Access.referents and Assignment.references 2019-10-08 15:48:59 -07:00
Jimmy Lai
65cc4d23bd add test case for Assignments and Accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
392426d6bd add Scope.record_access and Access.record_assignment 2019-10-08 15:48:59 -07:00
Jimmy Lai
ee14c48e46 add Scope.assignments and Scope.accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
7a2d0048c7 add deprecation message to Assignment.accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
120fd04ce2 rename Assignment.accesses as Assignment.references and add Accesses/Assignments 2019-10-08 15:48:59 -07:00
Jimmy Lai
c92bc02d8c rewrite ExpressionContextProvider to handle nested List/Tuple and Attribute 2019-10-04 15:16:55 -07:00
Jennifer Taylor
8a8ea4b27b Upgrade Pyre to 0.32.
This fixes a TODO, removes several ignore statements and most importantly, addresses a massive speed regression triggered by importing matchers.
2019-10-04 11:05:37 -07:00
Jennifer Taylor
27b5a1d286 Improve removing nodes from parents in LibCST.
Add a RemoveFromParent() function as a convenience to returning RemovalSentinel.REMOVE.
Introduce a `deep_remove()` on CSTNode analogous to `deep_replace()` but for removing.
2019-10-02 15:43:48 -07:00
Jennifer Taylor
2383bea74b Export ProviderT so it can be used to type METADATA_DEPENDENCIES. 2019-10-02 15:15:18 -07:00
Jennifer Taylor
9fa2612673 Implement deep_replace helper on CSTNode. 2019-10-02 14:00:20 -07:00
Jennifer Taylor
e8c19a983c Fix issue with matchers that combine both @call and @visit decorators. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
90ec997687 Fix warning in docs creation relating to scope provider. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
e2868f703b Add documentation to matchers. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
271566bdbf Add a .remove() method to CSTNode as a convenience to returning RemovalSentinel.REMOVE 2019-10-01 15:28:58 -07:00
Jimmy Lai
1488126df5 fix import asname support in get_qualified_names_for and add tests/docs 2019-10-01 14:24:20 -07:00
Jimmy Lai
826765bd93 add QualifiedNameProvider 2019-10-01 14:24:20 -07:00
Jimmy Lai
cd25f15ff7 consolidate metadata imports 2019-10-01 13:40:24 -07:00
Jimmy Lai
fc2d8f8697 avoid redefine builtin function range 2019-09-30 14:38:25 -07:00
Jimmy Lai
9945a9b970 merge isinstance calls to be more simple and fast 2019-09-30 14:38:25 -07:00
Jimmy Lai
6680c2d05f add nested function/class test cases and documents to Qualified Name Metadata 2019-09-30 12:03:19 -07:00
Jimmy Lai
1bdce26bf3 add QualifiedNameSource.BUILTIN and address review comments 2019-09-30 12:03:19 -07:00
Jimmy Lai
50b3c61794 add docs of get_qualified_names_for 2019-09-30 12:03:19 -07:00
Jimmy Lai
9fcf84cf2c add QualifiedName and QualifiedNameSource enum 2019-09-30 12:03:19 -07:00
Jimmy Lai
881348df27 add get_fully_qualified_names_for tests for subscript and SimpleString typing 2019-09-30 12:03:19 -07:00
Jimmy Lai
e24ca294b6 use LocalScope in ScopeVisitor._new_scope to simplify typing 2019-09-30 12:03:19 -07:00
Jimmy Lai
894a0f7424 add local assignment (non-import assignment) supports to get_fully_qualified_names_for 2019-09-30 12:03:19 -07:00
Jimmy Lai
3123691788 add helper Scope.get_fully_qualified_names_for 2019-09-30 12:03:19 -07:00
Jennifer Taylor
85417b957d Initial export of matchers into LibCST. 2019-09-27 11:39:11 -07:00
Jimmy Lai
f2303cecd3 remove accidentally committed files. 2019-09-26 17:39:16 -07:00
Jimmy Lai
4cde536678 add more test cases to ParentNodeProviderTest 2019-09-26 17:39:16 -07:00
Jimmy Lai
db6092dffd add docs of ParentNodeProvider 2019-09-26 17:39:16 -07:00
Jimmy Lai
132549db56 add parent node metadata provider 2019-09-26 17:39:16 -07:00
Jimmy Lai
643acd7771 remove redundant constructor 2019-09-26 17:39:16 -07:00
Jennifer Taylor
1d483ef787 Fix deep_clone behavior regarding BaseLeaf nodes.
We used _visit_and_replace_children to implement deep_clone, which was already
bad since it relied on the implicit behavior of _visit_and_replace_children to
make a copy on visit. If we fix that behavior in the future, deep_Clone would
have broken. However, its even more broken, because nodes that subclass from
BaseLeaf define their _visit_and_replace_children as returning self. So, not
only is this a bad coupling, but its also broken. Implement deep_clone properly
here.
2019-09-25 12:36:33 -07:00
Jennifer Taylor
de1db7f0f6 Add a test to verify that deep_clone works. 2019-09-25 12:36:33 -07:00
Jennifer Taylor
93ed095c9e Fix non-unique tree generated by LibCST in some circumstances.
When parsing, we don't always fill in defaults unless we have a good reason to. That, coupled with the fact that we use dataclasses that allow you to set a default on creation instead of runtime construction means that we accidentally aliased a whole bunch of SimpleWhitespace nodes. Fix that by switching to the datalasses field() method which allows runtime evaluation. We do this by creating a simple (untyped, unfortunately) helper on CSTNode which makes for easier creation.
2019-09-25 12:36:33 -07:00
Jennifer Taylor
a6bdc9d03d Add test case for uniqueness of resulting tree when parsing. 2019-09-25 12:36:33 -07:00
Jennifer Taylor
fb4785cfa1 Bump pyre version to 0.0.30.
This introduces a few new gotchas (namely attribute access and a bug with
Union[Callable]), but it also removes a whole host of pyre-fixmes and gets us
updated to a release of pyre that came out after May.
2019-09-25 12:04:33 -07:00
Jennifer Taylor
fc430343b5 Fix internal underscore convention.
Standardize on the convention that private modules (those we don't expect people to directly import) are prefixed with an underscore. Everything under a directory/module that has an underscore is considered private, unless it is re-exported from a non-underscored module. Most things are exported from libcst directly, but there are a few things in libcst.tool, libcst.codegen and libcst.metadata that are namedspaced as such.
2019-09-17 13:52:42 -07:00
Jimmy Lai
02a831ff27 [doc] fix some typos and add simple Scope Provider introduction 2019-09-16 19:53:22 -07:00
Jimmy Lai
b4851a60a1 [doc] add scope introduction and examples 2019-09-16 19:53:22 -07:00