Support static class scope in frontend, JVM codegen and IDE

This commit is contained in:
Alexander Udalov
2014-09-03 15:14:59 +04:00
parent cb81023469
commit 8ccca1781d
12 changed files with 84 additions and 54 deletions
@@ -77,21 +77,22 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
super.visitParameter(parameter);
}
private void highlightProperty(@NotNull PsiElement elementToHighlight,
private void highlightProperty(
@NotNull PsiElement elementToHighlight,
@NotNull PropertyDescriptor descriptor,
boolean withBackingField) {
boolean inPackage = DescriptorUtils.isTopLevelDeclaration(descriptor);
JetPsiChecker.highlightName(holder, elementToHighlight,
inPackage ? JetHighlightingColors.PACKAGE_PROPERTY : JetHighlightingColors.INSTANCE_PROPERTY
boolean withBackingField
) {
boolean isStatic = DescriptorUtils.isStaticDeclaration(descriptor);
JetPsiChecker.highlightName(
holder, elementToHighlight,
isStatic ? JetHighlightingColors.PACKAGE_PROPERTY : JetHighlightingColors.INSTANCE_PROPERTY
);
if (descriptor.getReceiverParameter() != null) {
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.EXTENSION_PROPERTY);
}
if (withBackingField) {
holder.createInfoAnnotation(
elementToHighlight,
"This property has a backing field")
.setTextAttributes(JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD);
holder.createInfoAnnotation(elementToHighlight, "This property has a backing field")
.setTextAttributes(JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD);
}
}
}
@@ -39,7 +39,9 @@ public val DeclarationDescriptor.importableFqNameSafe: FqName
get() = DescriptorUtils.getFqNameSafe(getImportableDescriptor())
public fun DeclarationDescriptor.canBeReferencedViaImport(): Boolean {
if (this is PackageViewDescriptor || DescriptorUtils.isTopLevelDeclaration(this)) {
if (this is PackageViewDescriptor ||
DescriptorUtils.isTopLevelDeclaration(this) ||
(this is CallableDescriptor && DescriptorUtils.isStaticDeclaration(this))) {
return true
}
val parent = getContainingDeclaration()!!