Add some TODOs based on code coverage.
Fix some typos and minor code issues.
This commit is contained in:
@@ -61,26 +61,17 @@ public final class NamingScope {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
/*package*/ JsName declareObfuscatableName(@NotNull String name) {
|
/*package*/ JsName declareObfuscatableName(@NotNull String name) {
|
||||||
return scope.declareName(mayBeObfuscateName(name, true));
|
return scope.declareName(obfuscateName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: temporary solution
|
//TODO: temporary solution
|
||||||
@NotNull
|
@NotNull
|
||||||
private String mayBeObfuscateName(@NotNull String name, boolean shouldObfuscate) {
|
private String obfuscateName(@NotNull String name) {
|
||||||
if (!shouldObfuscate) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
return doObfuscate(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: refactor
|
|
||||||
@NotNull
|
|
||||||
private String doObfuscate(@NotNull String name) {
|
|
||||||
int obfuscate = 0;
|
int obfuscate = 0;
|
||||||
String result = name;
|
String result = name;
|
||||||
while (true) {
|
while (true) {
|
||||||
JsName existingNameWithSameIdent = scope.findExistingName(result);
|
JsName existingNameWithSameIdent = this.scope.findExistingName(result);
|
||||||
boolean isDuplicate = (existingNameWithSameIdent != null) && JsAstUtils.ownsName(scope, existingNameWithSameIdent);
|
boolean isDuplicate = (existingNameWithSameIdent != null) && JsAstUtils.ownsName(this.scope, existingNameWithSameIdent);
|
||||||
|
|
||||||
if (!isDuplicate) break;
|
if (!isDuplicate) break;
|
||||||
|
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ public final class StaticContext {
|
|||||||
return getRootScope().innerScope("Namespace " + descriptor.getName());
|
return getRootScope().innerScope("Namespace " + descriptor.getName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
//TODO: never get there
|
||||||
Rule<NamingScope> generateInnerScopesForMembers = new Rule<NamingScope>() {
|
Rule<NamingScope> generateInnerScopesForMembers = new Rule<NamingScope>() {
|
||||||
@Override
|
@Override
|
||||||
public NamingScope apply(@NotNull DeclarationDescriptor descriptor) {
|
public NamingScope apply(@NotNull DeclarationDescriptor descriptor) {
|
||||||
|
|||||||
+2
-2
@@ -82,7 +82,7 @@ public final class ArrayForTranslator extends ForTranslator {
|
|||||||
private JsBlock translate() {
|
private JsBlock translate() {
|
||||||
List<JsStatement> blockStatements = Lists.newArrayList();
|
List<JsStatement> blockStatements = Lists.newArrayList();
|
||||||
blockStatements.add(temporariesInitialization(loopRange, end).makeStmt());
|
blockStatements.add(temporariesInitialization(loopRange, end).makeStmt());
|
||||||
blockStatements.add(generateForExpression(getInitExpression(), getCondition(), getIncrExpression(), getBody()));
|
blockStatements.add(generateForExpression(getInitExpression(), getCondition(), getIncrementExpression(), getBody()));
|
||||||
return newBlock(blockStatements);
|
return newBlock(blockStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public final class ArrayForTranslator extends ForTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JsExpression getIncrExpression() {
|
private JsExpression getIncrementExpression() {
|
||||||
return new JsPrefixOperation(JsUnaryOperator.INC, index.reference());
|
return new JsPrefixOperation(JsUnaryOperator.INC, index.reference());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -34,6 +34,7 @@ import static org.jetbrains.k2js.translate.utils.JsAstUtils.qualified;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* For native apis that use .property notation for access.
|
* For native apis that use .property notation for access.
|
||||||
*/
|
*/
|
||||||
|
//TODO: test this class
|
||||||
public final class NativePropertyAccessTranslator extends PropertyAccessTranslator {
|
public final class NativePropertyAccessTranslator extends PropertyAccessTranslator {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
+1
@@ -39,6 +39,7 @@ import static org.jetbrains.k2js.translate.utils.PsiUtils.isBackingFieldReferenc
|
|||||||
*/
|
*/
|
||||||
public abstract class PropertyAccessTranslator extends AbstractTranslator implements AccessTranslator {
|
public abstract class PropertyAccessTranslator extends AbstractTranslator implements AccessTranslator {
|
||||||
|
|
||||||
|
//TODO: is it really called?
|
||||||
@NotNull
|
@NotNull
|
||||||
private static PropertyAccessTranslator newInstance(@NotNull PropertyDescriptor descriptor,
|
private static PropertyAccessTranslator newInstance(@NotNull PropertyDescriptor descriptor,
|
||||||
@NotNull ResolvedCall<?> resolvedCall,
|
@NotNull ResolvedCall<?> resolvedCall,
|
||||||
|
|||||||
+1
@@ -70,6 +70,7 @@ public final class QualifiedExpressionTranslator {
|
|||||||
if (selector instanceof JetCallExpression) {
|
if (selector instanceof JetCallExpression) {
|
||||||
return CallExpressionTranslator.translate((JetCallExpression)selector, receiver, callType, context);
|
return CallExpressionTranslator.translate((JetCallExpression)selector, receiver, callType, context);
|
||||||
}
|
}
|
||||||
|
//TODO: never get there
|
||||||
if (selector instanceof JetSimpleNameExpression) {
|
if (selector instanceof JetSimpleNameExpression) {
|
||||||
return ReferenceTranslator.translateSimpleName((JetSimpleNameExpression)selector, context);
|
return ReferenceTranslator.translateSimpleName((JetSimpleNameExpression)selector, context);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -20,9 +20,12 @@ import com.google.common.collect.Maps;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.k2js.translate.utils.PsiUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.jetbrains.k2js.translate.utils.PsiUtils.getBaseExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pavel Talanov
|
* @author Pavel Talanov
|
||||||
*/
|
*/
|
||||||
@@ -88,7 +91,7 @@ public final class FindPreviousVisitor extends JetTreeVisitor<DangerousData> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hasDangerous(expression.getBaseExpression())) {
|
if (hasDangerous(getBaseExpression(expression))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user