OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package com.google.javascript.jscomp; | 5 package com.google.javascript.jscomp; |
6 | 6 |
7 import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; | 7 import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; |
8 import com.google.javascript.rhino.IR; | 8 import com.google.javascript.rhino.IR; |
9 import com.google.javascript.rhino.JSDocInfoBuilder; | 9 import com.google.javascript.rhino.JSDocInfoBuilder; |
10 import com.google.javascript.rhino.JSTypeExpression; | 10 import com.google.javascript.rhino.JSTypeExpression; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } else { | 113 } else { |
114 setJsDocWithType(getPropNode, new Node(Token.QMARK)); | 114 setJsDocWithType(getPropNode, new Node(Token.QMARK)); |
115 } | 115 } |
116 | 116 |
117 Node definitionNode = IR.exprResult(getPropNode).srcref(parent); | 117 Node definitionNode = IR.exprResult(getPropNode).srcref(parent); |
118 | 118 |
119 parent.getParent().addChildAfter(definitionNode, parent); | 119 parent.getParent().addChildAfter(definitionNode, parent); |
120 } | 120 } |
121 | 121 |
122 private Node getTypeByCrPropertyKind(Node propertyKind) { | 122 private Node getTypeByCrPropertyKind(Node propertyKind) { |
| 123 if (propertyKind == null || propertyKind.matchesQualifiedName("cr.Proper
tyKind.JS")) { |
| 124 return new Node(Token.QMARK); |
| 125 } |
123 if (propertyKind.matchesQualifiedName("cr.PropertyKind.ATTR")) { | 126 if (propertyKind.matchesQualifiedName("cr.PropertyKind.ATTR")) { |
124 return IR.string("string"); | 127 return IR.string("string"); |
125 } | 128 } |
126 if (propertyKind.matchesQualifiedName("cr.PropertyKind.BOOL_ATTR")) { | 129 if (propertyKind.matchesQualifiedName("cr.PropertyKind.BOOL_ATTR")) { |
127 return IR.string("boolean"); | 130 return IR.string("boolean"); |
128 } | 131 } |
129 if (propertyKind.matchesQualifiedName("cr.PropertyKind.JS")) { | |
130 return new Node(Token.QMARK); | |
131 } | |
132 compiler.report(JSError.make(propertyKind, CR_DEFINE_PROPERTY_INVALID_PR
OPERTY_KIND, | 132 compiler.report(JSError.make(propertyKind, CR_DEFINE_PROPERTY_INVALID_PR
OPERTY_KIND, |
133 propertyKind.getQualifiedName())); | 133 propertyKind.getQualifiedName())); |
134 return null; | 134 return null; |
135 } | 135 } |
136 | 136 |
137 private void setJsDocWithType(Node target, Node type) { | 137 private void setJsDocWithType(Node target, Node type) { |
138 JSDocInfoBuilder builder = new JSDocInfoBuilder(false); | 138 JSDocInfoBuilder builder = new JSDocInfoBuilder(false); |
139 builder.recordType(new JSTypeExpression(type, "")); | 139 builder.recordType(new JSTypeExpression(type, "")); |
140 target.setJSDocInfo(builder.build(target)); | 140 target.setJSDocInfo(builder.build(target)); |
141 } | 141 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 | 333 |
334 private Node buildQualifiedName(Node internalName) { | 334 private Node buildQualifiedName(Node internalName) { |
335 String externalName = this.exports.get(internalName.getString()); | 335 String externalName = this.exports.get(internalName.getString()); |
336 return NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(), | 336 return NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(), |
337 this.namespaceName + "." + externalName).srcrefTree(internal
Name); | 337 this.namespaceName + "." + externalName).srcrefTree(internal
Name); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 } | 341 } |
OLD | NEW |