001 /* 002 * Copyright 2010-2015 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.jetbrains.kotlin.resolve; 018 019 import com.google.common.base.Predicate; 020 import com.intellij.psi.PsiFile; 021 import org.jetbrains.annotations.NotNull; 022 import org.jetbrains.kotlin.context.GlobalContext; 023 import org.jetbrains.kotlin.context.LazinessToken; 024 import org.jetbrains.kotlin.storage.ExceptionTracker; 025 import org.jetbrains.kotlin.storage.StorageManager; 026 027 /** 028 * Various junk that cannot be placed into context (yet). 029 */ 030 public class TopDownAnalysisParameters extends LazinessToken implements GlobalContext { 031 @Deprecated 032 public static final boolean LAZY; 033 034 static { 035 LAZY = !"false".equals(System.getProperty("lazy.tda")); 036 } 037 038 @NotNull 039 public static TopDownAnalysisParameters create( 040 @NotNull StorageManager storageManager, 041 @NotNull ExceptionTracker exceptionTracker, 042 @NotNull Predicate<PsiFile> analyzeCompletely, 043 boolean analyzingBootstrapLibrary, 044 boolean declaredLocally 045 ) { 046 return new TopDownAnalysisParameters(storageManager, exceptionTracker, analyzeCompletely, analyzingBootstrapLibrary, 047 declaredLocally, LAZY); 048 } 049 050 @NotNull 051 public static TopDownAnalysisParameters createForLocalDeclarations( 052 @NotNull StorageManager storageManager, 053 @NotNull ExceptionTracker exceptionTracker, 054 @NotNull Predicate<PsiFile> analyzeCompletely 055 ) { 056 return new TopDownAnalysisParameters(storageManager, exceptionTracker, analyzeCompletely, false, true, false); 057 } 058 059 @NotNull private final StorageManager storageManager; 060 @NotNull private final ExceptionTracker exceptionTracker; 061 @NotNull private final Predicate<PsiFile> analyzeCompletely; 062 private final boolean analyzingBootstrapLibrary; 063 private final boolean declaredLocally; 064 private final boolean lazyTopDownAnalysis; 065 066 private TopDownAnalysisParameters( 067 @NotNull StorageManager storageManager, 068 @NotNull ExceptionTracker exceptionTracker, 069 @NotNull Predicate<PsiFile> analyzeCompletely, 070 boolean analyzingBootstrapLibrary, 071 boolean declaredLocally, 072 boolean lazyTopDownAnalysis 073 ) { 074 this.storageManager = storageManager; 075 this.exceptionTracker = exceptionTracker; 076 this.analyzeCompletely = analyzeCompletely; 077 this.analyzingBootstrapLibrary = analyzingBootstrapLibrary; 078 this.declaredLocally = declaredLocally; 079 this.lazyTopDownAnalysis = lazyTopDownAnalysis; 080 } 081 082 @Override 083 @NotNull 084 public StorageManager getStorageManager() { 085 return storageManager; 086 } 087 088 @Override 089 @NotNull 090 public ExceptionTracker getExceptionTracker() { 091 return exceptionTracker; 092 } 093 094 @NotNull 095 public Predicate<PsiFile> getAnalyzeCompletely() { 096 return analyzeCompletely; 097 } 098 099 public boolean isAnalyzingBootstrapLibrary() { 100 return analyzingBootstrapLibrary; 101 } 102 103 public boolean isDeclaredLocally() { 104 return declaredLocally; 105 } 106 107 // Used temporarily while we are transitioning from eager to lazy analysis of headers in the IDE 108 @Override 109 @Deprecated 110 public boolean isLazy() { 111 return lazyTopDownAnalysis; 112 } 113 }