Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Side by Side Diff: third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java

Issue 473853003: Fix in compiler pass: cr.defineProperty() with 2 arguments means opt_kind == cr.PropertyKind.JS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@D_define_once_rebase
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698