Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Require Rewrite again
Browse files Browse the repository at this point in the history
Summary:
Modify require feature response to return an array of ModuleMetadata instead of toplevel match_route, graphql etc.

The Require feature now returns a list of ModuleMetadata  found when parsing a file. Each module import is distinguished by type ModuletType which is added in this diff. The ModuleType describes the way in which a module is required. The enum values are fairly self-explanatory.

The new ModuleMetadata class contains a list of references where the module was required/imported/etc. These refs contain the call_range and the args_range of the statement.
The args_range represents the range of the import/require/reexport source  ie: const a = require(|'b'|);
The args_range represents the range of the import/require/reexport source. This is in keeping with what what the general require feature expects. ie: const a = require(|'b'|);

In addition, this diff adds reexported modules to the require feature. Reexported modules are referenced in an es6 reexport statement ie `export foo from 'bar'`.

Reviewed By: avp

Differential Revision: D24700998

fbshipit-source-id: f43a128454f0e131987ebf2dd05a914557bc9a49
  • Loading branch information
Calvin-Fernandez authored and facebook-github-bot committed Dec 29, 2020
1 parent 05b7eaf commit 1a10a4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/AST/ESTreeJSONDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class ESTreeJSONDumper {
if (locMode_ == LocationDumpMode::Range ||
locMode_ == LocationDumpMode::LocAndRange) {
json_.emitKey("range");
json_.openArray();
dumpSMRangeJSON(json_, rng, sm_->findBufferForLoc(rng.Start));
json_.closeArray();
}
}

Expand Down Expand Up @@ -457,10 +459,8 @@ void dumpSMRangeJSON(
rng.Start.getPointer() >= bufStart &&
rng.End.getPointer() <= buffer->getBufferEnd() &&
"The range must be within the buffer");
json.openArray();
json.emitValues(
{rng.Start.getPointer() - bufStart, rng.End.getPointer() - bufStart});
json.closeArray();
}

void dumpESTreeJSON(
Expand Down

0 comments on commit 1a10a4e

Please sign in to comment.