Skip to content

Commit

Permalink
Rename “primary topic reference” to “topic reference”
Browse files Browse the repository at this point in the history
The “primary” part was a vestige of the old smart-mix
pipeline proposal.
  • Loading branch information
js-choi committed Apr 9, 2021
1 parent 43d2965 commit da02613
Show file tree
Hide file tree
Showing 46 changed files with 89 additions and 175 deletions.
2 changes: 1 addition & 1 deletion packages/babel-generator/src/generators/types.ts
Expand Up @@ -236,6 +236,6 @@ export function DecimalLiteral(this: Printer, node: t.DecimalLiteral) {
this.word(node.value + "m");
}

export function PipelinePrimaryTopicReference(this: Printer) {
export function TopicReference(this: Printer) {
this.token("#");
}
8 changes: 4 additions & 4 deletions packages/babel-parser/src/parser/error-message.js
Expand Up @@ -131,12 +131,12 @@ export const ErrorMessages = Object.freeze({
PatternHasMethod: "Object pattern can't contain methods",
PipeBodyCannotBeArrow:
'Unexpected arrow "=>" after pipeline body; arrow function acting as pipe body must be parenthesized due to operator precedence',
PipeTopicRequiresHackPipes:
"Topic reference is used, but the pipelineOperator plugin was not passed a 'proposal': 'hack' option.",
PipeTopicUnbound:
"Topic reference is unbound; it must be inside a Hack-style pipe body",
PipeTopicUnused:
"Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once",
PrimaryTopicNotAllowed:
"Topic reference is unbound; it must be inside a Hack-style pipe body",
PrimaryTopicRequiresHackPipes:
"Topic reference is used, but the pipelineOperator plugin was not passed a 'proposal': 'hack' option.",
PrivateInExpectedIn:
"Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`)",
PrivateNameRedeclaration: "Duplicate private name #%0",
Expand Down
14 changes: 7 additions & 7 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -1150,17 +1150,17 @@ export default class ExpressionParser extends LValParser {
node = this.startNode();

if (this.getPluginOption("pipelineOperator", "proposal") !== "hack") {
this.raise(node.start, Errors.PrimaryTopicRequiresHackPipes);
this.raise(node.start, Errors.PipeTopicRequiresHackPipes);
}

this.next();

if (!this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) {
this.raise(node.start, Errors.PrimaryTopicNotAllowed);
if (!this.topicReferenceIsAllowedInCurrentContext()) {
this.raise(node.start, Errors.PipeTopicUnbound);
}

this.registerTopicReference();
return this.finishNode(node, "PipelinePrimaryTopicReference");
return this.finishNode(node, "TopicReference");
}

// https://tc39.es/proposal-private-fields-in-in
Expand Down Expand Up @@ -2475,7 +2475,7 @@ export default class ExpressionParser extends LValParser {
throw this.raise(this.state.start, Errors.PipeBodyCannotBeArrow);
}
// A Hack pipe body must use the topic reference at least once.
else if (!this.topicReferenceWasUsedInCurrentTopicContext()) {
else if (!this.topicReferenceWasUsedInCurrentContext()) {
this.raise(startPos, Errors.PipeTopicUnused);
}
}
Expand Down Expand Up @@ -2547,11 +2547,11 @@ export default class ExpressionParser extends LValParser {
this.state.topicContext.maxTopicIndex = 0;
}

primaryTopicReferenceIsAllowedInCurrentTopicContext(): boolean {
topicReferenceIsAllowedInCurrentContext(): boolean {
return this.state.topicContext.maxNumOfResolvableTopics >= 1;
}

topicReferenceWasUsedInCurrentTopicContext(): boolean {
topicReferenceWasUsedInCurrentContext(): boolean {
return (
this.state.topicContext.maxTopicIndex != null &&
this.state.topicContext.maxTopicIndex >= 0
Expand Down
Expand Up @@ -27,7 +27,7 @@
"type": "BinaryExpression",
"start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6}}
},
"operator": "+",
Expand Down
Expand Up @@ -23,7 +23,7 @@
"type": "BinaryExpression",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}
},
"operator": "+",
Expand Down
Expand Up @@ -33,7 +33,7 @@
},
"operator": "+",
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}
}
}
Expand Down
Expand Up @@ -34,7 +34,7 @@
"type": "BinaryExpression",
"start":16,"end":21,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":21}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}}
},
"operator": "+",
Expand Down
Expand Up @@ -38,7 +38,7 @@
"type": "AwaitExpression",
"start":36,"end":43,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":21}},
"argument": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":42,"end":43,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":21}}
}
}
Expand Down
Expand Up @@ -62,7 +62,7 @@
},
"operator": "<",
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":36,"end":37,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":37}}
}
}
Expand Down
Expand Up @@ -63,7 +63,7 @@
"kind": "const"
},
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":61,"end":62,"loc":{"start":{"line":2,"column":38},"end":{"line":2,"column":39}}
},
"body": {
Expand Down
Expand Up @@ -42,7 +42,7 @@
"name": "i"
},
"init": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}}
}
}
Expand All @@ -64,7 +64,7 @@
"name": "i"
},
{
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":43,"end":44,"loc":{"start":{"line":1,"column":43},"end":{"line":1,"column":44}}
}
]
Expand All @@ -79,7 +79,7 @@
"name": "i"
},
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":52,"end":53,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":53}}
}
},
Expand Down
Expand Up @@ -35,7 +35,7 @@
"name": "e"
},
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}}
},
"body": {
Expand Down
Expand Up @@ -36,7 +36,7 @@
"name": "e"
},
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}}
},
"body": {
Expand Down
Expand Up @@ -54,7 +54,7 @@
"type": "ExpressionStatement",
"start":42,"end":44,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":44}},
"expression": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":42,"end":43,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":43}}
}
},
Expand Down
Expand Up @@ -46,7 +46,7 @@
"type": "ExpressionStatement",
"start":34,"end":36,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":36}},
"expression": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35}}
}
}
Expand Down
Expand Up @@ -38,7 +38,7 @@
"type": "ExpressionStatement",
"start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}},
"expression": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24}}
}
},
Expand Down
Expand Up @@ -30,7 +30,7 @@
"type": "IfStatement",
"start":14,"end":31,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":31}},
"test": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}}
},
"consequent": {
Expand Down
Expand Up @@ -43,7 +43,7 @@
"type": "ExpressionStatement",
"start":46,"end":48,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":14}},
"expression": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":46,"end":47,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":13}}
}
}
Expand All @@ -69,7 +69,7 @@
"type": "BinaryExpression",
"start":61,"end":66,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":17}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":61,"end":62,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":13}}
},
"operator": "+",
Expand Down Expand Up @@ -106,7 +106,7 @@
"type": "BinaryExpression",
"start":81,"end":87,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":19}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":81,"end":82,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":14}}
},
"operator": "+",
Expand Down
Expand Up @@ -30,7 +30,7 @@
"type": "SwitchStatement",
"start":16,"end":81,"loc":{"start":{"line":2,"column":2},"end":{"line":6,"column":3}},
"discriminant": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":24,"end":25,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11}}
},
"cases": [
Expand Down
Expand Up @@ -30,7 +30,7 @@
"type": "ExpressionStatement",
"start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}},
"expression": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}}
}
}
Expand Down
Expand Up @@ -129,7 +129,7 @@
},
"arguments": [
{
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":110,"end":111,"loc":{"start":{"line":4,"column":22},"end":{"line":4,"column":23}}
}
]
Expand Down
Expand Up @@ -56,7 +56,7 @@
},
"arguments": [
{
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":33,"end":34,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":20}}
}
]
Expand Down
Expand Up @@ -56,7 +56,7 @@
},
"arguments": [
{
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":33,"end":34,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":20}}
}
]
Expand Down
Expand Up @@ -39,7 +39,7 @@
},
"operator": "<",
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":25,"end":26,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":26}}
}
},
Expand Down
Expand Up @@ -29,7 +29,7 @@
},
"arguments": [
{
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}}
}
]
Expand Down
Expand Up @@ -35,7 +35,7 @@
"name": "x"
},
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24}}
}
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
},
"delegate": false,
"argument": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":39,"end":40,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":22}}
}
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
},
"operator": "|>",
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}
}
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
"type": "BinaryExpression",
"start":11,"end":21,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":21}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}}
},
"operator": "|>",
Expand Down
Expand Up @@ -49,7 +49,7 @@
},
"operator": "|>",
"right": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}}
}
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
"type": "BinaryExpression",
"start":11,"end":23,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":23}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}}
},
"operator": "|>",
Expand All @@ -57,7 +57,7 @@
},
"arguments": [
{
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}}
},
{
Expand All @@ -73,7 +73,7 @@
"type": "BinaryExpression",
"start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}}
},
"operator": ">",
Expand Down
Expand Up @@ -30,7 +30,7 @@
"parenStart": 5
},
"left": {
"type": "PipelinePrimaryTopicReference",
"type": "TopicReference",
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}
},
"operator": "|>",
Expand Down

0 comments on commit da02613

Please sign in to comment.