Skip to content

Commit

Permalink
Merge 93ca840 into 53145f7
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Jan 13, 2020
2 parents 53145f7 + 93ca840 commit 730e6aa
Show file tree
Hide file tree
Showing 41 changed files with 563 additions and 563 deletions.
12 changes: 6 additions & 6 deletions src/ast.js
Expand Up @@ -21,11 +21,11 @@ const Position = require("./ast/position");
* - [Constant](#constant)
* - [Identifier](#identifier)
* - [Reference](#reference)
* - [TypeReference](#classreference)
* - [ParentReference](#classreference)
* - [StaticReference](#classreference)
* - [SelfReference](#classreference)
* - [ClassReference](#classreference)
* - [TypeReference](#typereference)
* - [ParentReference](#parentreference)
* - [StaticReference](#staticreference)
* - [SelfReference](#selfreference)
* - [Name](#name)
* - [TraitUse](#traituse)
* - [TraitAlias](#traitalias)
* - [TraitPrecedence](#traitprecedence)
Expand Down Expand Up @@ -464,7 +464,6 @@ AST.prototype.checkNodes = function() {
require("./ast/catch"),
require("./ast/class"),
require("./ast/classconstant"),
require("./ast/classreference"),
require("./ast/clone"),
require("./ast/closure"),
require("./ast/comment"),
Expand Down Expand Up @@ -505,6 +504,7 @@ AST.prototype.checkNodes = function() {
require("./ast/lookup"),
require("./ast/magic"),
require("./ast/method"),
require("./ast/name"),
require("./ast/namespace"),
require("./ast/new"),
require("./ast/node"),
Expand Down
24 changes: 12 additions & 12 deletions src/ast/classreference.js → src/ast/name.js
Expand Up @@ -6,30 +6,30 @@
"use strict";

const Reference = require("./reference");
const KIND = "classreference";
const KIND = "name";

/**
* Defines a class reference node
* @constructor ClassReference
* @constructor Name
* @extends {Reference}
* @property {string} name
* @property {string} resolution
*/
const ClassReference = Reference.extends(KIND, function ClassReference(
const Name = Reference.extends(KIND, function Name(
name,
isRelative,
docs,
location
) {
Reference.apply(this, [KIND, docs, location]);
if (isRelative) {
this.resolution = ClassReference.RELATIVE_NAME;
this.resolution = Name.RELATIVE_NAME;
} else if (name.length === 1) {
this.resolution = ClassReference.UNQUALIFIED_NAME;
this.resolution = Name.UNQUALIFIED_NAME;
} else if (!name[0]) {
this.resolution = ClassReference.FULL_QUALIFIED_NAME;
this.resolution = Name.FULL_QUALIFIED_NAME;
} else {
this.resolution = ClassReference.QUALIFIED_NAME;
this.resolution = Name.QUALIFIED_NAME;
}
this.name = name.join("\\");
});
Expand All @@ -38,23 +38,23 @@ const ClassReference = Reference.extends(KIND, function ClassReference(
* This is an identifier without a namespace separator, such as Foo
* @constant {String} UNQUALIFIED_NAME
*/
ClassReference.UNQUALIFIED_NAME = "uqn";
Name.UNQUALIFIED_NAME = "uqn";
/**
* This is an identifier with a namespace separator, such as Foo\Bar
* @constant {String} QUALIFIED_NAME
*/
ClassReference.QUALIFIED_NAME = "qn";
Name.QUALIFIED_NAME = "qn";
/**
* This is an identifier with a namespace separator that begins with
* a namespace separator, such as \Foo\Bar. The namespace \Foo is also
* a fully qualified name.
* @constant {String} FULL_QUALIFIED_NAME
*/
ClassReference.FULL_QUALIFIED_NAME = "fqn";
Name.FULL_QUALIFIED_NAME = "fqn";
/**
* This is an identifier starting with namespace, such as namespace\Foo\Bar.
* @constant {String} RELATIVE_NAME
*/
ClassReference.RELATIVE_NAME = "rn";
Name.RELATIVE_NAME = "rn";

module.exports = ClassReference;
module.exports = Name;
2 changes: 1 addition & 1 deletion src/parser/namespace.js
Expand Up @@ -85,7 +85,7 @@ module.exports = {
return result("selfreference", names[0]);
}
}
return result("classreference", names, relative);
return result("name", names, relative);
},
/**
* Reads a use statement
Expand Down
88 changes: 44 additions & 44 deletions test/snapshot/__snapshots__/acid.test.js.snap
Expand Up @@ -42,8 +42,8 @@ Program {
"offset": 19,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 15,
Expand Down Expand Up @@ -534,8 +534,8 @@ Program {
},
},
"traits": Array [
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 12,
Expand All @@ -558,8 +558,8 @@ Program {
"adaptations": Array [
TraitPrecedence {
"instead": Array [
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 28,
Expand Down Expand Up @@ -608,8 +608,8 @@ Program {
},
"name": "baz",
},
"trait": ClassReference {
"kind": "classreference",
"trait": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 9,
Expand Down Expand Up @@ -676,8 +676,8 @@ Program {
},
"name": "foo",
},
"trait": ClassReference {
"kind": "classreference",
"trait": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 9,
Expand Down Expand Up @@ -715,8 +715,8 @@ Program {
},
},
"traits": Array [
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 11,
Expand All @@ -733,8 +733,8 @@ Program {
"name": "foo",
"resolution": "uqn",
},
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 16,
Expand Down Expand Up @@ -1489,8 +1489,8 @@ Program {
"offset": 900,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 27,
Expand Down Expand Up @@ -1598,8 +1598,8 @@ Program {
],
"extends": null,
"implements": Array [
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 51,
Expand Down Expand Up @@ -1879,8 +1879,8 @@ Program {
},
],
"extends": Array [
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 32,
Expand Down Expand Up @@ -2058,8 +2058,8 @@ Program {
"offset": 1179,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 19,
Expand Down Expand Up @@ -3601,8 +3601,8 @@ Program {
"offset": 1705,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 11,
Expand Down Expand Up @@ -3822,8 +3822,8 @@ Program {
"offset": 1820,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 27,
Expand Down Expand Up @@ -4819,8 +4819,8 @@ next:
"offset": 2651,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 28,
Expand Down Expand Up @@ -5282,8 +5282,8 @@ next:
"visibility": "",
},
],
"extends": ClassReference {
"kind": "classreference",
"extends": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 40,
Expand Down Expand Up @@ -5878,8 +5878,8 @@ next:
"name": "ex",
},
"what": Array [
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 18,
Expand All @@ -5896,8 +5896,8 @@ next:
"name": "Coco",
"resolution": "uqn",
},
ClassReference {
"kind": "classreference",
Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 22,
Expand Down Expand Up @@ -6060,8 +6060,8 @@ next:
},
},
"parenthesizedExpression": true,
"right": ClassReference {
"kind": "classreference",
"right": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 45,
Expand Down Expand Up @@ -6109,8 +6109,8 @@ next:
"children": Array [
Break {
"kind": "break",
"level": ClassReference {
"kind": "classreference",
"level": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 19,
Expand Down Expand Up @@ -6195,8 +6195,8 @@ next:
"offset": 2023,
},
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 39,
Expand Down Expand Up @@ -6543,8 +6543,8 @@ next:
},
"name": "NUMBAR",
},
"what": ClassReference {
"kind": "classreference",
"what": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 20,
Expand All @@ -6567,8 +6567,8 @@ next:
},
Return {
"expr": Empty {
"expression": ClassReference {
"kind": "classreference",
"expression": Name {
"kind": "name",
"loc": Location {
"end": Position {
"column": 33,
Expand Down

0 comments on commit 730e6aa

Please sign in to comment.