Renames "possibly nothing" to "probably nothing"

This commit is contained in:
Valentin Kipyatkov
2014-11-19 18:50:59 +03:00
parent e5579bcf32
commit 3b77d337e8
15 changed files with 53 additions and 54 deletions
@@ -29,5 +29,5 @@ public interface KotlinFunctionStub extends KotlinStubWithFqName<JetNamedFunctio
boolean hasTypeParameterListBeforeFunctionName(); boolean hasTypeParameterListBeforeFunctionName();
boolean isPossiblyNothingType(); boolean isProbablyNothingType();
} }
@@ -27,5 +27,5 @@ public interface KotlinPropertyStub extends KotlinStubWithFqName<JetProperty> {
boolean hasReceiverTypeRef(); boolean hasReceiverTypeRef();
boolean hasReturnTypeRef(); boolean hasReturnTypeRef();
boolean isPossiblyNothingType(); boolean isProbablyNothingType();
} }
@@ -44,10 +44,9 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
FqName fqName = ResolveSessionUtils.safeFqNameForLazyResolve(psi); FqName fqName = ResolveSessionUtils.safeFqNameForLazyResolve(psi);
boolean hasBlockBody = psi.hasBlockBody(); boolean hasBlockBody = psi.hasBlockBody();
boolean hasBody = psi.hasBody(); boolean hasBody = psi.hasBody();
boolean isNothing = ElementsPackage.isPossiblyNothing(psi.getTypeReference());
return new KotlinFunctionStubImpl(parentStub, StringRef.fromString(psi.getName()), isTopLevel, fqName, return new KotlinFunctionStubImpl(parentStub, StringRef.fromString(psi.getName()), isTopLevel, fqName,
isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName(), isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName(),
isNothing); ElementsPackage.isProbablyNothing(psi.getTypeReference()));
} }
@Override @Override
@@ -62,7 +61,7 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
dataStream.writeBoolean(stub.hasBlockBody()); dataStream.writeBoolean(stub.hasBlockBody());
dataStream.writeBoolean(stub.hasBody()); dataStream.writeBoolean(stub.hasBody());
dataStream.writeBoolean(stub.hasTypeParameterListBeforeFunctionName()); dataStream.writeBoolean(stub.hasTypeParameterListBeforeFunctionName());
dataStream.writeBoolean(stub.isPossiblyNothingType()); dataStream.writeBoolean(stub.isProbablyNothingType());
} }
@NotNull @NotNull
@@ -78,10 +77,10 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
boolean hasBlockBody = dataStream.readBoolean(); boolean hasBlockBody = dataStream.readBoolean();
boolean hasBody = dataStream.readBoolean(); boolean hasBody = dataStream.readBoolean();
boolean hasTypeParameterListBeforeFunctionName = dataStream.readBoolean(); boolean hasTypeParameterListBeforeFunctionName = dataStream.readBoolean();
boolean possiblyNothingType = dataStream.readBoolean(); boolean probablyNothingType = dataStream.readBoolean();
return new KotlinFunctionStubImpl(parentStub, name, isTopLevel, fqName, isExtension, hasBlockBody, hasBody, return new KotlinFunctionStubImpl(parentStub, name, isTopLevel, fqName, isExtension, hasBlockBody, hasBody,
hasTypeParameterListBeforeFunctionName, possiblyNothingType); hasTypeParameterListBeforeFunctionName, probablyNothingType);
} }
@Override @Override
@@ -47,7 +47,7 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
psi.isVar(), psi.isTopLevel(), psi.hasDelegate(), psi.isVar(), psi.isTopLevel(), psi.hasDelegate(),
psi.hasDelegateExpression(), psi.hasInitializer(), psi.hasDelegateExpression(), psi.hasInitializer(),
psi.getReceiverTypeReference() != null, psi.getTypeReference() != null, psi.getReceiverTypeReference() != null, psi.getTypeReference() != null,
ElementsPackage.isPossiblyNothing(psi.getTypeReference()), ElementsPackage.isProbablyNothing(psi.getTypeReference()),
ResolveSessionUtils.safeFqNameForLazyResolve(psi) ResolveSessionUtils.safeFqNameForLazyResolve(psi)
); );
} }
@@ -62,7 +62,7 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
dataStream.writeBoolean(stub.hasInitializer()); dataStream.writeBoolean(stub.hasInitializer());
dataStream.writeBoolean(stub.hasReceiverTypeRef()); dataStream.writeBoolean(stub.hasReceiverTypeRef());
dataStream.writeBoolean(stub.hasReturnTypeRef()); dataStream.writeBoolean(stub.hasReturnTypeRef());
dataStream.writeBoolean(stub.isPossiblyNothingType()); dataStream.writeBoolean(stub.isProbablyNothingType());
FqName fqName = stub.getFqName(); FqName fqName = stub.getFqName();
dataStream.writeName(fqName != null ? fqName.asString() : null); dataStream.writeName(fqName != null ? fqName.asString() : null);
@@ -79,13 +79,13 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
boolean hasInitializer = dataStream.readBoolean(); boolean hasInitializer = dataStream.readBoolean();
boolean hasReceiverTypeRef = dataStream.readBoolean(); boolean hasReceiverTypeRef = dataStream.readBoolean();
boolean hasReturnTypeRef = dataStream.readBoolean(); boolean hasReturnTypeRef = dataStream.readBoolean();
boolean possiblyNothing = dataStream.readBoolean(); boolean probablyNothing = dataStream.readBoolean();
StringRef fqNameAsString = dataStream.readName(); StringRef fqNameAsString = dataStream.readName();
FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null; FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null;
return new KotlinPropertyStubImpl(parentStub, name, isVar, isTopLevel, hasDelegate, return new KotlinPropertyStubImpl(parentStub, name, isVar, isTopLevel, hasDelegate,
hasDelegateExpression, hasInitializer, hasReceiverTypeRef, hasReturnTypeRef, possiblyNothing, hasDelegateExpression, hasInitializer, hasReceiverTypeRef, hasReturnTypeRef, probablyNothing,
fqName); fqName);
} }
@@ -19,5 +19,5 @@ package org.jetbrains.jet.lang.psi.stubs.elements
import org.jetbrains.jet.lang.psi.JetUserType import org.jetbrains.jet.lang.psi.JetUserType
import org.jetbrains.jet.lang.psi.JetTypeReference import org.jetbrains.jet.lang.psi.JetTypeReference
fun JetTypeReference?.isPossiblyNothing() fun JetTypeReference?.isProbablyNothing()
= (this?.getTypeElement() as? JetUserType)?.getReferencedName() == "Nothing" = (this?.getTypeElement() as? JetUserType)?.getReferencedName() == "Nothing"
@@ -34,7 +34,7 @@ public class KotlinFunctionStubImpl extends KotlinStubBaseImpl<JetNamedFunction>
private final boolean hasBlockBody; private final boolean hasBlockBody;
private final boolean hasBody; private final boolean hasBody;
private final boolean hasTypeParameterListBeforeFunctionName; private final boolean hasTypeParameterListBeforeFunctionName;
private final boolean possiblyNothingType; private final boolean probablyNothingType;
public KotlinFunctionStubImpl( public KotlinFunctionStubImpl(
@NotNull StubElement parent, @NotNull StubElement parent,
@@ -45,7 +45,7 @@ public class KotlinFunctionStubImpl extends KotlinStubBaseImpl<JetNamedFunction>
boolean hasBlockBody, boolean hasBlockBody,
boolean hasBody, boolean hasBody,
boolean hasTypeParameterListBeforeFunctionName, boolean hasTypeParameterListBeforeFunctionName,
boolean possiblyNothingType boolean probablyNothingType
) { ) {
super(parent, JetStubElementTypes.FUNCTION); super(parent, JetStubElementTypes.FUNCTION);
@@ -60,7 +60,7 @@ public class KotlinFunctionStubImpl extends KotlinStubBaseImpl<JetNamedFunction>
this.hasBlockBody = hasBlockBody; this.hasBlockBody = hasBlockBody;
this.hasBody = hasBody; this.hasBody = hasBody;
this.hasTypeParameterListBeforeFunctionName = hasTypeParameterListBeforeFunctionName; this.hasTypeParameterListBeforeFunctionName = hasTypeParameterListBeforeFunctionName;
this.possiblyNothingType = possiblyNothingType; this.probablyNothingType = probablyNothingType;
} }
@Override @Override
@@ -100,7 +100,7 @@ public class KotlinFunctionStubImpl extends KotlinStubBaseImpl<JetNamedFunction>
} }
@Override @Override
public boolean isPossiblyNothingType() { public boolean isProbablyNothingType() {
return possiblyNothingType; return probablyNothingType;
} }
} }
@@ -33,7 +33,7 @@ public class KotlinPropertyStubImpl extends KotlinStubBaseImpl<JetProperty> impl
private final boolean hasInitializer; private final boolean hasInitializer;
private final boolean hasReceiverTypeRef; private final boolean hasReceiverTypeRef;
private final boolean hasReturnTypeRef; private final boolean hasReturnTypeRef;
private final boolean possiblyNothingType; private final boolean probablyNothingType;
private final FqName fqName; private final FqName fqName;
public KotlinPropertyStubImpl( public KotlinPropertyStubImpl(
@@ -46,7 +46,7 @@ public class KotlinPropertyStubImpl extends KotlinStubBaseImpl<JetProperty> impl
boolean hasInitializer, boolean hasInitializer,
boolean hasReceiverTypeRef, boolean hasReceiverTypeRef,
boolean hasReturnTypeRef, boolean hasReturnTypeRef,
boolean possiblyNothingType, boolean probablyNothingType,
@Nullable FqName fqName @Nullable FqName fqName
) { ) {
super(parent, JetStubElementTypes.PROPERTY); super(parent, JetStubElementTypes.PROPERTY);
@@ -66,7 +66,7 @@ public class KotlinPropertyStubImpl extends KotlinStubBaseImpl<JetProperty> impl
this.hasInitializer = hasInitializer; this.hasInitializer = hasInitializer;
this.hasReceiverTypeRef = hasReceiverTypeRef; this.hasReceiverTypeRef = hasReceiverTypeRef;
this.hasReturnTypeRef = hasReturnTypeRef; this.hasReturnTypeRef = hasReturnTypeRef;
this.possiblyNothingType = possiblyNothingType; this.probablyNothingType = probablyNothingType;
this.fqName = fqName; this.fqName = fqName;
} }
@@ -106,8 +106,8 @@ public class KotlinPropertyStubImpl extends KotlinStubBaseImpl<JetProperty> impl
} }
@Override @Override
public boolean isPossiblyNothingType() { public boolean isProbablyNothingType() {
return possiblyNothingType; return probablyNothingType;
} }
@Nullable @Nullable
@@ -70,7 +70,7 @@ public abstract class ElementResolver {
} }
@NotNull @NotNull
protected PossiblyNothingCallableNamesService possiblyNothingCallableNamesService() { protected ProbablyNothingCallableNamesService probablyNothingCallableNamesService() {
return DefaultNothingCallableNamesService.INSTANCE$; return DefaultNothingCallableNamesService.INSTANCE$;
} }
@@ -101,7 +101,7 @@ public abstract class ElementResolver {
boolean inBody = body != null && PsiTreeUtil.isAncestor(body, jetElement, false); boolean inBody = body != null && PsiTreeUtil.isAncestor(body, jetElement, false);
Function1<JetElement, Boolean> filter; Function1<JetElement, Boolean> filter;
if (inBody) { if (inBody) {
filter = new PartialBodyResolveFilter(jetElement, body, possiblyNothingCallableNamesService()); filter = new PartialBodyResolveFilter(jetElement, body, probablyNothingCallableNamesService());
} }
else { // do as less as possible body-resolve else { // do as less as possible body-resolve
filter = new Function1<JetElement, Boolean>() { filter = new Function1<JetElement, Boolean>() {
@@ -30,13 +30,13 @@ import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
class PartialBodyResolveFilter( class PartialBodyResolveFilter(
elementToResolve: JetElement, elementToResolve: JetElement,
private val body: JetExpression, private val body: JetExpression,
possiblyNothingCallableNamesService: PossiblyNothingCallableNamesService probablyNothingCallableNamesService: ProbablyNothingCallableNamesService
) : (JetElement) -> Boolean { ) : (JetElement) -> Boolean {
private val statementsToResolve = HashSet<JetExpression>() private val statementsToResolve = HashSet<JetExpression>()
private val processedBlocks = HashSet<JetBlockExpression>() private val processedBlocks = HashSet<JetBlockExpression>()
private val possiblyNothingFunctionNames = possiblyNothingCallableNamesService.functionNames() private val nothingFunctionNames = probablyNothingCallableNamesService.functionNames()
private val possiblyNothingPropertyNames = possiblyNothingCallableNamesService.propertyNames() private val nothingPropertyNames = probablyNothingCallableNamesService.propertyNames()
;{ ;{
assert(body.isAncestor(elementToResolve, strict = false)) assert(body.isAncestor(elementToResolve, strict = false))
@@ -286,7 +286,7 @@ class PartialBodyResolveFilter(
override fun visitCallExpression(expression: JetCallExpression) { override fun visitCallExpression(expression: JetCallExpression) {
val name = (expression.getCalleeExpression() as? JetSimpleNameExpression)?.getReferencedName() val name = (expression.getCalleeExpression() as? JetSimpleNameExpression)?.getReferencedName()
if (name != null && name in possiblyNothingFunctionNames) { if (name != null && name in nothingFunctionNames) {
result.add(expression) result.add(expression)
} }
super.visitCallExpression(expression) super.visitCallExpression(expression)
@@ -294,7 +294,7 @@ class PartialBodyResolveFilter(
override fun visitSimpleNameExpression(expression: JetSimpleNameExpression) { override fun visitSimpleNameExpression(expression: JetSimpleNameExpression) {
val name = expression.getReferencedName() val name = expression.getReferencedName()
if (name in possiblyNothingPropertyNames) { if (name in nothingPropertyNames) {
result.add(expression) result.add(expression)
} }
} }
@@ -16,12 +16,12 @@
package org.jetbrains.jet.lang.resolve.lazy package org.jetbrains.jet.lang.resolve.lazy
public trait PossiblyNothingCallableNamesService { public trait ProbablyNothingCallableNamesService {
public fun functionNames(): Set<String> public fun functionNames(): Set<String>
public fun propertyNames(): Set<String> public fun propertyNames(): Set<String>
} }
public object DefaultNothingCallableNamesService : PossiblyNothingCallableNamesService { public object DefaultNothingCallableNamesService : ProbablyNothingCallableNamesService {
private val hardcodedNames = setOf("error") private val hardcodedNames = setOf("error")
override fun functionNames() = hardcodedNames override fun functionNames() = hardcodedNames
@@ -30,10 +30,10 @@ import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.lazy.DefaultNothingCallableNamesService; import org.jetbrains.jet.lang.resolve.lazy.DefaultNothingCallableNamesService;
import org.jetbrains.jet.lang.resolve.lazy.ElementResolver; import org.jetbrains.jet.lang.resolve.lazy.ElementResolver;
import org.jetbrains.jet.lang.resolve.lazy.PossiblyNothingCallableNamesService; import org.jetbrains.jet.lang.resolve.lazy.ProbablyNothingCallableNamesService;
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession; import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
import org.jetbrains.jet.plugin.stubindex.JetPossiblyNothingFunctionShortNameIndex; import org.jetbrains.jet.plugin.stubindex.JetProbablyNothingFunctionShortNameIndex;
import org.jetbrains.jet.plugin.stubindex.JetPossiblyNothingPropertyShortNameIndex; import org.jetbrains.jet.plugin.stubindex.JetProbablyNothingPropertyShortNameIndex;
import org.jetbrains.jet.storage.LazyResolveStorageManager; import org.jetbrains.jet.storage.LazyResolveStorageManager;
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull; import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
@@ -87,14 +87,14 @@ public class ResolveElementCache extends ElementResolver {
@NotNull @NotNull
@Override @Override
protected PossiblyNothingCallableNamesService possiblyNothingCallableNamesService() { protected ProbablyNothingCallableNamesService probablyNothingCallableNamesService() {
return new PossiblyNothingCallableNamesService() { return new ProbablyNothingCallableNamesService() {
@NotNull @NotNull
@Override @Override
public Set<String> functionNames() { public Set<String> functionNames() {
// we have to add hardcoded-names until we have Kotlin compiled classes in caches // we have to add hardcoded-names until we have Kotlin compiled classes in caches
Set<String> hardcodedNames = DefaultNothingCallableNamesService.INSTANCE$.functionNames(); Set<String> hardcodedNames = DefaultNothingCallableNamesService.INSTANCE$.functionNames();
Collection<String> indexedNames = JetPossiblyNothingFunctionShortNameIndex.getInstance().getAllKeys(project); Collection<String> indexedNames = JetProbablyNothingFunctionShortNameIndex.getInstance().getAllKeys(project);
Set<String> set = new HashSet<String>(hardcodedNames.size() + indexedNames.size()); Set<String> set = new HashSet<String>(hardcodedNames.size() + indexedNames.size());
set.addAll(hardcodedNames); set.addAll(hardcodedNames);
set.addAll(indexedNames); set.addAll(indexedNames);
@@ -105,7 +105,7 @@ public class ResolveElementCache extends ElementResolver {
@NotNull @NotNull
@Override @Override
public Set<String> propertyNames() { public Set<String> propertyNames() {
return new HashSet<String>(JetPossiblyNothingPropertyShortNameIndex.getInstance().getAllKeys(project)); return new HashSet<String>(JetProbablyNothingPropertyShortNameIndex.getInstance().getAllKeys(project));
} }
}; };
} }
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction;
import java.util.Collection; import java.util.Collection;
public class JetPossiblyNothingFunctionShortNameIndex extends StringStubIndexExtension<JetNamedFunction> { public class JetProbablyNothingFunctionShortNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetPossiblyNothingFunctionShortNameIndex.class); private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetProbablyNothingFunctionShortNameIndex.class);
private static final JetPossiblyNothingFunctionShortNameIndex ourInstance = new JetPossiblyNothingFunctionShortNameIndex(); private static final JetProbablyNothingFunctionShortNameIndex ourInstance = new JetProbablyNothingFunctionShortNameIndex();
public static JetPossiblyNothingFunctionShortNameIndex getInstance() { public static JetProbablyNothingFunctionShortNameIndex getInstance() {
return ourInstance; return ourInstance;
} }
private JetPossiblyNothingFunctionShortNameIndex() {} private JetProbablyNothingFunctionShortNameIndex() {}
@NotNull @NotNull
@Override @Override
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetProperty;
import java.util.Collection; import java.util.Collection;
public class JetPossiblyNothingPropertyShortNameIndex extends StringStubIndexExtension<JetProperty> { public class JetProbablyNothingPropertyShortNameIndex extends StringStubIndexExtension<JetProperty> {
private static final StubIndexKey<String, JetProperty> KEY = KotlinIndexUtil.createIndexKey(JetPossiblyNothingPropertyShortNameIndex.class); private static final StubIndexKey<String, JetProperty> KEY = KotlinIndexUtil.createIndexKey(JetProbablyNothingPropertyShortNameIndex.class);
private static final JetPossiblyNothingPropertyShortNameIndex ourInstance = new JetPossiblyNothingPropertyShortNameIndex(); private static final JetProbablyNothingPropertyShortNameIndex ourInstance = new JetProbablyNothingPropertyShortNameIndex();
public static JetPossiblyNothingPropertyShortNameIndex getInstance() { public static JetProbablyNothingPropertyShortNameIndex getInstance() {
return ourInstance; return ourInstance;
} }
private JetPossiblyNothingPropertyShortNameIndex() {} private JetProbablyNothingPropertyShortNameIndex() {}
@NotNull @NotNull
@Override @Override
@@ -114,8 +114,8 @@ public class StubIndexServiceImpl implements StubIndexService {
} }
sink.occurrence(JetFunctionShortNameIndex.getInstance().getKey(), name); sink.occurrence(JetFunctionShortNameIndex.getInstance().getKey(), name);
if (stub.isPossiblyNothingType()) { if (stub.isProbablyNothingType()) {
sink.occurrence(JetPossiblyNothingFunctionShortNameIndex.getInstance().getKey(), name); sink.occurrence(JetProbablyNothingFunctionShortNameIndex.getInstance().getKey(), name);
} }
} }
// can have special fq name in case of syntactically incorrect function with no name // can have special fq name in case of syntactically incorrect function with no name
@@ -141,8 +141,8 @@ public class StubIndexServiceImpl implements StubIndexService {
sink.occurrence(JetPropertyShortNameIndex.getInstance().getKey(), name); sink.occurrence(JetPropertyShortNameIndex.getInstance().getKey(), name);
if (stub.isPossiblyNothingType()) { if (stub.isProbablyNothingType()) {
sink.occurrence(JetPossiblyNothingPropertyShortNameIndex.getInstance().getKey(), name); sink.occurrence(JetProbablyNothingPropertyShortNameIndex.getInstance().getKey(), name);
} }
} }
// can have special fq name in case of syntactically incorrect function with no name // can have special fq name in case of syntactically incorrect function with no name
+2 -2
View File
@@ -395,8 +395,8 @@
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelPropertiesFqnNameIndex"/> <stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelPropertiesFqnNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetAnnotationsIndex"/> <stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetAnnotationsIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelObjectShortNameIndex"/> <stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelObjectShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetPossiblyNothingFunctionShortNameIndex"/> <stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetProbablyNothingFunctionShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetPossiblyNothingPropertyShortNameIndex"/> <stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetProbablyNothingPropertyShortNameIndex"/>
<psi.classFileDecompiler implementation="org.jetbrains.jet.plugin.decompiler.JetClassFileDecompiler"/> <psi.classFileDecompiler implementation="org.jetbrains.jet.plugin.decompiler.JetClassFileDecompiler"/>