clean up inType tracking in flow parser plugin
This commit is contained in:
parent
2d195c4843
commit
50ca6b1018
@ -16,6 +16,15 @@ pp.expectRelational = function (op) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pp.flow_parseTypeInitialiser = function (tok) {
|
||||||
|
var oldInType = this.inType
|
||||||
|
this.inType = true
|
||||||
|
this.expect(tok || tt.colon)
|
||||||
|
var type = this.flow_parseType()
|
||||||
|
this.inType = oldInType
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
pp.flow_parseDeclareClass = function (node) {
|
pp.flow_parseDeclareClass = function (node) {
|
||||||
this.next()
|
this.next()
|
||||||
this.flow_parseInterfaceish(node, true)
|
this.flow_parseInterfaceish(node, true)
|
||||||
@ -41,12 +50,7 @@ pp.flow_parseDeclareFunction = function (node) {
|
|||||||
typeNode.params = tmp.params
|
typeNode.params = tmp.params
|
||||||
typeNode.rest = tmp.rest
|
typeNode.rest = tmp.rest
|
||||||
this.expect(tt.parenR)
|
this.expect(tt.parenR)
|
||||||
|
typeNode.returnType = this.flow_parseTypeInitialiser()
|
||||||
var oldInType = this.inType
|
|
||||||
this.inType = true
|
|
||||||
this.expect(tt.colon)
|
|
||||||
typeNode.returnType = this.flow_parseType()
|
|
||||||
this.inType = oldInType
|
|
||||||
|
|
||||||
typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation")
|
typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation")
|
||||||
id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation")
|
id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation")
|
||||||
@ -157,15 +161,7 @@ pp.flow_parseTypeAlias = function (node) {
|
|||||||
node.typeParameters = null
|
node.typeParameters = null
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldInType = this.inType;
|
node.right = this.flow_parseTypeInitialiser(tt.eq)
|
||||||
this.inType = true;
|
|
||||||
|
|
||||||
this.expect(tt.eq)
|
|
||||||
|
|
||||||
node.right = this.flow_parseType()
|
|
||||||
|
|
||||||
this.inType = oldInType;
|
|
||||||
|
|
||||||
this.semicolon()
|
this.semicolon()
|
||||||
|
|
||||||
return this.finishNode(node, "TypeAlias")
|
return this.finishNode(node, "TypeAlias")
|
||||||
@ -218,11 +214,9 @@ pp.flow_parseObjectTypeIndexer = function (node, isStatic) {
|
|||||||
|
|
||||||
this.expect(tt.bracketL)
|
this.expect(tt.bracketL)
|
||||||
node.id = this.flow_parseObjectPropertyKey()
|
node.id = this.flow_parseObjectPropertyKey()
|
||||||
this.expect(tt.colon)
|
node.key = this.flow_parseTypeInitialiser()
|
||||||
node.key = this.flow_parseType()
|
|
||||||
this.expect(tt.bracketR)
|
this.expect(tt.bracketR)
|
||||||
this.expect(tt.colon)
|
node.value = this.flow_parseTypeInitialiser()
|
||||||
node.value = this.flow_parseType()
|
|
||||||
|
|
||||||
this.flow_objectTypeSemicolon()
|
this.flow_objectTypeSemicolon()
|
||||||
return this.finishNode(node, "ObjectTypeIndexer")
|
return this.finishNode(node, "ObjectTypeIndexer")
|
||||||
@ -249,8 +243,7 @@ pp.flow_parseObjectTypeMethodish = function (node) {
|
|||||||
node.rest = this.flow_parseFunctionTypeParam()
|
node.rest = this.flow_parseFunctionTypeParam()
|
||||||
}
|
}
|
||||||
this.expect(tt.parenR)
|
this.expect(tt.parenR)
|
||||||
this.expect(tt.colon)
|
node.returnType = this.flow_parseTypeInitialiser()
|
||||||
node.returnType = this.flow_parseType()
|
|
||||||
|
|
||||||
return this.finishNode(node, "FunctionTypeAnnotation")
|
return this.finishNode(node, "FunctionTypeAnnotation")
|
||||||
}
|
}
|
||||||
@ -314,9 +307,8 @@ pp.flow_parseObjectType = function (allowStatic) {
|
|||||||
if (this.eat(tt.question)) {
|
if (this.eat(tt.question)) {
|
||||||
optional = true
|
optional = true
|
||||||
}
|
}
|
||||||
this.expect(tt.colon)
|
|
||||||
node.key = propertyKey
|
node.key = propertyKey
|
||||||
node.value = this.flow_parseType()
|
node.value = this.flow_parseTypeInitialiser()
|
||||||
node.optional = optional
|
node.optional = optional
|
||||||
node.static = isStatic
|
node.static = isStatic
|
||||||
this.flow_objectTypeSemicolon()
|
this.flow_objectTypeSemicolon()
|
||||||
@ -384,9 +376,8 @@ pp.flow_parseFunctionTypeParam = function () {
|
|||||||
if (this.eat(tt.question)) {
|
if (this.eat(tt.question)) {
|
||||||
optional = true
|
optional = true
|
||||||
}
|
}
|
||||||
this.expect(tt.colon)
|
|
||||||
node.optional = optional
|
node.optional = optional
|
||||||
node.typeAnnotation = this.flow_parseType()
|
node.typeAnnotation = this.flow_parseTypeInitialiser()
|
||||||
return this.finishNode(node, "FunctionTypeParam")
|
return this.finishNode(node, "FunctionTypeParam")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,13 +574,7 @@ pp.flow_parseType = function () {
|
|||||||
|
|
||||||
pp.flow_parseTypeAnnotation = function () {
|
pp.flow_parseTypeAnnotation = function () {
|
||||||
var node = this.startNode()
|
var node = this.startNode()
|
||||||
|
node.typeAnnotation = this.flow_parseTypeInitialiser()
|
||||||
var oldInType = this.inType
|
|
||||||
this.inType = true
|
|
||||||
this.expect(tt.colon)
|
|
||||||
node.typeAnnotation = this.flow_parseType()
|
|
||||||
this.inType = oldInType
|
|
||||||
|
|
||||||
return this.finishNode(node, "TypeAnnotation")
|
return this.finishNode(node, "TypeAnnotation")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9965,6 +9965,95 @@ var fbTestFixture = {
|
|||||||
end: { line: 1, column: 49 }
|
end: { line: 1, column: 49 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'declare class IViewFactory { didAnimate(view:Object, prop:string) :void; }': {
|
||||||
|
start: 0,
|
||||||
|
id: {
|
||||||
|
start: 14,
|
||||||
|
name: "IViewFactory",
|
||||||
|
type: "Identifier",
|
||||||
|
end: 26
|
||||||
|
},
|
||||||
|
typeParameters: null,
|
||||||
|
extends: [],
|
||||||
|
body: {
|
||||||
|
start: 27,
|
||||||
|
callProperties: [],
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
start: 29,
|
||||||
|
value: {
|
||||||
|
start: 29,
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
start: 40,
|
||||||
|
name: {
|
||||||
|
start: 40,
|
||||||
|
name: "view",
|
||||||
|
type: "Identifier",
|
||||||
|
end: 44
|
||||||
|
},
|
||||||
|
optional: false,
|
||||||
|
typeAnnotation: {
|
||||||
|
start: 45,
|
||||||
|
typeParameters: null,
|
||||||
|
id: {
|
||||||
|
start: 45,
|
||||||
|
name: "Object",
|
||||||
|
type: "Identifier",
|
||||||
|
end: 51
|
||||||
|
},
|
||||||
|
type: "GenericTypeAnnotation",
|
||||||
|
end: 51
|
||||||
|
},
|
||||||
|
type: "FunctionTypeParam",
|
||||||
|
end: 51
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: 53,
|
||||||
|
name: {
|
||||||
|
start: 53,
|
||||||
|
name: "prop",
|
||||||
|
type: "Identifier",
|
||||||
|
end: 57
|
||||||
|
},
|
||||||
|
optional: false,
|
||||||
|
typeAnnotation: {
|
||||||
|
start: 58,
|
||||||
|
type: "StringTypeAnnotation",
|
||||||
|
end: 64
|
||||||
|
},
|
||||||
|
type: "FunctionTypeParam",
|
||||||
|
end: 64
|
||||||
|
}
|
||||||
|
],
|
||||||
|
rest: null,
|
||||||
|
typeParameters: null,
|
||||||
|
returnType: {
|
||||||
|
start: 67,
|
||||||
|
type: "VoidTypeAnnotation",
|
||||||
|
end: 71
|
||||||
|
},
|
||||||
|
type: "FunctionTypeAnnotation",
|
||||||
|
end: 71
|
||||||
|
},
|
||||||
|
key: {
|
||||||
|
start: 29,
|
||||||
|
name: "didAnimate",
|
||||||
|
type: "Identifier",
|
||||||
|
end: 39
|
||||||
|
},
|
||||||
|
optional: false,
|
||||||
|
type: "ObjectTypeProperty",
|
||||||
|
end: 72
|
||||||
|
}
|
||||||
|
],
|
||||||
|
indexers: [],
|
||||||
|
type: "ObjectTypeAnnotation",
|
||||||
|
end: 74
|
||||||
|
},
|
||||||
|
type: "DeclareClass",
|
||||||
|
end: 74
|
||||||
|
},
|
||||||
'declare class A {}': {
|
'declare class A {}': {
|
||||||
type: 'DeclareClass',
|
type: 'DeclareClass',
|
||||||
id: {
|
id: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user