code clean up
This commit is contained in:
@@ -9,7 +9,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
//TODO: implement aliasesForDescriptors stack for this need TESTS
|
||||
public class Aliaser {
|
||||
|
||||
public static Aliaser newInstance() {
|
||||
@@ -30,7 +29,6 @@ public class Aliaser {
|
||||
return thisAliases.peek().makeRef();
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public void setAliasForThis(@NotNull JsName alias) {
|
||||
thisAliases.push(alias);
|
||||
}
|
||||
|
||||
@@ -56,12 +56,6 @@ public class DynamicContext {
|
||||
return new TemporaryVariable(namingScope.declareTemporary(), initExpression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TemporaryVariable declareTemporaryWithName(@NotNull String preferredName,
|
||||
@NotNull JsExpression initExpression) {
|
||||
return new TemporaryVariable(namingScope.declareTemporaryWithName(preferredName), initExpression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsName declareLocalVariable(@NotNull DeclarationDescriptor descriptor) {
|
||||
return namingScope.declareVariable(descriptor, descriptor.getName());
|
||||
@@ -72,6 +66,7 @@ public class DynamicContext {
|
||||
return namingScope.jsScope();
|
||||
}
|
||||
|
||||
//TODO:
|
||||
@NotNull
|
||||
public JsBlock jsBlock() {
|
||||
return currentBlock;
|
||||
|
||||
@@ -78,10 +78,6 @@ public final class NamingScope {
|
||||
return scope.declareTemporary();
|
||||
}
|
||||
|
||||
public JsName declareTemporaryWithName(@NotNull String preferredName) {
|
||||
return scope.declareName(preferredName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsScope jsScope() {
|
||||
return scope;
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class StandardClasses {
|
||||
StandardClasses standardClasses = new StandardClasses(kotlinObjectScope);
|
||||
declareArray(standardClasses, standardLibrary);
|
||||
declareIterator(standardClasses, standardLibrary);
|
||||
declareRange(standardClasses, standardLibrary);
|
||||
declareRange(standardClasses);
|
||||
declareJavaArrayList(standardClasses);
|
||||
declareJavaSystem(standardClasses);
|
||||
declareJavaInteger(standardClasses);
|
||||
@@ -36,7 +36,7 @@ public final class StandardClasses {
|
||||
}
|
||||
|
||||
//TODO: duplication
|
||||
private static void declareRange(@NotNull StandardClasses standardClasses, @NotNull JetStandardLibrary standardLibrary) {
|
||||
private static void declareRange(@NotNull StandardClasses standardClasses) {
|
||||
String intRangeFQName = "jet.IntRange";
|
||||
standardClasses.declareStandardTopLevelObject(intRangeFQName, "NumberRange");
|
||||
standardClasses.declareStandardInnerDeclaration(intRangeFQName, "<init>", "NumberRange");
|
||||
|
||||
@@ -119,7 +119,9 @@ public class StaticContext {
|
||||
|
||||
@NotNull
|
||||
public JsName getGlobalName(@NotNull DeclarationDescriptor descriptor) {
|
||||
return declarations.getName(descriptor);
|
||||
JsName nameToDeclare = declarations.getName(descriptor);
|
||||
nameToDeclare.setObfuscatable(false);
|
||||
return nameToDeclare;
|
||||
}
|
||||
|
||||
public boolean isDeclared(@NotNull DeclarationDescriptor descriptor) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import static com.google.dart.compiler.util.AstUtil.sum;
|
||||
/**
|
||||
* @author Talanov Pavel
|
||||
*/
|
||||
//TODO: add toString call for non-primitive object
|
||||
public final class StringTemplateTranslator extends AbstractTranslator {
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,6 +23,7 @@ public final class IntrinsicDeclarationVisitor extends DeclarationDescriptorVisi
|
||||
public Void visitClassDescriptor(@NotNull ClassDescriptor descriptor, @Nullable Void nothing) {
|
||||
for (DeclarationDescriptor memberDescriptor :
|
||||
descriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
|
||||
//noinspection NullableProblems
|
||||
memberDescriptor.accept(this, null);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -213,7 +213,8 @@ public final class PropertyAccessTranslator extends AccessTranslator {
|
||||
|
||||
@NotNull
|
||||
private JsName getGetterName() {
|
||||
//TODO: hack alert. properties for standard objects that do not have their implementation do not have getters
|
||||
//TODO: hack alert. properties for standard objects that do not have their implementation
|
||||
// do not have getters and thus this workaround is needed
|
||||
if (context().isStandardObject(propertyDescriptor)) {
|
||||
return context().getNameForStandardObject(propertyDescriptor);
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
package org.jetbrains.k2js.translate.utils;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
|
||||
/**
|
||||
* @author Talanov Pavel
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public final class IsStatement {
|
||||
|
||||
private IsStatement() {
|
||||
}
|
||||
|
||||
private static IsStatementVisitor visitor = new IsStatementVisitor();
|
||||
|
||||
public static boolean isStatement(@NotNull JetExpression expression) {
|
||||
return (expression.accept(visitor, null));
|
||||
}
|
||||
|
||||
private static final class IsStatementVisitor extends JetVisitor<Boolean, Void> {
|
||||
|
||||
@NotNull
|
||||
private Boolean visitParent(@NotNull JetElement element) {
|
||||
PsiElement parent = element.getParent();
|
||||
assert parent != null : "Cannot visit top level expressions.";
|
||||
assert parent instanceof JetElement : "Elements of Kotlin PSI must be instances of JetElement";
|
||||
return ((JetElement) parent).accept(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitJetElement(@NotNull JetElement element, @Nullable Void nothing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitBlockExpression(@NotNull JetBlockExpression expression, @Nullable Void nothing) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitWhenExpression(@NotNull JetWhenExpression expression, @Nullable Void nothing) {
|
||||
return visitParent(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitIfExpression(@NotNull JetIfExpression expression, @Nullable Void nothing) {
|
||||
return visitParent(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitWhenEntry(@NotNull JetWhenEntry expression, @Nullable Void nothing) {
|
||||
return visitParent(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitWhenCondition(@NotNull JetWhenCondition expression, @Nullable Void nothing) {
|
||||
return visitParent(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Boolean visitContainerNode(@NotNull JetContainerNode expression, @Nullable Void nothing) {
|
||||
return visitParent(expression);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user