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