printScopeStructure() introduced for debugging
This commit is contained in:
+11
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -255,4 +256,14 @@ public abstract class DeserializedMemberScope implements JetScope {
|
||||
boolean accept(T value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printScopeStructure(@NotNull Printer p) {
|
||||
p.println(getClass().getSimpleName(), " {");
|
||||
p.pushIndent();
|
||||
|
||||
p.println("containingDeclaration = " + containingDeclaration);
|
||||
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -43,6 +43,7 @@ import org.jetbrains.jet.lang.types.expressions.DataFlowUtils;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
@@ -113,7 +114,12 @@ public class CallExpressionResolver {
|
||||
public String toString() {
|
||||
return "Scope for the type parameter on the left hand side of dot";
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void printScopeStructure(@NotNull Printer p) {
|
||||
p.println(toString(), " for ", classifier);
|
||||
}
|
||||
};
|
||||
return new NamespaceType(referencedName, scopeForStaticMembersResolution, NO_RECEIVER);
|
||||
}
|
||||
temporaryTrace.commit();
|
||||
|
||||
@@ -22,6 +22,7 @@ import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
@@ -32,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -312,4 +314,19 @@ public class LazyImportScope implements JetScope {
|
||||
public String toString() {
|
||||
return "LazyImportScope: " + debugName;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@Override
|
||||
public void printScopeStructure(@NotNull Printer p) {
|
||||
p.println(getClass().getSimpleName(), ": ", debugName, " {");
|
||||
p.pushIndent();
|
||||
|
||||
p.println("packageDescriptor = ", packageDescriptor);
|
||||
|
||||
p.print("rootScope = ");
|
||||
rootScope.printScopeStructure(p.withholdIndentOnce());
|
||||
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -329,4 +330,15 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
public Collection<DeclarationDescriptor> getOwnDeclaredDescriptors() {
|
||||
return getAllDescriptors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printScopeStructure(@NotNull Printer p) {
|
||||
p.println(getClass().getSimpleName(), " {");
|
||||
p.pushIndent();
|
||||
|
||||
p.println("thisDescriptor = ", thisDescriptor);
|
||||
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,12 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -130,4 +131,18 @@ public final class JetScopeUtils {
|
||||
result.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
return result;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@NotNull
|
||||
public static String printStructure(@Nullable JetScope scope) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
Printer p = new Printer(out);
|
||||
if (scope == null) {
|
||||
p.println("null");
|
||||
}
|
||||
else {
|
||||
scope.printScopeStructure(p);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
@@ -284,4 +286,11 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
|
||||
return getWorkerScope();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@Override
|
||||
protected void printAdditionalScopeStructure(@NotNull Printer p) {
|
||||
p.print("writableWorker = ");
|
||||
writableWorker.printScopeStructure(p.withholdIndentOnce());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class Printer {
|
||||
private static final String INDENTATION_UNIT = " ";
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
private final Appendable out;
|
||||
private final int maxBlankLines;
|
||||
|
||||
private String indent = "";
|
||||
private int blankLineCountIncludingCurrent = 0;
|
||||
|
||||
public Printer(@NotNull Appendable out) {
|
||||
this(out, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Printer(@NotNull Appendable out, int maxBlankLines) {
|
||||
this.out = out;
|
||||
this.maxBlankLines = maxBlankLines;
|
||||
}
|
||||
|
||||
private void append(Object o) {
|
||||
try {
|
||||
out.append(o.toString());
|
||||
}
|
||||
catch (IOException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer println(Object... objects) {
|
||||
print(objects);
|
||||
printLineSeparator();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void printLineSeparator() {
|
||||
if (blankLineCountIncludingCurrent <= maxBlankLines) {
|
||||
blankLineCountIncludingCurrent++;
|
||||
append(LINE_SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer print(Object... objects) {
|
||||
append(indent);
|
||||
printWithNoIndent(objects);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer printWithNoIndent(Object... objects) {
|
||||
for (Object object : objects) {
|
||||
blankLineCountIncludingCurrent = 0;
|
||||
append(object);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer printlnWithNoIndent(Object... objects) {
|
||||
printWithNoIndent(objects);
|
||||
printLineSeparator();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer pushIndent() {
|
||||
indent += INDENTATION_UNIT;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer popIndent() {
|
||||
if (indent.length() < INDENTATION_UNIT.length()) {
|
||||
throw new IllegalStateException("No indentation to pop");
|
||||
}
|
||||
|
||||
indent = indent.substring(INDENTATION_UNIT.length());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer separated(Object separator, Object... items) {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (i > 0) {
|
||||
printlnWithNoIndent(separator);
|
||||
}
|
||||
printlnWithNoIndent(items[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer separated(Object separator, Collection<?> items) {
|
||||
for (Iterator<?> iterator = items.iterator(); iterator.hasNext(); ) {
|
||||
printlnWithNoIndent(iterator.next());
|
||||
if (iterator.hasNext()) {
|
||||
printlnWithNoIndent(separator);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user