Remove obsolete SCRIPT markers
This commit is contained in:
@@ -2579,7 +2579,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
else if (receiverValue instanceof ScriptReceiver) {
|
||||
// SCRIPT: generate script
|
||||
return generateScript((ScriptReceiver) receiverValue);
|
||||
}
|
||||
else if (receiverValue instanceof ExtensionReceiver) {
|
||||
@@ -2598,7 +2597,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return context.generateReceiver(descriptor, state, false);
|
||||
}
|
||||
|
||||
// SCRIPT: generate script, move to ScriptingUtil
|
||||
private StackValue generateScript(@NotNull ScriptReceiver receiver) {
|
||||
CodegenContext cur = context;
|
||||
StackValue result = StackValue.LOCAL_0;
|
||||
@@ -3393,7 +3391,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
Type varType = asmType(variableDescriptor.getType());
|
||||
|
||||
StackValue storeTo;
|
||||
// SCRIPT: Variable at the top of the script is generated as field
|
||||
if (KtPsiUtil.isScriptDeclaration(variableDeclaration)) {
|
||||
KtScript scriptPsi = KtPsiUtil.getScript(variableDeclaration);
|
||||
assert scriptPsi != null;
|
||||
|
||||
@@ -21,14 +21,16 @@ import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtScript;
|
||||
import org.jetbrains.kotlin.resolve.ScriptNameUtil;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.registerClassNameForScript;
|
||||
|
||||
@@ -37,7 +39,6 @@ public class KotlinCodegenFacade {
|
||||
public static void prepareForCompilation(@NotNull GenerationState state) {
|
||||
for (KtFile file : state.getFiles()) {
|
||||
if (file.isScript()) {
|
||||
// SCRIPT: register class name for scripting from this file, move outside of this function
|
||||
KtScript script = file.getScript();
|
||||
assert script != null;
|
||||
|
||||
|
||||
@@ -162,17 +162,14 @@ public class MultifileClassCodegen(
|
||||
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, file)
|
||||
|
||||
for (declaration in file.declarations) {
|
||||
if (declaration is KtProperty || declaration is KtNamedFunction) {
|
||||
generatePart = true
|
||||
}
|
||||
else if (declaration is KtClassOrObject) {
|
||||
if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
|
||||
when (declaration) {
|
||||
is KtProperty, is KtNamedFunction -> {
|
||||
generatePart = true
|
||||
}
|
||||
is KtClassOrObject -> if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
|
||||
generateClassOrObject(declaration, partContext)
|
||||
}
|
||||
}
|
||||
else if (declaration is KtScript) {
|
||||
// SCRIPT: generate script code, should be separate execution branch
|
||||
if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
|
||||
is KtScript -> if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
|
||||
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,6 @@ public class PackageCodegen {
|
||||
else if (declaration instanceof KtScript) {
|
||||
KtScript script = (KtScript) declaration;
|
||||
|
||||
// SCRIPT: generate script code, should be separate execution branch
|
||||
if (state.getGenerateDeclaredClassFilter().shouldGenerateScript(script)) {
|
||||
ScriptCodegen.createScriptCodegen(script, state, packagePartContext).generate();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
// SCRIPT: script code generator
|
||||
public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
|
||||
public static ScriptCodegen createScriptCodegen(
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
@Override
|
||||
public void visitJetFile(@NotNull KtFile file) {
|
||||
if (file.isScript()) {
|
||||
// SCRIPT: should be replaced with VisitScript override
|
||||
// TODO: replace with visitScript override
|
||||
//noinspection ConstantConditions
|
||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS_FOR_SCRIPT, bindingContext.get(SCRIPT, file.getScript()));
|
||||
classStack.push(classDescriptor);
|
||||
|
||||
@@ -89,7 +89,6 @@ public class CodegenBinding {
|
||||
return Boolean.TRUE.equals(bindingContext.get(ENUM_ENTRY_CLASS_NEED_SUBCLASS, classDescriptor));
|
||||
}
|
||||
|
||||
// SCRIPT: Generate asmType for script, move to ScriptingUtil
|
||||
@NotNull
|
||||
public static Type asmTypeForScriptDescriptor(BindingContext bindingContext, @NotNull ScriptDescriptor scriptDescriptor) {
|
||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS_FOR_SCRIPT, scriptDescriptor);
|
||||
@@ -97,7 +96,6 @@ public class CodegenBinding {
|
||||
return getAsmType(bindingContext, classDescriptor);
|
||||
}
|
||||
|
||||
// SCRIPT: Generate asmType for script, move to ScriptingUtil
|
||||
@NotNull
|
||||
public static Type asmTypeForScriptPsi(BindingContext bindingContext, @NotNull KtScript script) {
|
||||
ScriptDescriptor scriptDescriptor = bindingContext.get(SCRIPT, script);
|
||||
@@ -198,7 +196,6 @@ public class CodegenBinding {
|
||||
innerClasses.add(inner);
|
||||
}
|
||||
|
||||
// SCRIPT: register asmType for script, move to ScriptingUtil
|
||||
public static void registerClassNameForScript(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull KtScript script,
|
||||
@@ -227,15 +224,14 @@ public class CodegenBinding {
|
||||
// todo: we use Set and add given files but ignoring other scripts because something non-clear kept in binding
|
||||
// for scripts especially in case of REPL
|
||||
|
||||
// SCRIPT: collect fq names for files that are not scripts
|
||||
HashSet<FqName> names = new HashSet<FqName>();
|
||||
Set<FqName> names = new HashSet<FqName>();
|
||||
for (KtFile file : files) {
|
||||
if (!file.isScript()) {
|
||||
names.add(file.getPackageFqName());
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<KtFile> answer = new HashSet<KtFile>();
|
||||
Set<KtFile> answer = new HashSet<KtFile>();
|
||||
answer.addAll(files);
|
||||
|
||||
for (FqName name : names) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.*;
|
||||
@@ -312,7 +311,6 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
return new ConstructorContext(descriptor, getContextKind(), this, closure);
|
||||
}
|
||||
|
||||
// SCRIPT: generate into script, move to ScriptingUtil
|
||||
@NotNull
|
||||
public ScriptContext intoScript(
|
||||
@NotNull ScriptDescriptor script,
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// SCRIPT: script as field owner context
|
||||
public class ScriptContext extends FieldOwnerContext<ClassDescriptor> {
|
||||
private final ScriptDescriptor scriptDescriptor;
|
||||
private final List<ScriptDescriptor> earlierScripts;
|
||||
|
||||
@@ -155,7 +155,6 @@ public interface KtNodeTypes {
|
||||
|
||||
IElementType PACKAGE_DIRECTIVE = KtStubElementTypes.PACKAGE_DIRECTIVE;
|
||||
|
||||
// SCRIPT: script node type
|
||||
KtNodeType SCRIPT = new KtNodeType("SCRIPT", KtScript.class);
|
||||
|
||||
IFileElementType TYPE_CODE_FRAGMENT = new KtTypeCodeFragmentType();
|
||||
|
||||
@@ -172,7 +172,6 @@ public class KtFile extends PsiFileBase implements KtDeclarationContainer, KtAnn
|
||||
@Override
|
||||
public void setPackageName(String packageName) { }
|
||||
|
||||
// SCRIPT: find script in file
|
||||
@Nullable
|
||||
public KtScript getScript() {
|
||||
return PsiTreeUtil.getChildOfType(this, KtScript.class);
|
||||
|
||||
@@ -280,12 +280,10 @@ public class KtPsiUtil {
|
||||
return qualifiedParent.getReceiverExpression() == expression || isLHSOfDot(qualifiedParent);
|
||||
}
|
||||
|
||||
// SCRIPT: is declaration in script?
|
||||
public static boolean isScriptDeclaration(@NotNull KtDeclaration namedDeclaration) {
|
||||
return getScript(namedDeclaration) != null;
|
||||
}
|
||||
|
||||
// SCRIPT: get script from top-level declaration
|
||||
@Nullable
|
||||
public static KtScript getScript(@NotNull KtDeclaration namedDeclaration) {
|
||||
PsiElement parent = namedDeclaration.getParent();
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// SCRIPT: Script declaration
|
||||
public class KtScript extends KtDeclarationImpl implements KtDeclarationContainer {
|
||||
|
||||
public KtScript(@NotNull ASTNode node) {
|
||||
|
||||
@@ -23,13 +23,11 @@ import com.intellij.psi.stubs.PsiFileStubImpl
|
||||
import com.intellij.psi.tree.IStubFileElementType
|
||||
import com.intellij.util.io.StringRef
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinFileStub
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinImportDirectiveStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
|
||||
// SCRIPT: PsiJetFileStubImpl knows about scripting
|
||||
public open class KotlinFileStubImpl(
|
||||
jetFile: KtFile?,
|
||||
private val packageName: StringRef,
|
||||
|
||||
@@ -112,7 +112,6 @@ public class BodyResolver {
|
||||
|
||||
resolveFunctionBodies(c);
|
||||
|
||||
// SCRIPT: resolve script bodies
|
||||
scriptBodyResolverResolver.resolveScriptBodies(c);
|
||||
|
||||
if (!c.getTopDownAnalysisMode().isLocalDeclarations()) {
|
||||
|
||||
@@ -649,7 +649,6 @@ public class DescriptorResolver {
|
||||
DeclarationDescriptor containingDeclaration = scope.getOwnerDescriptor();
|
||||
VariableDescriptor result;
|
||||
KotlinType type;
|
||||
// SCRIPT: Create property descriptors
|
||||
if (KtPsiUtil.isScriptDeclaration(variable)) {
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
containingDeclaration,
|
||||
|
||||
@@ -33,10 +33,8 @@ import java.util.Map;
|
||||
|
||||
import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
|
||||
// SCRIPT: resolve symbols in scripts
|
||||
public class ScriptBodyResolver {
|
||||
|
||||
@NotNull private final ExpressionTypingServices expressionTypingServices;
|
||||
private final ExpressionTypingServices expressionTypingServices;
|
||||
|
||||
public ScriptBodyResolver(
|
||||
@NotNull ExpressionTypingServices expressionTypingServices
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.psi.KtScript;
|
||||
|
||||
// SCRIPT: Resolve declarations in scripts
|
||||
public class ScriptPriorities {
|
||||
|
||||
public static final Key<Integer> PRIORITY_KEY = Key.create(KtScript.class.getName() + ".priority");
|
||||
|
||||
@@ -158,7 +158,6 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
|
||||
@NotNull
|
||||
public Collection<ClassDescriptorWithResolutionScopes> getAllClasses() {
|
||||
// SCRIPT: all classes are declared classes + script classes
|
||||
Collection<ClassDescriptorWithResolutionScopes> scriptClasses = CollectionsKt.map(
|
||||
getScripts().values(),
|
||||
new Function1<ScriptDescriptor, ClassDescriptorWithResolutionScopes>() {
|
||||
|
||||
+1
-2
@@ -33,8 +33,8 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue.Kind;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
@@ -125,7 +125,6 @@ public class DataFlowValueFactory {
|
||||
@NotNull DeclarationDescriptor containingDeclarationOrModule
|
||||
) {
|
||||
if (receiverValue instanceof TransientReceiver || receiverValue instanceof ScriptReceiver) {
|
||||
// SCRIPT: smartcasts data flow
|
||||
KotlinType type = receiverValue.getType();
|
||||
return new DataFlowValue(receiverValue, type, STABLE_VALUE, getImmanentNullability(type));
|
||||
}
|
||||
|
||||
-1
@@ -55,7 +55,6 @@ protected constructor(
|
||||
|
||||
private fun resolveClassDescriptor(name: Name): List<ClassDescriptor> {
|
||||
return declarationProvider.getClassOrObjectDeclarations(name).map {
|
||||
// SCRIPT: Creating a script class
|
||||
if (it is JetScriptInfo)
|
||||
LazyScriptClassDescriptor(c as ResolveSession, thisDescriptor, name, it)
|
||||
else
|
||||
|
||||
-1
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProv
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
|
||||
// SCRIPT: Members of a script class
|
||||
public class LazyScriptClassMemberScope protected constructor(
|
||||
private val resolveSession: ResolveSession,
|
||||
declarationProvider: ClassMemberDeclarationProvider,
|
||||
|
||||
-4
@@ -21,17 +21,13 @@ import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
// SCRIPT: script receiver
|
||||
public class ScriptReceiver implements ThisReceiver {
|
||||
|
||||
@NotNull
|
||||
private final ScriptDescriptor scriptDescriptor;
|
||||
|
||||
public ScriptReceiver(@NotNull ScriptDescriptor scriptDescriptor) {
|
||||
this.scriptDescriptor = scriptDescriptor;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ScriptDescriptor getDeclarationDescriptor() {
|
||||
|
||||
-1
@@ -159,7 +159,6 @@ public class ExpressionTypingServices {
|
||||
) {
|
||||
List<KtExpression> block = StatementFilterKt.filterStatements(statementFilter, expression);
|
||||
|
||||
// SCRIPT: get code descriptor for script declaration
|
||||
DeclarationDescriptor containingDescriptor = context.scope.getOwnerDescriptor();
|
||||
if (containingDescriptor instanceof ScriptDescriptor) {
|
||||
if (!(expression.getParent() instanceof KtScript)) {
|
||||
|
||||
@@ -120,7 +120,6 @@ public class CodegenTestFiles {
|
||||
List<AnalyzerScriptParameter> scriptParameterTypes = Lists.newArrayList();
|
||||
List<Object> scriptParameterValues = Lists.newArrayList();
|
||||
|
||||
// SCRIPT: extract script params, move to ScriptingUtil
|
||||
if (file.isScript()) {
|
||||
Pattern scriptParametersPattern = Pattern.compile("param: (\\S+): (\\S+): (\\S.*)");
|
||||
Matcher scriptParametersMatcher = scriptParametersPattern.matcher(file.getText());
|
||||
|
||||
-4
@@ -37,8 +37,6 @@ import org.jetbrains.kotlin.idea.stubindex.*
|
||||
import org.jetbrains.kotlin.idea.stubindex.JetSourceFilterScope.kotlinSourceAndClassFiles
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||
@@ -205,10 +203,8 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun forceResolvePackageDeclarations(files: Collection<KtFile>, session: ResolveSession) {
|
||||
for (file in files) {
|
||||
// SCRIPT: not supported
|
||||
if (file.isScript) continue
|
||||
|
||||
val packageFqName = file.packageFqName
|
||||
|
||||
@@ -436,7 +436,6 @@ public class JetBlock extends AbstractBlock {
|
||||
ASTNode childParent = child.getTreeParent();
|
||||
IElementType childType = child.getElementType();
|
||||
|
||||
// SCRIPT: Avoid indenting script top BLOCK contents
|
||||
if (childParent != null && childParent.getTreeParent() != null) {
|
||||
if (childParent.getElementType() == BLOCK && childParent.getTreeParent().getElementType() == SCRIPT) {
|
||||
return Indent.getNoneIndent();
|
||||
|
||||
Reference in New Issue
Block a user