Commit graph

40 commits

Author SHA1 Message Date
Sebastián Ramírez
e9dc135ae4
Fix tiny typo in docs/source/metadata.rst (#1134)
* ✏️ Fix typo in metadata.rst

* ✏️ Fix typo
2024-05-03 22:27:20 +01:00
Sergii Dymchenko
0d087acdf6
Typo fix FullRepoManager (#1138) 2024-05-03 22:25:37 +01:00
Marcelo Trylesinski
f1b973f6b3
Fix pyre setup link in metadata.rst (#913) 2023-04-25 09:45:51 +01:00
Amethyst Reese
c876db6d2d Add new FilePathProvider
Caches file path information on the root `Module` node.
Resolves paths when caching, so they are always absolute paths.

Adds a new `chdir` helper to change working directory and automatically
revert to previous directory, which makes testing file paths with the
`"."` repo root easier.

ghstack-source-id: 3413905fc1
Pull Request resolved: https://github.com/Instagram/LibCST/pull/892
2023-03-13 18:33:46 -07:00
zzl
84da283604
Fix code example in metadata documentation. (#703)
Co-authored-by: zzl0 <zhuzhaolong0@mail.com>
2022-06-16 09:49:24 +01:00
Zsolt Dollenstein
1bd1c0890c
Add FullyQualifiedNameProvider (#465) 2021-03-26 17:15:57 +00:00
Luke Petre
4ab866e40f
Add BuiltinScope (#469)
* Add more builtin tests

* Introduce a BuiltinScope that sits above GlobalScope

* Address comments and fix lint

* Updating documentation

* Update scope illustration

* Add BuiltinScope to libcst.metadata

* Lazily create builtin assignments, update scope diagram
2021-03-24 12:12:56 -07:00
Zsolt Dollenstein
477a03e3a8
[ScopeProvider] Expose more granular Assignments and Accesses for dotted imports (#284) 2020-04-21 10:27:47 +01:00
Zsolt Dollenstein
bd31d3feac add docs and expose provider in libcst.metadata 2020-02-28 09:28:11 -08:00
Jennifer Taylor
b319312de3 Add docstring for CodemodTest. 2020-01-08 17:17:48 -08:00
Jimmy Lai
3c4c282bbe add documents for TypeInferenceProvider and FullRepoManager 2019-12-28 20:51:29 -08:00
Benjamin Woodruff
42c3f3f267 Add an unsafe_skip_copy option to MetadataWrapper
In certain cases (e.g. inside Instagram's lint framework) we know that
our tree originates from the parser, so we know that there shouldn't be
any duplicate nodes in our tree.

MetadataWrapper exists to copy the tree ensuring that there's no
duplicate nodes.

This diff provides an escape hatch on MetadataWrapper that allows us to
save a little time and avoid a copy when we know that it's safe to skip
the copy.

As part of this, I ran into some issues with `InitVar` and pyre, so I
removed `@dataclass` from the class. This means that this is techincally
a breaking change if someone depended on the MetadataWrapper being an
actual dataclass, but I think this is unlikely. I implemented `__repr__`
and added tests for hashing/equality behavior.
2019-10-29 13:35:38 -07:00
Benjamin Woodruff
e1c1d450ae Export CodePosition and CodeRange from metadata
While these classes are used by the codegen implementation, conceptually
they're part of `libcst.metadata`, so we should export them from
`libcst.metadata` instead of the top-level `libcst` package.
2019-10-18 14:30:33 -07:00
Benjamin Woodruff
94e40d84ac Reorder position providers in documentation
PositionProvider is the best choice in most cases, so it should come
before WhitespaceInclusivePositionProvider in the documentation.
2019-10-17 14:59:52 -07:00
Benjamin Woodruff
9d68a58c17 Rename position provider classes
I discussed the high-level idea here with @DragonMinded a few months
ago, but this isn't set in stone. If people have better ideas for names,
I'd love to hear it.

Publicly-Visible Changes
------------------------

- SyntacticPositionProvider is deprecated. The new name is
  PositionProvider.
- BasicPositionProvider is deprecated. The new name is
  WhitespaceInclusivePositionProvider.
- Documentation is updated to better explain these renamed providers and
  how to use them.

The prefixes "Syntactic" and "Basic" were pretty bad because they're
just concepts that we made up for LibCST.

The idea for the new names is that most users will want the
SyntacticPositionProvider, and so we should name things so that the user
will naturally gravitate towards the correct choice.

There's some argument that we shouldn't even bother exposing
WhitespaceInclusivePositionProvider, but we already need to implement it
as a fallback for PositionProvider, and it might be useful for some
niche use-cases.

Once we have another major version bump, we can remove the old class
names. The old class names have already be removed from the
documentation so that new users aren't tempted to use them.

Internal-Only Changes
---------------------

- `PositionProvider` is now `_PositionProviderUnion`. This type alias
  was never a public API (and probably never will be).
- `BasicCodegenState` is now
  `WhitespaceInclusivePositionProvidingCodegenState`.
- `SyntacticCodegenState` is now `PositionProvidingCodegenState`.
2019-10-17 14:59:52 -07:00
Benjamin Woodruff
3c92a7b367 Tweak wording/formatting of the scope provider intro
Explaining the implementation details of scopes to someone unfamiliar
with compilers can be tricky. Hopefully this helps.

- Rephrased the definition of a scope to be more applicable to Python
  (remove references to "blocks"), and made it use an example for
  (hopefully) better clarity.
- New scopes are also created for comprehensions.
- Set a fixed width (400px) for the scope diagram, since it was too
  large before.
- Tweaked some tenses.
- Add a final call to action: "LibCST allows you to inspect these
  scopes"
2019-10-15 18:02:51 -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
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
13637b7d58 add docs for Assignments and Accesses 2019-10-08 15:48:59 -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
6680c2d05f add nested function/class test cases and documents to Qualified Name Metadata 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
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
21e155e0aa [doc] use png file and fix typo 2019-09-16 19:53:22 -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
Jimmy Lai
213b335cd5 move metadata providers its data structures to libcst.metadata 2019-09-16 19:53:22 -07:00
Jimmy Lai
612cbb0a9e add docstring to ScopeProvider 2019-09-16 19:53:22 -07:00
Jimmy Lai
966ab81a36 add ScopeProvider document 2019-09-16 19:53:22 -07:00
jimmylai
70d6ca6513
[doc] improve metadata docs. (#50) 2019-08-28 13:41:31 -07:00
jimmylai
b19732938c
[metadata] add ExpressionContextProvider (#49)
* [metadata] add ExpressionContextProvider

* address comments
2019-08-27 19:07:28 -07:00
Ray Zeng
68699e21d7 Add more examples and improve docstrings 2019-08-16 10:34:30 -07:00
Ray Zeng
e2f2eafc59 Add extended example for metadata and fix some docstrings 2019-08-16 10:34:30 -07:00
Ray Zeng
fa6bb4942c Moved metadata usage example into usage.ipynb 2019-08-16 10:34:30 -07:00
Ray Zeng
d91a79220b Fix some typing and improve some docstrings for metadata 2019-08-16 10:34:30 -07:00
Ray Zeng
f0b6e6c37d Re-organize metadata documentation and add a usage example 2019-08-16 10:34:30 -07:00
Ray Zeng
63ff16cb47 Add more metadata documentation 2019-08-16 10:34:30 -07:00
Ray Zeng
79f0ebc2a4 Add sphinx docs to metadata modules 2019-08-16 10:34:30 -07:00