JS backend: add NotNull annotations
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -13,6 +15,7 @@ import java.util.List;
|
|||||||
* Represents a JavaScript block statement.
|
* Represents a JavaScript block statement.
|
||||||
*/
|
*/
|
||||||
public class JsBlock extends SourceInfoAwareJsNode implements JsStatement {
|
public class JsBlock extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
|
@NotNull
|
||||||
private final List<JsStatement> statements;
|
private final List<JsStatement> statements;
|
||||||
|
|
||||||
public JsBlock() {
|
public JsBlock() {
|
||||||
@@ -27,10 +30,11 @@ public class JsBlock extends SourceInfoAwareJsNode implements JsStatement {
|
|||||||
this(Arrays.asList(statements));
|
this(Arrays.asList(statements));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsBlock(List<JsStatement> statements) {
|
public JsBlock(@NotNull List<JsStatement> statements) {
|
||||||
this.statements = statements;
|
this.statements = statements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public List<JsStatement> getStatements() {
|
public List<JsStatement> getStatements() {
|
||||||
return statements;
|
return statements;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class JsCatchScope extends JsScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
public JsName declareName(String identifier) {
|
public JsName declareName(String identifier) {
|
||||||
// Declare into parent scope!
|
// Declare into parent scope!
|
||||||
return getParent().declareName(identifier);
|
return getParent().declareName(identifier);
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
|
|
||||||
import com.google.dart.compiler.common.Symbol;
|
import com.google.dart.compiler.common.Symbol;
|
||||||
import com.intellij.util.SmartList;
|
import com.intellij.util.SmartList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class JsFunction extends JsLiteral implements HasName {
|
public final class JsFunction extends JsLiteral implements HasName {
|
||||||
|
@NotNull
|
||||||
private JsBlock body;
|
private JsBlock body;
|
||||||
private List<JsParameter> params;
|
private List<JsParameter> params;
|
||||||
|
@NotNull
|
||||||
private final JsScope scope;
|
private final JsScope scope;
|
||||||
private JsName name;
|
private JsName name;
|
||||||
|
|
||||||
@@ -20,7 +23,7 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
this(parentScope, (JsName) null);
|
this(parentScope, (JsName) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsFunction(JsScope parentScope, JsBlock body) {
|
public JsFunction(JsScope parentScope, @NotNull JsBlock body) {
|
||||||
this(parentScope, (JsName) null);
|
this(parentScope, (JsName) null);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
@@ -30,6 +33,7 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
scope = new JsScope(parentScope, name == null ? null : name.getIdent());
|
scope = new JsScope(parentScope, name == null ? null : name.getIdent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public JsBlock getBody() {
|
public JsBlock getBody() {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
@@ -44,6 +48,7 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public List<JsParameter> getParameters() {
|
public List<JsParameter> getParameters() {
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new SmartList<JsParameter>();
|
params = new SmartList<JsParameter>();
|
||||||
@@ -51,11 +56,12 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public JsScope getScope() {
|
public JsScope getScope() {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBody(JsBlock body) {
|
public void setBody(@NotNull JsBlock body) {
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,23 +5,27 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.Symbol;
|
import com.google.dart.compiler.common.Symbol;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A JavaScript parameter.
|
* A JavaScript parameter.
|
||||||
*/
|
*/
|
||||||
public final class JsParameter extends SourceInfoAwareJsNode implements HasName {
|
public final class JsParameter extends SourceInfoAwareJsNode implements HasName {
|
||||||
|
@NotNull
|
||||||
private final JsName name;
|
private final JsName name;
|
||||||
|
|
||||||
public JsParameter(JsName name) {
|
public JsParameter(@NotNull JsName name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
public JsName getName() {
|
public JsName getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
public Symbol getSymbol() {
|
public Symbol getSymbol() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class JsScope {
|
|||||||
*
|
*
|
||||||
* @param identifier An identifier that is unique within this scope.
|
* @param identifier An identifier that is unique within this scope.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public JsName declareName(String identifier) {
|
public JsName declareName(String identifier) {
|
||||||
JsName name = findOwnName(identifier);
|
JsName name = findOwnName(identifier);
|
||||||
return name != null ? name : doCreateName(identifier);
|
return name != null ? name : doCreateName(identifier);
|
||||||
@@ -112,6 +113,7 @@ public class JsScope {
|
|||||||
* name) that does not clash with any existing variables in the scope.
|
* name) that does not clash with any existing variables in the scope.
|
||||||
* Future declarations of variables might however clash with the temporary.
|
* Future declarations of variables might however clash with the temporary.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public JsName declareTemporary() {
|
public JsName declareTemporary() {
|
||||||
return declareFreshName(getNextTempName());
|
return declareFreshName(getNextTempName());
|
||||||
}
|
}
|
||||||
@@ -158,6 +160,7 @@ public class JsScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
protected JsName doCreateName(String ident) {
|
protected JsName doCreateName(String ident) {
|
||||||
JsName name = new JsName(this, ident);
|
JsName name = new JsName(this, ident);
|
||||||
names = Maps.put(names, ident, name);
|
names = Maps.put(names, ident, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user