From 43a6e13f4bb916bb40321e94371a632e8630359d Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 7 Jan 2016 18:12:30 +0100 Subject: [PATCH] idea: cleanup 'public', property access syntax --- .../kotlin/idea/resolve/ResolutionFacade.kt | 24 +-- .../jetbrains/kotlin/idea/util/CallType.kt | 10 +- .../jetbrains/kotlin/idea/util/FuzzyType.kt | 32 +-- .../idea/util/IdeDescriptorRenderers.kt | 17 +- .../kotlin/idea/util/ImportsUtils.kt | 14 +- .../idea/util/ShadowedDeclarationsFilter.kt | 32 +-- .../jetbrains/kotlin/idea/util/TypeUtils.kt | 32 +-- .../org/jetbrains/kotlin/idea/util/Utils.kt | 10 +- .../kotlin/idea/util/extensionsUtils.kt | 18 +- .../idea/util/implicitReceiversUtils.kt | 24 +-- .../jetbrains/kotlin/idea/util/scopeUtils.kt | 14 +- .../kotlin/resolve/lazy/BodyResolveMode.kt | 2 +- .../resolve/lazy/PartialBodyResolveFilter.kt | 92 ++++----- .../lazy/ProbablyNothingCallableNames.kt | 6 +- .../resolve/scopes/ExplicitImportsScope.kt | 12 +- .../jetbrains/kotlin/util/TypeIndexUtil.kt | 22 +-- .../jetbrains/kotlin/util/descriptorUtils.kt | 32 +-- .../kotlin/util/substitutionUtils.kt | 24 +-- .../actions/internal/KotlinInternalMode.kt | 6 +- .../kotlin/idea/analysis/AnalyzerUtil.kt | 11 +- .../idea/caches/FileAttributeService.kt | 2 +- .../kotlin/idea/caches/JarUserDataManager.kt | 18 +- .../idea/caches/KotlinShortNamesCache.kt | 4 +- .../resolve/ClsJavaStubByVirtualFileCache.kt | 6 +- .../caches/resolve/CodeFragmentAnalyzer.kt | 22 +-- .../resolve/IDELightClassGenerationSupport.kt | 4 +- .../caches/resolve/IDEPackagePartProvider.kt | 2 +- .../idea/caches/resolve/IdeaModuleInfos.kt | 54 ++--- .../caches/resolve/JavaResolveExtension.kt | 14 +- .../idea/caches/resolve/JsAnalyzerFacade.kt | 4 +- .../idea/caches/resolve/JsProjectDetector.kt | 7 +- .../idea/caches/resolve/KotlinCacheService.kt | 14 +- ...OutOfBlockCompletionModificationTracker.kt | 8 +- .../idea/caches/resolve/KotlinResolveCache.kt | 6 +- .../KtLightClassForDecompiledDeclaration.kt | 12 +- .../resolve/LibraryDependenciesCache.kt | 20 +- .../caches/resolve/ModuleDependencyMapper.kt | 12 +- .../caches/resolve/ProjectResolutionFacade.kt | 2 +- .../kotlin/idea/caches/resolve/cacheUtils.kt | 4 +- .../idea/caches/resolve/getModuleInfo.kt | 14 +- .../idea/caches/resolve/globalContextUtils.kt | 4 +- .../idea/caches/resolve/moduleDependents.kt | 14 +- .../idea/caches/resolve/resolutionApi.kt | 27 ++- .../codeInsight/DescriptorToSourceUtilsIde.kt | 8 +- .../KotlinFileReferencesResolver.kt | 16 +- .../codeInsight/shorten/shortenWaitingSet.kt | 16 +- .../idea/configuration/ModuleTypeCache.kt | 6 +- .../KotlinDecompiledFileViewProvider.kt | 6 +- .../idea/decompiler/KtDecompiledFile.kt | 14 +- .../builtIns/KotlinBuiltInDecompiler.kt | 2 +- .../KotlinBuiltInDeserializerForDecompiler.kt | 2 +- .../builtIns/KotlinBuiltInStubBuilder.kt | 2 +- .../idea/decompiler/builtIns/fileTypes.kt | 4 +- .../classFile/ClassFileDecompilerUtil.kt | 14 +- .../DeserializerForClassfileDecompiler.kt | 14 +- .../classFile/KotlinClassFileDecompiler.kt | 14 +- .../classFile/KotlinClsStubBuilder.kt | 20 +- .../AnnotationLoaderForStubBuilderImpl.kt | 2 +- .../idea/decompiler/js/JsMetaFileUtils.kt | 20 +- ...tlinJavaScriptDeserializerForDecompiler.kt | 2 +- .../js/KotlinJavaScriptMetaFileDecompiler.kt | 2 +- .../js/KotlinJavaScriptMetaFileType.kt | 2 +- .../js/KotlinJavaScriptStubBuilder.kt | 2 +- .../KotlinDeclarationNavigationPolicyImpl.kt | 2 +- .../stubBuilder/ClassClsStubBuilder.kt | 12 +- .../stubBuilder/ClsStubBuilderContext.kt | 2 +- .../stubBuilder/TypeClsStubBuilder.kt | 12 +- .../decompiler/stubBuilder/clsStubBuilding.kt | 4 +- .../textBuilder/DecompiledTextFactory.kt | 14 +- .../DeserializerForDecompilerBase.kt | 2 +- .../textBuilder/ResolverForDecompiler.kt | 6 +- .../textBuilder/missingDependencies.kt | 2 +- .../findUsages/KotlinFindUsagesProvider.kt | 18 +- .../kotlin/idea/findUsages/UsageTypeUtils.kt | 66 +++---- .../KotlinJavaScriptLibraryDetectionUtil.kt | 14 +- .../kotlin/idea/highlighter/IdeRenderers.kt | 41 ++-- .../KotlinBeforeResolveHighlightingPass.kt | 4 +- .../KotlinProblemHighlightFilter.kt | 2 +- .../idea/highlighter/KotlinPsiChecker.kt | 36 ++-- .../KotlinSuppressableWarningProblemGroup.kt | 16 +- .../idea/highlighter/NameHighlighter.kt | 6 +- .../kotlin/idea/highlighter/renderersUtil.kt | 34 ++-- .../inspections/AbstractKotlinInspection.kt | 8 +- .../inspections/IntentionBasedInspection.kt | 20 +- .../intentions/OperatorToFunctionIntention.kt | 62 +++--- .../idea/intentions/SelfTargetingIntention.kt | 22 +-- .../kotlin/idea/kdoc/KDocElementFactory.kt | 4 +- .../jetbrains/kotlin/idea/kdoc/KDocFinder.kt | 10 +- .../idea/kdoc/KDocHighlightingVisitor.kt | 2 +- .../kotlin/idea/kdoc/KDocReference.kt | 8 +- .../kdoc/KDocUnresolvedReferenceInspection.kt | 2 +- .../idea/project/AnalyzerFacadeProvider.kt | 4 +- .../kotlin/idea/project/IdeaEnvironment.kt | 2 +- .../project/IdeaLocalDescriptorResolver.kt | 2 +- .../idea/project/ResolveElementCache.kt | 42 ++-- .../quickfix/KotlinIntentionActionsFactory.kt | 8 +- .../quickfix/KotlinSuppressIntentionAction.kt | 26 +-- .../kotlin/idea/quickfix/QuickFixes.kt | 16 +- .../kotlin/idea/quickfix/generateUtil.kt | 34 ++-- .../idea/refactoring/fqName/fqNameUtil.kt | 20 +- .../references/KotlinReferenceContributor.kt | 4 +- .../KtDestructuringDeclarationReference.kt | 12 +- .../idea/references/KtForLoopInReference.kt | 12 +- .../KtPropertyDelegationMethodsReference.kt | 14 +- .../kotlin/idea/references/KtReference.kt | 20 +- .../idea/references/KtSimpleNameReference.kt | 26 +-- .../SyntheticPropertyAccessorReference.kt | 8 +- .../kotlin/idea/references/referenceUtil.kt | 42 ++-- .../idea/search/KotlinIndexPatternBuilder.kt | 2 +- .../classInheritorsSearch.kt | 2 +- .../declarationSearchUtil.kt | 8 +- .../declarationsSearch/overridersSearch.kt | 10 +- .../KotlinReadWriteAccessDetector.kt | 2 +- .../KotlinReferencesSearcher.kt | 24 +-- .../kotlin/idea/search/searchUtil.kt | 8 +- .../idea/search/usagesSearch/conventions.kt | 12 +- .../idea/search/usagesSearch/searchHelpers.kt | 16 +- .../kotlin/idea/search/usagesSearch/utils.kt | 26 +-- .../KotlinInheritedMembersNodeProvider.kt | 4 +- .../KtClsStructureViewBuilderProvider.kt | 2 +- .../kotlin/idea/stubindex/IndexUtils.kt | 18 +- .../KotlinFileFacadeClassByPackageIndex.kt | 8 +- .../stubindex/KotlinFileFacadeFqNameIndex.kt | 8 +- .../KotlinFileFacadeShortNameIndex.kt | 8 +- .../stubindex/KotlinFilePartClassIndex.kt | 8 +- .../idea/stubindex/KotlinFileStubForIde.kt | 10 +- .../KotlinMultifileClassPartIndex.kt | 8 +- ...inTopLevelExtensionsByReceiverTypeIndex.kt | 10 +- .../kotlin/idea/stubindex/PackageIndexUtil.kt | 16 +- .../idea/stubindex/StaticFacadeIndexUtil.kt | 7 +- .../idea/stubindex/SubpackagesIndexService.kt | 10 +- .../PluginDeclarationProviderFactory.kt | 2 +- ...PluginDeclarationProviderFactoryService.kt | 2 +- ...ubBasedPackageMemberDeclarationProvider.kt | 4 +- .../kotlin/idea/util/ApplicationUtils.kt | 10 +- .../kotlin/idea/util/CommentSaver.kt | 54 ++--- .../kotlin/idea/util/ImportInsertHelper.kt | 3 +- .../kotlin/idea/util/ProjectRootsUtil.kt | 44 ++--- .../kotlin/idea/util/PsiPrecedences.kt | 16 +- .../kotlin/idea/util/ShortenReferences.kt | 84 ++++---- .../jetbrains/kotlin/idea/util/dumbUtils.kt | 6 +- .../idea/vfilefinder/IDEVirtualFileFinder.kt | 4 +- .../idea/vfilefinder/JsVirtualFileFinder.kt | 7 +- .../vfilefinder/JsVirtualFileFinderFactory.kt | 7 +- .../kotlin/idea/vfilefinder/factories.kt | 4 +- .../kotlin/idea/vfilefinder/fileFinders.kt | 6 +- .../kotlin/idea/vfilefinder/fileIndexes.kt | 6 +- .../idea/vfilefinder/moduleMappingIndexes.kt | 8 +- .../SimpleNameReferenceExtension.kt | 4 +- .../idea/completion/AllClassesCompletion.kt | 10 +- .../completion/BasicLookupElementFactory.kt | 44 ++--- .../idea/completion/CompletionSession.kt | 26 +-- .../kotlin/idea/completion/CompletionUtils.kt | 42 ++-- .../completion/ContextVariablesProvider.kt | 2 +- .../DataFlowInfoUtilForCompletion.kt | 6 +- .../completion/DeclarationLookupObjectImpl.kt | 14 +- .../idea/completion/InsertHandlerProvider.kt | 4 +- .../completion/KDocCompletionContributor.kt | 8 +- .../idea/completion/KeywordCompletion.kt | 44 ++--- .../kotlin/idea/completion/KeywordValues.kt | 2 +- .../completion/KotlinCompletionCharFilter.kt | 40 ++-- .../completion/KotlinCompletionContributor.kt | 86 ++++---- ...cludeFromCompletionLookupActionProvider.kt | 6 +- .../idea/completion/LeafElementFilter.kt | 4 +- .../idea/completion/LookupElementFactory.kt | 6 +- .../completion/LookupElementsCollector.kt | 32 +-- .../completion/NamedArgumentCompletion.kt | 10 +- .../completion/PackageDirectiveCompletion.kt | 12 +- .../ParameterNameAndTypeCompletion.kt | 36 ++-- .../completion/ToFromOriginalFileMapper.kt | 16 +- .../kotlin/idea/completion/Weighers.kt | 4 +- .../handlers/CastReceiverInsertHandler.kt | 20 +- .../completion/handlers/GenerateLambda.kt | 18 +- .../handlers/KotlinCallableInsertHandler.kt | 10 +- .../handlers/KotlinClassifierInsertHandler.kt | 22 +-- .../handlers/KotlinFunctionInsertHandler.kt | 12 +- .../handlers/KotlinPropertyInsertHandler.kt | 14 +- .../WithExpressionPrefixInsertHandler.kt | 10 +- .../handlers/WithTailInsertHandler.kt | 16 +- .../idea/completion/handlers/handlerUtils.kt | 2 +- .../completion/smart/ClassLiteralItems.kt | 2 +- .../idea/completion/smart/LambdaItems.kt | 8 +- .../smart/MultipleArgumentsItemProvider.kt | 18 +- .../idea/completion/smart/SmartCompletion.kt | 60 +++--- .../smart/SmartCompletionSession.kt | 6 +- .../idea/completion/smart/StaticMembers.kt | 14 +- .../smart/TypeInstantiationItems.kt | 40 ++-- .../kotlin/idea/completion/smart/Utils.kt | 36 ++-- ...tractCompiledKotlinInJavaCompletionTest.kt | 2 +- .../AbstractJvmWithLibBasicCompletionTest.kt | 2 +- .../test/AbstractKeywordCompletionTest.kt | 2 +- ...bstractKotlinSourceInJavaCompletionTest.kt | 2 +- ...AbstractMultiFileJvmBasicCompletionTest.kt | 4 +- .../AbstractMultiFileSmartCompletionTest.kt | 4 +- .../test/ExpectedCompletionUtils.kt | 58 +++--- .../KotlinFixtureCompletionBaseTestCase.kt | 8 +- .../AbstractCompletionHandlerTests.kt | 20 +- .../handlers/BasicCompletionHandlerTest.kt | 5 +- .../handlers/CompletionHandlerTestBase.kt | 26 +-- .../SmartCompletionMultifileHandlerTest.kt | 14 +- .../weighers/AbstractCompletionWeigherTest.kt | 10 +- .../kotlin/idea/core/ExpectedInfos.kt | 94 ++++----- .../kotlin/idea/core/HeuristicSignatures.kt | 18 +- .../idea/core/ImportableFqNameClassifier.kt | 6 +- .../idea/core/IterableTypesDetection.kt | 12 +- .../kotlin/idea/core/KotlinIndicesHelper.kt | 30 +-- .../kotlin/idea/core/KotlinNameSuggester.kt | 68 +++---- .../kotlin/idea/core/NameValidators.kt | 14 +- .../idea/core/OptionalParametersHelper.kt | 32 +-- .../idea/core/TypesWithContainsDetector.kt | 14 +- .../org/jetbrains/kotlin/idea/core/Utils.kt | 16 +- .../completion/DeclarationLookupObject.kt | 14 +- .../kotlin/idea/core/descriptorUtils.kt | 4 +- .../ImplementMembersHandler.kt | 4 +- .../OverrideImplementMembersHandler.kt | 8 +- .../OverrideMemberChooserObject.kt | 2 +- .../OverrideMembersHandler.kt | 2 +- .../kotlin/idea/core/packageUtils.kt | 8 +- .../jetbrains/kotlin/idea/core/psiFilters.kt | 6 +- .../kotlin/idea/core/psiModificationUtils.kt | 63 +++--- .../util/DescriptorMemberChooserObject.kt | 8 +- .../kotlin/config/CompilerSettings.kt | 8 +- .../KotlinShortenFQNamesProcessor.kt | 8 +- .../liveTemplates/LiveTemplatesContextTest.kt | 12 +- .../idea/liveTemplates/LiveTemplatesTest.kt | 2 +- .../kotlin/console/CommandExecutor.kt | 2 +- .../kotlin/console/ConsoleCompilerHelper.kt | 2 +- .../kotlin/console/HistoryUpdater.kt | 2 +- .../kotlin/console/KotlinConsoleKeeper.kt | 2 +- .../kotlin/console/KotlinConsoleRunner.kt | 2 +- .../jetbrains/kotlin/console/ReplColors.kt | 14 +- .../kotlin/console/ReplOutputHandler.kt | 4 +- .../kotlin/console/ReplOutputProcessor.kt | 2 +- .../console/actions/ConsoleModuleDialog.kt | 4 +- .../console/actions/RunExecuteActions.kt | 6 +- .../console/gutter/ConsoleErrorRenderer.kt | 2 +- .../gutter/ConsoleGutterContentProvider.kt | 2 +- .../gutter/ConsoleIndicatorRenderer.kt | 2 +- .../kotlin/console/gutter/ReplIcons.kt | 24 +-- .../kotlin/idea/test/AstAccessControl.kt | 6 +- .../idea/test/DirectiveBasedActionUtils.kt | 14 +- .../KotlinLightCodeInsightFixtureTestCase.kt | 14 +- ...LightPlatformCodeInsightFixtureTestCase.kt | 6 +- .../idea/test/KotlinMultiFileTestCase.kt | 2 +- .../idea/test/KotlinStdJSProjectDescriptor.kt | 4 +- .../jetbrains/kotlin/idea/test/testUtils.kt | 28 +-- .../android/KotlinOutputParserHelper.kt | 4 +- .../android/navigation/gotoResourceHelper.kt | 12 +- .../kotlin/idea/ExtraSteppingFilter.kt | 6 +- .../kotlin/idea/KotlinFoldingBuilder.kt | 52 ++--- .../KotlinJavaScriptMetaFileTypeFactory.kt | 4 +- .../kotlin/idea/KotlinPluginUpdater.kt | 2 +- .../idea/KotlinQuickDocumentationProvider.kt | 4 +- .../actions/ConfigureKotlinInProjectAction.kt | 18 +- .../kotlin/idea/actions/JavaToKotlinAction.kt | 20 +- .../idea/actions/KotlinAddImportAction.kt | 2 +- .../actions/KotlinQualifiedNameProvider.kt | 6 +- .../idea/actions/ShowExpressionTypeAction.kt | 17 +- .../idea/actions/ShowKotlinBytecodeAction.kt | 10 +- .../KotlinGenerateTestSupportActionBase.kt | 8 +- .../internal/CheckPartialBodyResolveAction.kt | 42 ++-- .../internal/FindImplicitNothingAction.kt | 30 +-- .../KotlinInternalModeToggleAction.kt | 4 +- .../StoredExceptionsThrowToggleAction.kt | 4 +- .../idea/caches/FileAttributeServiceImpl.kt | 2 +- .../KotlinCopyPasteReferenceProcessor.kt | 31 ++- .../KotlinReferenceTransferableData.kt | 22 +-- ...otlinShortenReferencesRefactoringHelper.kt | 4 +- .../KotlinRuntimeTypeCastSurrounder.kt | 36 ++-- .../KotlinBuildProcessParametersProvider.kt | 2 +- .../KotlinCompilerWorkspaceSettings.kt | 7 +- ...radleKotlinJavaFrameworkSupportProvider.kt | 2 +- .../KotlinSetupSDKNotificationProvider.kt | 2 +- .../copy/ConvertJavaCopyPastePostProcessor.kt | 33 ++-- .../idea/conversion/copy/CopiedJavaCode.kt | 4 +- .../idea/conversion/copy/DataForConversion.kt | 24 +-- .../kotlin/idea/conversion/copy/RangeUtils.kt | 16 +- .../idea/coverage/KotlinCoverageExtension.kt | 28 +-- .../DiagnosticSuppressorForDebugger.kt | 8 +- .../idea/debugger/KotlinDebuggerSettings.kt | 11 +- .../idea/debugger/KotlinEditorTextProvider.kt | 18 +- .../KotlinFrameExtraVariablesProvider.kt | 2 +- .../idea/debugger/KotlinPositionManager.kt | 13 +- .../KotlinSourcePositionHighlighter.kt | 2 +- .../debugger/KotlinSourcePositionProvider.kt | 38 ++-- .../KotlinBreakpointHandlerFactory.kt | 8 +- .../breakpoints/KotlinFieldBreakpoint.kt | 90 ++++----- .../KotlinFieldBreakpointPropertiesPanel.kt | 2 +- .../breakpoints/KotlinFieldBreakpointType.kt | 2 +- .../KotlinPropertyBreakpointProperties.kt | 8 +- .../kotlin/idea/debugger/debuggerUtil.kt | 4 +- .../idea/debugger/evaluate/FrameVisitor.kt | 2 +- .../evaluate/KotlinCodeFragmentFactory.kt | 4 +- .../evaluate/KotlinEvaluateExpressionCache.kt | 10 +- .../evaluate/KotlinRuntimeTypeEvaluator.kt | 2 +- .../debugger/evaluate/compilingEvaluator.kt | 2 +- .../debugger/filter/DebuggerFiltersUtil.kt | 2 +- ...inDebuggerInternalClassesFilterProvider.kt | 2 +- .../KotlinSyntheticTypeComponentProvider.kt | 2 +- ...otlinClassWithDelegatedPropertyRenderer.kt | 2 +- .../stepping/KotlinBasicStepMethodFilter.kt | 2 +- .../stepping/KotlinLambdaMethodFilter.kt | 4 +- .../KotlinLambdaSmartStepIntoTarget.kt | 2 +- .../KotlinMethodSmartStepIntoTarget.kt | 2 +- .../stepping/KotlinSmartStepIntoHandler.kt | 2 +- .../stepping/KotlinSteppingCommandProvider.kt | 2 +- .../kotlin/idea/editor/KotlinEnterHandler.kt | 20 +- .../kotlin/idea/editor/KotlinQuoteHandler.kt | 14 +- .../idea/editor/KotlinSmartEnterHandler.kt | 40 ++-- .../idea/editor/fixers/KotlinDoWhileFixer.kt | 14 +- .../editor/fixers/KotlinForConditionFixer.kt | 10 +- .../KotlinFunctionDeclarationBodyFixer.kt | 6 +- .../fixers/KotlinFunctionParametersFixer.kt | 18 +- .../editor/fixers/KotlinIfConditionFixer.kt | 10 +- .../KotlinMissingForOrWhileBodyFixer.kt | 10 +- .../fixers/KotlinMissingIfBranchFixer.kt | 18 +- .../fixers/KotlinMissingWhenBodyFixer.kt | 18 +- .../fixers/KotlinWhenSubjectCaretFixer.kt | 8 +- .../fixers/KotlinWhileConditionFixer.kt | 10 +- .../editor/fixers/MissingConditionFixer.kt | 2 +- .../kotlin/idea/editor/fixers/fixersUtil.kt | 8 +- .../KotlinCodeBlockSelectioner.kt | 8 +- .../KotlinDeclarationSelectioner.kt | 8 +- .../KotlinDocCommentSelectioner.kt | 4 +- .../wordSelection/KotlinListSelectioner.kt | 8 +- .../KotlinStatementGroupSelectioner.kt | 20 +- .../KotlinStringLiteralSelectioner.kt | 4 +- .../KotlinWordSelectionFilter.kt | 8 +- .../KotlinDeclarationGroupRuleProvider.kt | 8 +- .../KotlinElementDescriptionProvider.kt | 12 +- .../KotlinFindUsagesHandlerFactory.kt | 10 +- .../findUsages/KotlinImportFilteringRule.kt | 6 +- .../findUsages/KotlinReferenceUsageInfo.kt | 6 +- .../findUsages/KotlinUsageTypeProvider.kt | 6 +- .../idea/findUsages/findUsagesOptions.kt | 16 +- .../DelegatingFindMemberUsagesHandler.kt | 6 +- .../handlers/KotlinFindClassUsagesHandler.kt | 32 +-- .../handlers/KotlinFindMemberUsagesHandler.kt | 10 +- .../handlers/KotlinFindUsagesHandler.kt | 17 +- .../KotlinTypeParameterFindUsagesHandler.kt | 10 +- .../idea/formatter/ImportSettingsPanel.kt | 16 +- .../idea/formatter/KotlinSpacingBuilder.kt | 14 +- .../idea/formatter/SyntheticKotlinBlock.kt | 20 +- .../kotlin/idea/formatter/WrappingStrategy.kt | 2 +- .../idea/formatter/kotlinSpacingRules.kt | 40 ++-- .../idea/framework/KotlinModuleBuilder.kt | 2 +- .../idea/framework/KotlinTemplatesFactory.kt | 4 +- .../KotlinOverrideHierarchyBrowser.kt | 2 +- .../KotlinOverrideHierarchyProvider.kt | 4 +- .../overrides/KotlinOverrideTreeStructure.kt | 2 +- ...orDuringFileAnalyzeNotificationProvider.kt | 10 +- .../highlighter/KotlinColorSettingsPage.kt | 8 +- ...KotlinHighlightExitPointsHandlerFactory.kt | 4 +- .../KotlinRecursiveCallLineMarkerProvider.kt | 30 +-- .../KotlinRunLineMarkerContributor.kt | 2 +- .../idea/highlighter/markers/JavaPsiUtils.kt | 8 +- .../markers/KotlinLineMarkerProvider.kt | 36 ++-- .../markers/OverridenFunctionMarker.kt | 28 +-- .../markers/OverridenPropertyMarker.kt | 22 +-- .../markers/SuperDeclarationMarker.kt | 21 +- .../idea/imports/KotlinImportOptimizer.kt | 12 +- .../idea/inspections/AddKotlinLibQuickFix.kt | 6 +- .../ConflictingExtensionPropertyInspection.kt | 2 +- .../inspections/KotlinCleanupInspection.kt | 8 +- .../inspections/OldStdlibApiInspection.kt | 2 +- .../RedundantSamConstructorInspection.kt | 6 +- .../RedundantVisibilityModifierInspection.kt | 2 +- .../UnusedReceiverParameterInspection.kt | 2 +- .../inspections/UnusedSymbolInspection.kt | 54 ++--- .../idea/intentions/AddBracesIntention.kt | 2 +- .../intentions/AddForLoopIndicesIntention.kt | 2 +- .../intentions/AddNameToArgumentIntention.kt | 2 +- .../ChangeVisibilityModifierIntention.kt | 10 +- .../idea/intentions/ChooseValueExpression.kt | 4 +- .../ConvertAssertToIfWithThrowIntention.kt | 2 +- .../ConvertForEachToForLoopIntention.kt | 2 +- .../ConvertFunctionToPropertyIntention.kt | 2 +- .../ConvertIfWithThrowToAssertIntention.kt | 2 +- .../ConvertNegatedBooleanSequenceIntention.kt | 2 +- ...atedExpressionWithDemorgansLawIntention.kt | 2 +- .../ConvertParameterToReceiverIntention.kt | 2 +- .../ConvertPropertyToFunctionIntention.kt | 2 +- .../ConvertReceiverToParameterIntention.kt | 2 +- .../intentions/ConvertToBlockBodyIntention.kt | 4 +- .../ConvertToConcatenatedStringIntention.kt | 2 +- .../ConvertToExpressionBodyIntention.kt | 4 +- .../ConvertToForEachFunctionCallIntention.kt | 2 +- .../ConvertToStringTemplateIntention.kt | 8 +- ...precatedCallableAddReplaceWithIntention.kt | 4 +- .../idea/intentions/IfNullToElvisIntention.kt | 6 +- .../InfixCallToOrdinaryIntention.kt | 4 +- .../InsertCurlyBracesToTemplateIntention.kt | 2 +- .../InsertExplicitTypeArgumentsIntention.kt | 6 +- .../intentions/InvertIfConditionIntention.kt | 2 +- .../intentions/IterateExpressionIntention.kt | 2 +- .../MoveAssignmentToInitializerIntention.kt | 2 +- .../MoveLambdaInsideParenthesesIntention.kt | 2 +- .../MoveLambdaOutsideParenthesesIntention.kt | 2 +- .../ReconstructTypeInCastOrIsIntention.kt | 2 +- .../intentions/RemoveArgumentNameIntention.kt | 2 +- .../idea/intentions/RemoveBracesIntention.kt | 2 +- .../RemoveCurlyBracesFromTemplateIntention.kt | 6 +- ...veExplicitLambdaParameterTypesIntention.kt | 2 +- .../RemoveExplicitSuperQualifierIntention.kt | 4 +- .../RemoveExplicitTypeArgumentsIntention.kt | 6 +- .../intentions/RemoveExplicitTypeIntention.kt | 2 +- .../RemoveForLoopIndicesIntention.kt | 4 +- .../RemoveUnnecessaryParenthesesIntention.kt | 2 +- ...icitFunctionLiteralParamWithItIntention.kt | 4 +- ...thExplicitFunctionLiteralParamIntention.kt | 2 +- .../ReplaceWithOperatorAssignmentIntention.kt | 4 +- .../ReplaceWithOrdinaryAssignmentIntention.kt | 2 +- .../SimplifyBooleanWithConstantsIntention.kt | 4 +- ...implifyNegatedBinaryExpressionIntention.kt | 8 +- ...SpecifyExplicitLambdaSignatureIntention.kt | 2 +- .../SpecifyTypeExplicitlyIntention.kt | 10 +- .../idea/intentions/SplitIfIntention.kt | 2 +- .../SwapBinaryExpressionIntention.kt | 2 +- .../idea/intentions/ToInfixCallIntention.kt | 2 +- .../UsePropertyAccessSyntaxIntention.kt | 4 +- .../jetbrains/kotlin/idea/intentions/Utils.kt | 2 +- .../BranchedFoldingUtils.kt | 6 +- .../BranchedUnfoldingUtils.kt | 6 +- .../branchedTransformationUtils.kt | 4 +- .../intentions/DoubleBangToIfThenIntention.kt | 2 +- .../EliminateWhenSubjectIntention.kt | 2 +- .../intentions/ElvisToIfThenIntention.kt | 2 +- .../intentions/FlattenWhenIntention.kt | 2 +- .../intentions/FoldIfToAssignmentIntention.kt | 2 +- .../FoldIfToReturnAsymmetricallyIntention.kt | 2 +- .../intentions/FoldIfToReturnIntention.kt | 2 +- .../FoldWhenToAssignmentIntention.kt | 2 +- .../intentions/FoldWhenToReturnIntention.kt | 2 +- .../intentions/IfThenToDoubleBangIntention.kt | 2 +- .../intentions/IfThenToElvisIntention.kt | 6 +- .../intentions/IfThenToSafeAccessIntention.kt | 6 +- .../intentions/IfToWhenIntention.kt | 2 +- .../IntroduceWhenSubjectIntention.kt | 4 +- .../intentions/MergeWhenIntention.kt | 2 +- .../intentions/SafeAccessToIfThenIntention.kt | 2 +- .../UnfoldAssignmentToIfIntention.kt | 2 +- .../UnfoldAssignmentToWhenIntention.kt | 2 +- .../intentions/UnfoldPropertyToIfIntention.kt | 2 +- .../UnfoldPropertyToWhenIntention.kt | 2 +- .../intentions/UnfoldReturnToIfIntention.kt | 2 +- .../intentions/UnfoldReturnToWhenIntention.kt | 2 +- .../intentions/WhenToIfIntention.kt | 2 +- .../ReplaceCallWithBinaryOperatorIntention.kt | 2 +- .../ReplaceCallWithUnaryOperatorIntention.kt | 2 +- .../ReplaceContainsIntention.kt | 2 +- .../ReplaceGetOrSetIntention.kt | 2 +- .../ReplaceInvokeIntention.kt | 2 +- .../ConvertMemberToExtensionIntention.kt | 2 +- .../SplitPropertyDeclarationIntention.kt | 2 +- .../CreateIncrementalCompilationBackup.kt | 46 ++--- .../makeBackup/MakeBackupCompileTask.kt | 6 +- .../idea/j2k/IdeaDocCommentConverter.kt | 36 ++-- .../kotlin/idea/j2k/IdeaReferenceSearcher.kt | 8 +- .../idea/j2k/IdeaResolverForConverter.kt | 2 +- .../kotlin/idea/j2k/J2kPostProcessor.kt | 2 +- .../JoinBlockIntoSingleStatementHandler.kt | 30 +-- .../JoinDeclarationAndAssignmentHandler.kt | 18 +- .../kotlin/idea/kdoc/KDocRenderer.kt | 2 +- .../kotlin/idea/kdoc/KDocTypedHandler.kt | 20 +- .../KotlinProblemFileHighlightFilter.kt | 2 +- .../KotlinPropertiesReferenceContributor.kt | 2 +- .../idea/properties/referenceProviders.kt | 4 +- .../idea/quickfix/AddConstModifierFix.kt | 6 +- .../idea/quickfix/AddFunctionParametersFix.kt | 2 +- .../idea/quickfix/AddGenericUpperBoundFix.kt | 2 +- .../kotlin/idea/quickfix/AddLoopLabelFix.kt | 2 +- .../idea/quickfix/AddNameToArgumentFix.kt | 2 +- .../ChangePrivateTopLevelToInternalFix.kt | 2 +- .../quickfix/ChangeVariableMutabilityFix.kt | 8 +- .../kotlin/idea/quickfix/CleanupFix.kt | 2 +- .../quickfix/DelegatingIntentionAction.kt | 2 +- .../kotlin/idea/quickfix/ExclExclCallFixes.kt | 6 +- .../quickfix/InsertDelegationCallQuickfix.kt | 2 +- .../KotlinAddOrderEntryActionFactory.kt | 2 +- ...otlinIntentionActionFactoryWithDelegate.kt | 2 +- .../idea/quickfix/KotlinReferenceImporter.kt | 4 +- .../KotlinSingleIntentionActionFactory.kt | 2 +- .../quickfix/MakeOverriddenMemberOpenFix.kt | 2 +- .../quickfix/MissingConstructorKeywordFix.kt | 4 +- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 4 +- .../quickfix/QuickFixWithDelegateFactory.kt | 6 +- .../kotlin/idea/quickfix/RemoveModifierFix.kt | 12 +- .../RemoveNameFromFunctionExpressionFix.kt | 2 +- .../kotlin/idea/quickfix/ReplaceCallFix.kt | 6 +- .../idea/quickfix/ReplaceInfixCallFix.kt | 2 +- ...aceJavaAnnotationPositionedArgumentsFix.kt | 2 +- .../quickfix/ReplaceObsoleteLabelSyntaxFix.kt | 6 +- .../idea/quickfix/SpecifyTypeExplicitlyFix.kt | 2 +- .../idea/quickfix/SuperClassNotInitialized.kt | 2 +- .../idea/quickfix/UnsupportedAsyncFix.kt | 2 +- .../idea/quickfix/WholeProjectModalAction.kt | 4 +- .../createFromUsage/CreateFromUsageFixBase.kt | 2 +- .../callableBuilder/CallableBuilder.kt | 4 +- .../callableBuilder/generationUtils.kt | 2 +- .../callableBuilder/templateExpressions.kt | 4 +- .../callableBuilder/typeUtils.kt | 2 +- .../CreateBinaryOperationActionFactory.kt | 2 +- .../CreateCallableFromUsageFix.kt | 6 +- .../CreateCallableMemberFromUsageFactory.kt | 2 +- .../CreateUnaryOperationActionFactory.kt | 2 +- ...mCallWithConstructorCalleeActionFactory.kt | 2 +- ...teClassFromConstructorCallActionFactory.kt | 2 +- ...assFromReferenceExpressionActionFactory.kt | 2 +- ...eateClassFromTypeReferenceActionFactory.kt | 2 +- .../createClass/CreateClassFromUsageFix.kt | 4 +- ...teParameterByNamedArgumentActionFactory.kt | 2 +- .../CreateParameterFromUsageFix.kt | 4 +- .../quickfix/quickfixUtil/quickfixUtil.kt | 2 +- .../CallableUsageReplacementStrategy.kt | 4 +- .../replaceWith/DeprecatedSymbolUsageFix.kt | 4 +- .../DeprecatedSymbolUsageFixBase.kt | 2 +- .../DeprecatedSymbolUsageInWholeProjectFix.kt | 2 +- .../ReplaceWithAnnotationAnalyzer.kt | 10 +- .../AbstractPullPushMembersHandler.kt | 2 +- .../idea/refactoring/CallableRefactoring.kt | 4 +- .../idea/refactoring/KotlinNamesValidator.kt | 2 +- .../KotlinRefactoringSupportProvider.kt | 10 +- .../KotlinAwareJavaParameterInfoImpl.kt | 2 +- .../changeSignature/KotlinChangeInfo.kt | 49 +++-- .../changeSignature/KotlinChangeSignature.kt | 9 +- .../KotlinChangeSignatureData.kt | 2 +- .../KotlinChangeSignatureHandler.kt | 8 +- .../KotlinChangeSignatureProcessor.kt | 2 +- .../changeSignature/KotlinMethodDescriptor.kt | 2 +- .../KotlinMutableMethodDescriptor.kt | 10 +- .../changeSignature/KotlinParameterInfo.kt | 16 +- .../KotlinUsagesViewDescriptor.kt | 2 +- .../changeSignature/KotlinValVar.kt | 2 +- .../changeSignature/changeSignatureUtils.kt | 4 +- .../changeSignature/ui/KotlinCallerChooser.kt | 4 +- .../ui/KotlinChangePropertySignatureDialog.kt | 2 +- .../ui/KotlinChangeSignatureDialog.kt | 16 +- .../usages/JavaMethodDeferredKotlinUsage.kt | 6 +- .../JavaMethodKotlinUsageWithDelegate.kt | 4 +- .../usages/KotlinCallerUsages.kt | 4 +- .../KotlinConstructorDelegationCallUsage.kt | 2 +- .../KotlinEnumEntryWithoutSuperCallUsage.kt | 2 +- .../KotlinImplicitThisToParameterUsage.kt | 10 +- .../usages/KotlinParameterUsage.kt | 6 +- .../usages/KotlinPropertyCallUsage.kt | 2 +- .../changeSignature/usages/KotlinUsageInfo.kt | 8 +- .../usages/KotlinWrapperForJavaUsageInfos.kt | 2 +- .../refactoring/copy/CopyKotlinFileHandler.kt | 2 +- .../introduce/AbstractIntroduceAction.kt | 4 +- .../AbstractKotlinInplaceIntroducer.kt | 2 +- .../extractFunction/ExtractFunctionAction.kt | 4 +- .../ExtractKotlinFunctionHandler.kt | 4 +- .../ui/KotlinFunctionSignatureComponent.kt | 2 +- .../extractionEngine/ExtractionEngine.kt | 4 +- .../extractionEngine/duplicateUtil.kt | 8 +- .../IntroduceLambdaParameterAction.kt | 2 +- .../KotlinInplaceParameterIntroducer.kt | 4 +- .../KotlinIntroduceParameterDialog.kt | 4 +- .../KotlinIntroduceParameterHandler.kt | 8 +- ...nIntroduceParameterMethodUsageProcessor.kt | 2 +- .../IntroducePropertyAction.kt | 2 +- .../KotlinInplacePropertyIntroducer.kt | 2 +- .../KotlinIntroducePropertyHandler.kt | 6 +- .../KotlinVariableInplaceIntroducer.kt | 2 +- .../refactoring/javaElementFactoryUtils.kt | 2 +- .../idea/refactoring/jetRefactoringUtil.kt | 59 +++--- .../memberInfo/KotlinMemberInfo.kt | 4 +- .../memberInfo/KotlinMemberInfoStorage.kt | 2 +- .../memberInfo/KotlinMemberSelectionPanel.kt | 2 +- .../memberInfo/KotlinMemberSelectionTable.kt | 2 +- .../refactoring/memberInfo/memberInfoUtils.kt | 2 +- .../MoveJavaInnerClassKotlinUsagesHandler.kt | 2 +- .../changePackage/ChangePackageIntention.kt | 2 +- .../ChangePackageToMatchDirectoryIntention.kt | 2 +- .../KotlinChangePackageRefactoring.kt | 2 +- ...FileToPackageMatchingDirectoryIntention.kt | 2 +- .../PackageDirectoryMismatchInspection.kt | 2 +- .../KotlinMoveDirectoryWithClassesHelper.kt | 2 +- .../KotlinMoveFilesOrDirectoriesHandler.kt | 2 +- .../MoveKotlinFileHandler.kt | 2 +- .../KotlinMoveTarget.kt | 8 +- .../MoveDeclarationToSeparateFileIntention.kt | 2 +- .../MoveKotlinTopLevelDeclarationsHandler.kt | 2 +- ...MoveKotlinTopLevelDeclarationsProcessor.kt | 4 +- ...KotlinAwareMoveFilesOrDirectoriesDialog.kt | 4 +- .../kotlin/idea/refactoring/move/moveUtils.kt | 6 +- .../JavaToKotlinPostconversionPullUpHelper.kt | 2 +- .../JavaToKotlinPreconversionPullUpHelper.kt | 2 +- .../refactoring/pullUp/KotlinPullUpDialog.kt | 2 +- .../refactoring/pullUp/KotlinPullUpHandler.kt | 2 +- .../pullUp/KotlinPullUpHelperFactory.kt | 4 +- .../pushDown/KotlinPushDownDialog.kt | 4 +- .../pushDown/KotlinPushDownHandler.kt | 2 +- .../pushDown/KotlinPushDownProcessor.kt | 4 +- .../rename/AutomaticInheritorRenamer.kt | 4 +- .../rename/AutomaticOverloadsRenamer.kt | 4 +- .../rename/AutomaticVariableRenamer.kt | 6 +- .../rename/RenameDynamicMemberHandler.kt | 2 +- .../rename/RenameKotlinClassProcessor.kt | 2 +- .../rename/RenameKotlinFunctionProcessor.kt | 2 +- .../RenameKotlinImplicitLambdaParameter.kt | 2 +- .../rename/RenameKotlinParameterProcessor.kt | 2 +- .../rename/RenameKotlinPropertyProcessor.kt | 2 +- .../RenameOnSecondaryConstructorHandler.kt | 2 +- .../KotlinJavaSafeDeleteDelegate.kt | 2 +- .../KotlinSafeDeleteOverrideAnnotation.kt | 4 +- .../KotlinSafeDeleteOverridingUsageInfo.kt | 6 +- .../safeDelete/KotlinSafeDeleteProcessor.kt | 2 +- .../SafeDeleteImportDirectiveUsageInfo.kt | 2 +- .../SafeDeleteTypeArgumentListUsageInfo.kt | 4 +- .../SafeDeleteValueArgumentListUsageInfo.kt | 4 +- .../idea/refactoring/safeDelete/utils.kt | 2 +- .../KotlinJUnitRunConfigurationProducer.kt | 40 ++-- .../run/KotlinRunConfigurationProducer.kt | 34 ++-- ...tandaloneScriptRunConfigurationProducer.kt | 2 +- .../KotlinAnnotatedElementsSearcher.kt | 16 +- ...structorDelegationCallReferenceSearcher.kt | 4 +- .../KotlinDirectInheritorsSearcher.kt | 16 +- ...KotlinOverridingMethodReferenceSearcher.kt | 2 +- ...inOverridingMethodsWithGenericsSearcher.kt | 2 +- ...otlinPropertyAccessorsReferenceSearcher.kt | 10 +- .../KotlinTargetElementEvaluator.kt | 4 +- .../testIntegration/KotlinCreateTestDialog.kt | 2 +- .../testIntegration/testIntegrationUtils.kt | 2 +- .../kotlin/idea/util/DialogWithEditor.kt | 26 +-- .../idea/util/ImportInsertHelperImpl.kt | 44 ++--- .../idea/util/attachment/attachmentUtils.kt | 20 +- .../kotlin/idea/util/projectStructureUtil.kt | 8 +- .../psi/patternMatching/KotlinPsiRange.kt | 22 +-- .../psi/patternMatching/KotlinPsiUnifier.kt | 186 +++++++++--------- .../idea/versions/KotlinAbiVersionIndex.kt | 2 +- .../KotlinJavaScriptAbiVersionIndex.kt | 2 +- .../versions/KotlinUpdatePluginComponent.kt | 20 +- .../KotlinFindUsagesHandlerDecorator.kt | 6 +- .../jetbrains/kotlin/AbstractImportsTest.kt | 16 +- .../kotlin/DataFlowValueRenderingTest.kt | 8 +- .../kotlin/addImport/AbstractAddImportTest.kt | 12 +- .../asJava/KotlinLightClassInheritorTest.kt | 12 +- .../LightClassesClasspathSortingTest.kt | 6 +- .../kotlin/checkers/PsiCheckerCustomTest.kt | 8 +- ...AbstractKotlinFindUsagesWithLibraryTest.kt | 2 +- .../KotlinFindUsagesWithLibraryCustomTest.kt | 8 +- .../kotlin/idea/AbstractCopyPasteTest.kt | 8 +- .../OutdatedKotlinRuntimeNotificationTest.kt | 6 +- .../kotlin/idea/RegisteredFindersTest.kt | 8 +- .../kotlin/idea/ResolveElementCacheTest.kt | 54 ++--- .../AbstractGotoTestOrCodeActionTest.kt | 2 +- .../kotlin/idea/actions/QualifiedNamesTest.kt | 2 +- .../resolve/AbstractIdeLightClassTest.kt | 2 +- .../caches/resolve/CustomModuleInfoTest.kt | 2 +- .../HighlightingWithDependentLibrariesTest.kt | 8 +- .../idea/caches/resolve/IdeaModuleInfoTest.kt | 4 +- .../resolve/MultiModuleHighlightingTest.kt | 4 +- .../idea/caches/resolve/PsiElementChecker.kt | 2 +- .../AbstractInsertImportOnPasteTest.kt | 14 +- .../codeInsight/AbstractInspectionTest.kt | 32 +-- .../AbstractMultiFileInspectionTest.kt | 16 +- .../AbstractOverrideImplementTest.kt | 4 +- .../idea/codeInsight/OverrideImplementTest.kt | 106 +++++----- .../OverrideImplementWithLibTest.kt | 6 +- .../kotlin/idea/console/KotlinReplTest.kt | 3 +- ...ractJavaToKotlinCopyPasteConversionTest.kt | 16 +- .../AbstractKotlinCoverageOutputFilesTest.kt | 6 +- .../debugger/AbstractKotlinSteppingTest.kt | 2 +- .../debugger/AbstractSmartStepIntoTest.kt | 12 +- .../idea/debugger/KotlinDebuggerTestBase.kt | 38 ++-- ...AbstractEditorForEvaluateExpressionTest.kt | 26 +-- .../AbstractKotlinEvaluateExpressionTest.kt | 30 +-- ...AbstractSelectExpressionForDebuggerTest.kt | 8 +- .../CodeFragmentCompletionInLibraryTest.kt | 22 +-- .../AbstractInternalCompiledClassesTest.kt | 12 +- .../decompiler/InternalCompiledClassesTest.kt | 2 +- .../AbstractNavigateToLibrarySourceTest.kt | 26 +-- .../NavigateFromLibrarySourcesTest.kt | 26 +-- .../navigation/NavigateToStdlibSourceTest.kt | 18 +- .../stubBuilder/AbstractClsStubBuilderTest.kt | 8 +- .../stubBuilder/ClsStubConsistencyTest.kt | 4 +- .../KotlinJavaScriptStubConsistencyTest.kt | 4 +- .../stubBuilder/StubConsistencyBaseTest.kt | 6 +- .../AbstractDecompiledTextBaseTest.kt | 4 +- ...bstractDecompiledTextFromJsMetadataTest.kt | 10 +- .../textBuilder/AbstractDecompiledTextTest.kt | 10 +- .../DecompiledTextConsistencyTest.kt | 2 +- .../DecompiledTextForWrongAbiVersionTest.kt | 6 +- ...JavaScriptDecompiledTextConsistencyTest.kt | 2 +- .../textBuilder/TextConsistencyBaseTest.kt | 4 +- .../kotlin/idea/editor/TypedHandlerTest.kt | 90 ++++----- .../quickDoc/QuickDocInCompletionTest.kt | 8 +- .../quickDoc/QuickDocInHierarchyTest.kt | 14 +- .../editor/quickDoc/QuickDocNavigationTest.kt | 10 +- .../AbstractKotlinExceptionFilterTest.kt | 2 +- .../FoldingAfterOptimizeImportsTest.kt | 18 +- .../AbstractHighlightExitPointsTest.kt | 16 +- .../AbstractUsageHighlightingTest.kt | 20 +- .../idea/highlighter/NoErrorsInStdlibTest.kt | 12 +- .../imports/AbstractOptimizeImportsTest.kt | 2 +- .../KotlinCleanupInspectionTest.kt | 8 +- .../AbstractMultiFileIntentionTest.kt | 26 +-- .../AbstractBytecodeToolWindowTest.kt | 10 +- .../kotlin/idea/jsonUtils/jsonUtils.kt | 2 +- .../idea/kdoc/AbstractKDocTypingTest.kt | 4 +- .../kotlin/idea/kdoc/KDocFinderTest.kt | 20 +- .../AbstractKotlinGotoImplementationTest.kt | 2 +- .../DeprecatedSymbolUsageFixSpecialTest.kt | 15 +- .../refactoring/AbstractMemberPullPushTest.kt | 12 +- .../idea/refactoring/InplaceRenameTest.kt | 38 ++-- .../refactoring/KotlinNamesValidatorTest.kt | 6 +- .../introduce/AbstractExtractionTest.kt | 46 ++--- .../idea/refactoring/move/AbstractMoveTest.kt | 42 ++-- .../nameSuggester/KotlinNameSuggesterTest.kt | 52 ++--- .../refactoring/pullUp/AbstractPullUpTest.kt | 6 +- .../pushDown/AbstractPushDownTest.kt | 4 +- .../refactoring/rename/AbstractRenameTest.kt | 28 +-- ...AdditionalResolveDescriptorRendererTest.kt | 2 +- .../resolve/AbstractPartialBodyResolveTest.kt | 36 ++-- .../AbstractReferenceResolveInJavaTest.kt | 4 +- ...actReferenceResolveInLibrarySourcesTest.kt | 20 +- .../resolve/AbstractReferenceResolveTest.kt | 28 +-- .../kotlin/idea/run/RunConfigurationTest.kt | 44 ++--- .../StandaloneScriptRunConfigurationTest.kt | 2 +- .../idea/run/runConfigurationTestUtil.kt | 6 +- .../AbstractKotlinFileStructureTest.kt | 28 +-- .../kotlin/idea/stubs/DebugTextByStubTest.kt | 22 +-- ...StringTemplateExpressionManipulatorTest.kt | 16 +- .../psi/injection/StringInjectionHostTest.kt | 30 +-- .../patternMatching/AbstractPsiUnifierTest.kt | 14 +- .../search/KotlinReferencesSearchTest.kt | 24 +-- .../shortenRefs/AbstractShortenRefsTest.kt | 6 +- 728 files changed, 4001 insertions(+), 4069 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt index a6a883aa4b4..fb925f0779e 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt @@ -26,31 +26,31 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public interface ResolutionFacade { - public val project: Project +interface ResolutionFacade { + val project: Project - public fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext + fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext - public fun analyzeFullyAndGetResult(elements: Collection): AnalysisResult + fun analyzeFullyAndGetResult(elements: Collection): AnalysisResult - public fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor + fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor - public val moduleDescriptor: ModuleDescriptor + val moduleDescriptor: ModuleDescriptor // get service for the module this resolution was created for - public fun getFrontendService(serviceClass: Class): T + fun getFrontendService(serviceClass: Class): T - public fun getIdeService(serviceClass: Class): T + fun getIdeService(serviceClass: Class): T // get service for the module defined by PsiElement/ModuleDescriptor passed as parameter - public fun getFrontendService(element: PsiElement, serviceClass: Class): T + fun getFrontendService(element: PsiElement, serviceClass: Class): T - public fun getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class): T + fun getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class): T } -public inline fun ResolutionFacade.frontendService(): T +inline fun ResolutionFacade.frontendService(): T = this.getFrontendService(T::class.java) -public inline fun ResolutionFacade.ideService(): T +inline fun ResolutionFacade.ideService(): T = this.getIdeService(T::class.java) \ No newline at end of file diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt index 4e6f0b6e0fe..e550b070ce4 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.util.supertypesWithAny import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList -public sealed class CallType(val descriptorKindFilter: DescriptorKindFilter) { +sealed class CallType(val descriptorKindFilter: DescriptorKindFilter) { object UNKNOWN : CallType(DescriptorKindFilter.ALL) object DEFAULT : CallType(DescriptorKindFilter.ALL) @@ -93,7 +93,7 @@ public sealed class CallType(val descriptorKindFilter: D private object NonAnnotationClassifierExclude : DescriptorKindExclude() { override fun excludes(descriptor: DeclarationDescriptor): Boolean { if (descriptor !is ClassifierDescriptor) return false - return descriptor !is ClassDescriptor || descriptor.getKind() != ClassKind.ANNOTATION_CLASS + return descriptor !is ClassDescriptor || descriptor.kind != ClassKind.ANNOTATION_CLASS } override val fullyExcludedDescriptorKinds: Int get() = 0 @@ -108,7 +108,7 @@ public sealed class CallType(val descriptorKindFilter: D } } -public sealed class CallTypeAndReceiver>( +sealed class CallTypeAndReceiver>( val callType: TCallType, val receiver: TReceiver ) { @@ -127,7 +127,7 @@ public sealed class CallTypeAndReceiver(CallType.ANNOTATION, receiver) companion object { - public fun detect(expression: KtSimpleNameExpression): CallTypeAndReceiver<*, *> { + fun detect(expression: KtSimpleNameExpression): CallTypeAndReceiver<*, *> { val parent = expression.parent if (parent is KtCallableReferenceExpression) { return CallTypeAndReceiver.CALLABLE_REFERENCE(parent.typeReference) @@ -205,7 +205,7 @@ public sealed class CallTypeAndReceiver.receiverTypes( +fun CallTypeAndReceiver<*, *>.receiverTypes( bindingContext: BindingContext, contextElement: PsiElement, moduleDescriptor: ModuleDescriptor, diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index 64ddecec58d..23ae065e74f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -28,13 +28,13 @@ import org.jetbrains.kotlin.types.typeUtil.* import java.util.* fun CallableDescriptor.fuzzyReturnType(): FuzzyType? { - val returnType = getReturnType() ?: return null - return FuzzyType(returnType, getTypeParameters()) + val returnType = returnType ?: return null + return FuzzyType(returnType, typeParameters) } fun CallableDescriptor.fuzzyExtensionReceiverType(): FuzzyType? { - val receiverParameter = getExtensionReceiverParameter() - return if (receiverParameter != null) FuzzyType(receiverParameter.getType(), getTypeParameters()) else null + val receiverParameter = extensionReceiverParameter + return if (receiverParameter != null) FuzzyType(receiverParameter.type, typeParameters) else null } fun FuzzyType.makeNotNullable() = FuzzyType(type.makeNotNullable(), freeParameters) @@ -52,7 +52,7 @@ class FuzzyType( val type: KotlinType, freeParameters: Collection ) { - public val freeParameters: Set + val freeParameters: Set init { if (freeParameters.isNotEmpty()) { @@ -70,29 +70,29 @@ class FuzzyType( override fun hashCode() = type.hashCode() private fun MutableSet.addUsedTypeParameters(type: KotlinType) { - val typeParameter = type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor + val typeParameter = type.constructor.declarationDescriptor as? TypeParameterDescriptor if (typeParameter != null && add(typeParameter)) { - typeParameter.getLowerBounds().forEach { addUsedTypeParameters(it) } - typeParameter.getUpperBounds().forEach { addUsedTypeParameters(it) } + typeParameter.lowerBounds.forEach { addUsedTypeParameters(it) } + typeParameter.upperBounds.forEach { addUsedTypeParameters(it) } } - for (argument in type.getArguments()) { + for (argument in type.arguments) { if (!argument.isStarProjection) { // otherwise we can fall into infinite recursion - addUsedTypeParameters(argument.getType()) + addUsedTypeParameters(argument.type) } } } - public fun checkIsSubtypeOf(otherType: FuzzyType): TypeSubstitutor? + fun checkIsSubtypeOf(otherType: FuzzyType): TypeSubstitutor? = matchedSubstitutor(otherType, MatchKind.IS_SUBTYPE) - public fun checkIsSuperTypeOf(otherType: FuzzyType): TypeSubstitutor? + fun checkIsSuperTypeOf(otherType: FuzzyType): TypeSubstitutor? = matchedSubstitutor(otherType, MatchKind.IS_SUPERTYPE) - public fun checkIsSubtypeOf(otherType: KotlinType): TypeSubstitutor? + fun checkIsSubtypeOf(otherType: KotlinType): TypeSubstitutor? = checkIsSubtypeOf(FuzzyType(otherType, emptyList())) - public fun checkIsSuperTypeOf(otherType: KotlinType): TypeSubstitutor? + fun checkIsSuperTypeOf(otherType: KotlinType): TypeSubstitutor? = checkIsSuperTypeOf(FuzzyType(otherType, emptyList())) private enum class MatchKind { @@ -101,8 +101,8 @@ class FuzzyType( } private fun matchedSubstitutor(otherType: FuzzyType, matchKind: MatchKind): TypeSubstitutor? { - if (type.isError()) return null - if (otherType.type.isError()) return null + if (type.isError) return null + if (otherType.type.isError) return null fun KotlinType.checkInheritance(otherType: KotlinType): Boolean { return when (matchKind) { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt index c527c22f83e..44d7de7ae0e 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt @@ -24,12 +24,10 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isDynamic import org.jetbrains.kotlin.types.typeUtil.builtIns -public object IdeDescriptorRenderers { - @JvmField - public val APPROXIMATE_FLEXIBLE_TYPES: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, true) } +object IdeDescriptorRenderers { + @JvmField val APPROXIMATE_FLEXIBLE_TYPES: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, true) } - @JvmField - public val APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, false) } + @JvmField val APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, false) } private fun unwrapAnonymousType(type: KotlinType): KotlinType { if (type.isDynamic()) return type @@ -55,20 +53,17 @@ public object IdeDescriptorRenderers { modifiers = DescriptorRendererModifier.ALL } - @JvmField - public val SOURCE_CODE: DescriptorRenderer = BASE.withOptions { + @JvmField val SOURCE_CODE: DescriptorRenderer = BASE.withOptions { nameShortness = NameShortness.SOURCE_CODE_QUALIFIED typeNormalizer = { APPROXIMATE_FLEXIBLE_TYPES(unwrapAnonymousType(it)) } } - @JvmField - public val SOURCE_CODE_FOR_TYPE_ARGUMENTS: DescriptorRenderer = BASE.withOptions { + @JvmField val SOURCE_CODE_FOR_TYPE_ARGUMENTS: DescriptorRenderer = BASE.withOptions { nameShortness = NameShortness.SOURCE_CODE_QUALIFIED typeNormalizer = { APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS(unwrapAnonymousType(it)) } } - @JvmField - public val SOURCE_CODE_SHORT_NAMES_IN_TYPES: DescriptorRenderer = BASE.withOptions { + @JvmField val SOURCE_CODE_SHORT_NAMES_IN_TYPES: DescriptorRenderer = BASE.withOptions { nameShortness = NameShortness.SHORT typeNormalizer = { APPROXIMATE_FLEXIBLE_TYPES(unwrapAnonymousType(it)) } } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt index 6cbdcf11c00..ffe1435cd20 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt @@ -28,36 +28,36 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor import org.jetbrains.kotlin.types.KotlinType -public val DeclarationDescriptor.importableFqName: FqName? +val DeclarationDescriptor.importableFqName: FqName? get() { if (!canBeReferencedViaImport()) return null return getImportableDescriptor().fqNameSafe } -public fun DeclarationDescriptor.canBeReferencedViaImport(): Boolean { +fun DeclarationDescriptor.canBeReferencedViaImport(): Boolean { if (this is PackageViewDescriptor || DescriptorUtils.isTopLevelDeclaration(this) || this is CallableDescriptor && DescriptorUtils.isStaticDeclaration(this)) { return !name.isSpecial } - val parentClass = getContainingDeclaration() as? ClassDescriptor ?: return false + val parentClass = containingDeclaration as? ClassDescriptor ?: return false if (!parentClass.canBeReferencedViaImport()) return false return when (this) { - is ConstructorDescriptor -> !parentClass.isInner() // inner class constructors can't be referenced via import + is ConstructorDescriptor -> !parentClass.isInner // inner class constructors can't be referenced via import is ClassDescriptor -> true else -> parentClass.kind == ClassKind.OBJECT } } -public fun KotlinType.canBeReferencedViaImport(): Boolean { - val descriptor = getConstructor().getDeclarationDescriptor() +fun KotlinType.canBeReferencedViaImport(): Boolean { + val descriptor = constructor.declarationDescriptor return descriptor != null && descriptor.canBeReferencedViaImport() } // for cases when class qualifier refers companion object treats it like reference to class itself -public fun KtReferenceExpression.getImportableTargets(bindingContext: BindingContext): Collection { +fun KtReferenceExpression.getImportableTargets(bindingContext: BindingContext): Collection { val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, this]?.let { listOf(it) } ?: getReferenceTargets(bindingContext) return targets.map { it.getImportableDescriptor() }.toSet() diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt index 4cfc921ff5f..360e448f415 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution import java.util.* -public class ShadowedDeclarationsFilter( +class ShadowedDeclarationsFilter( private val bindingContext: BindingContext, private val resolutionFacade: ResolutionFacade, private val context: PsiElement, @@ -72,14 +72,14 @@ public class ShadowedDeclarationsFilter( private val psiFactory = KtPsiFactory(resolutionFacade.project) private val dummyExpressionFactory = DummyExpressionFactory(psiFactory) - public fun filter(declarations: Collection): Collection { + fun filter(declarations: Collection): Collection { return declarations .groupBy { signature(it) } .values .flatMap { group -> filterEqualSignatureGroup(group) } } - public fun createNonImportedDeclarationsFilter( + fun createNonImportedDeclarationsFilter( importedDeclarations: Collection ): (Collection) -> Collection { val importedDeclarationsSet = importedDeclarations.toSet() @@ -126,14 +126,14 @@ public class ShadowedDeclarationsFilter( } val isFunction = first is FunctionDescriptor - val name = first.getName() - val parameters = (first as CallableDescriptor).getValueParameters() + val name = first.name + val parameters = (first as CallableDescriptor).valueParameters val dummyArgumentExpressions = dummyExpressionFactory.createDummyExpressions(parameters.size) val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace for filtering shadowed declarations") for ((expression, parameter) in dummyArgumentExpressions.zip(parameters)) { - bindingTrace.recordType(expression, parameter.varargElementType ?: parameter.getType()) + bindingTrace.recordType(expression, parameter.varargElementType ?: parameter.type) bindingTrace.record(BindingContext.PROCESSED, expression, true) } @@ -145,7 +145,7 @@ public class ShadowedDeclarationsFilter( private val argumentName: ValueArgumentName? = if (isNamed()) { object : ValueArgumentName { - override val asName = parameters[index].getName() + override val asName = parameters[index].name override val referenceExpression = null } } @@ -206,11 +206,11 @@ public class ShadowedDeclarationsFilter( CallChecker.DoNothing, false) val callResolver = resolutionFacade.frontendService() val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context) - val resultingDescriptors = results.getResultingCalls().map { it.getResultingDescriptor() } - val resultingOriginals = resultingDescriptors.mapTo(HashSet()) { it.getOriginal() } + val resultingDescriptors = results.resultingCalls.map { it.resultingDescriptor } + val resultingOriginals = resultingDescriptors.mapTo(HashSet()) { it.original } val filtered = descriptors.filter { candidateDescriptor -> - candidateDescriptor.getOriginal() in resultingOriginals /* optimization */ - && resultingDescriptors.any { descriptorsEqualWithSubstitution(it, candidateDescriptor) } + candidateDescriptor.original in resultingOriginals /* optimization */ + && resultingDescriptors.any { descriptorsEqualWithSubstitution(it, candidateDescriptor) } } return if (filtered.isNotEmpty()) filtered else descriptors /* something went wrong, none of our declarations among resolve candidates, let's not filter anything */ } @@ -230,19 +230,19 @@ public class ShadowedDeclarationsFilter( override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is FunctionSignature) return false - if (function.getName() != other.function.getName()) return false - val parameters1 = function.getValueParameters() - val parameters2 = other.function.getValueParameters() + if (function.name != other.function.name) return false + val parameters1 = function.valueParameters + val parameters2 = other.function.valueParameters if (parameters1.size != parameters2.size) return false for (i in parameters1.indices) { val p1 = parameters1[i] val p2 = parameters2[i] if (p1.varargElementType != p2.varargElementType) return false // both should be vararg or or both not - if (p1.getType() != p2.getType()) return false + if (p1.type != p2.type) return false } return true } - override fun hashCode() = function.getName().hashCode() * 17 + function.getValueParameters().size + override fun hashCode() = function.name.hashCode() * 17 + function.valueParameters.size } } \ No newline at end of file diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt index ef6830e3833..3cc9b9408b4 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt @@ -34,11 +34,11 @@ import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.* -public fun approximateFlexibleTypes(jetType: KotlinType, outermost: Boolean = true): KotlinType { +fun approximateFlexibleTypes(jetType: KotlinType, outermost: Boolean = true): KotlinType { if (jetType.isDynamic()) return jetType if (jetType.isFlexible()) { val flexible = jetType.flexibility() - val lowerClass = flexible.lowerBound.getConstructor().getDeclarationDescriptor() as? ClassDescriptor? + val lowerClass = flexible.lowerBound.constructor.declarationDescriptor as? ClassDescriptor? val isCollection = lowerClass != null && JavaToKotlinClassMap.INSTANCE.isMutable(lowerClass) // (Mutable)Collection! -> MutableCollection? // Foo<(Mutable)Collection!>! -> Foo>? @@ -54,46 +54,46 @@ public fun approximateFlexibleTypes(jetType: KotlinType, outermost: Boolean = tr approximation = if (jetType.isAnnotatedNotNull()) approximation.makeNotNullable() else approximation - if (approximation.isMarkedNullable() && !flexible.lowerBound.isMarkedNullable() && TypeUtils.isTypeParameter(approximation) && TypeUtils.hasNullableSuperType(approximation)) { + if (approximation.isMarkedNullable && !flexible.lowerBound.isMarkedNullable && TypeUtils.isTypeParameter(approximation) && TypeUtils.hasNullableSuperType(approximation)) { approximation = approximation.makeNotNullable() } return approximation } return KotlinTypeImpl.create( - jetType.getAnnotations(), - jetType.getConstructor(), - jetType.isMarkedNullable(), - jetType.getArguments().map { it.substitute { type -> approximateFlexibleTypes(type, false)} }, + jetType.annotations, + jetType.constructor, + jetType.isMarkedNullable, + jetType.arguments.map { it.substitute { type -> approximateFlexibleTypes(type, false)} }, ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true) ) } -public fun KotlinType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION) -public fun KotlinType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION) -public fun KotlinType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION) +fun KotlinType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION) +fun KotlinType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION) +fun KotlinType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION) -private fun KotlinType.hasAnnotationMaybeExternal(fqName: FqName) = with (getAnnotations()) { +private fun KotlinType.hasAnnotationMaybeExternal(fqName: FqName) = with (annotations) { findAnnotation(fqName) ?: findExternalAnnotation(fqName) } != null fun KotlinType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolean): Boolean { if (canBeReferencedViaImport()) return true - val descriptor = getConstructor().getDeclarationDescriptor() - if (descriptor == null || descriptor.getName().isSpecial()) return false + val descriptor = constructor.declarationDescriptor + if (descriptor == null || descriptor.name.isSpecial) return false if (!checkTypeParameters && descriptor is TypeParameterDescriptor) return true return scope != null && scope.findClassifier(descriptor.name, NoLookupLocation.FROM_IDE) == descriptor } -public fun KotlinType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KotlinType { - if (isError() || isResolvableInScope(scope, checkTypeParameters)) return this +fun KotlinType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KotlinType { + if (isError || isResolvableInScope(scope, checkTypeParameters)) return this return supertypes().firstOrNull { it.isResolvableInScope(scope, checkTypeParameters) } ?: builtIns.anyType } -public fun KotlinType.anonymousObjectSuperTypeOrNull(): KotlinType? { +fun KotlinType.anonymousObjectSuperTypeOrNull(): KotlinType? { val classDescriptor = constructor.declarationDescriptor if (classDescriptor != null && DescriptorUtils.isAnonymousObject(classDescriptor)) { return immediateSupertypes().firstOrNull() ?: classDescriptor.builtIns.anyType diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt index c04896a7f2c..8d68b1f0c30 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt @@ -19,12 +19,12 @@ package org.jetbrains.kotlin.idea.util import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* -public fun KtFunctionLiteral.findLabelAndCall(): Pair { - val literalParent = (this.getParent() as KtLambdaExpression).getParent() +fun KtFunctionLiteral.findLabelAndCall(): Pair { + val literalParent = (this.parent as KtLambdaExpression).parent fun KtValueArgument.callExpression(): KtCallExpression? { - val parent = getParent() - return (if (parent is KtValueArgumentList) parent else this).getParent() as? KtCallExpression + val parent = parent + return (if (parent is KtValueArgumentList) parent else this).parent as? KtCallExpression } when (literalParent) { @@ -35,7 +35,7 @@ public fun KtFunctionLiteral.findLabelAndCall(): Pair is KtValueArgument -> { val callExpression = literalParent.callExpression() - val label = (callExpression?.getCalleeExpression() as? KtSimpleNameExpression)?.getReferencedNameAsName() + val label = (callExpression?.calleeExpression as? KtSimpleNameExpression)?.getReferencedNameAsName() return Pair(label, callExpression) } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index 9c07a010022..f13aa9ef325 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.nullability -public fun TCallable.substituteExtensionIfCallable( +fun TCallable.substituteExtensionIfCallable( receivers: Collection, context: BindingContext, dataFlowInfo: DataFlowInfo, @@ -42,7 +42,7 @@ public fun TCallable.substituteExtensionIfCalla containingDeclarationOrModule: DeclarationDescriptor ): Collection { val sequence = receivers.asSequence().flatMap { substituteExtensionIfCallable(it, callType, context, dataFlowInfo, containingDeclarationOrModule).asSequence() } - if (getTypeParameters().isEmpty()) { // optimization for non-generic callables + if (typeParameters.isEmpty()) { // optimization for non-generic callables return sequence.firstOrNull()?.let { listOf(it) } ?: listOf() } else { @@ -50,16 +50,16 @@ public fun TCallable.substituteExtensionIfCalla } } -public fun TCallable.substituteExtensionIfCallableWithImplicitReceiver( +fun TCallable.substituteExtensionIfCallableWithImplicitReceiver( scope: LexicalScope, context: BindingContext, dataFlowInfo: DataFlowInfo ): Collection { - val receiverValues = scope.getImplicitReceiversWithInstance().map { it.getValue() } + val receiverValues = scope.getImplicitReceiversWithInstance().map { it.value } return substituteExtensionIfCallable(receiverValues, context, dataFlowInfo, CallType.DEFAULT, scope.ownerDescriptor) } -public fun TCallable.substituteExtensionIfCallable( +fun TCallable.substituteExtensionIfCallable( receiver: ReceiverValue, callType: CallType<*>, bindingContext: BindingContext, @@ -70,7 +70,7 @@ public fun TCallable.substituteExtensionIfCalla return substituteExtensionIfCallable(types, callType) } -public fun TCallable.substituteExtensionIfCallable( +fun TCallable.substituteExtensionIfCallable( receiverTypes: Collection, callType: CallType<*> ): Collection { @@ -91,7 +91,7 @@ public fun TCallable.substituteExtensionIfCalla } substitutor } - if (getTypeParameters().isEmpty()) { // optimization for non-generic callables + if (typeParameters.isEmpty()) { // optimization for non-generic callables return if (substitutors.any()) listOf(this) else listOf() } else { @@ -99,10 +99,10 @@ public fun TCallable.substituteExtensionIfCalla } } -public fun ReceiverValue?.getThisReceiverOwner(bindingContext: BindingContext): DeclarationDescriptor? { +fun ReceiverValue?.getThisReceiverOwner(bindingContext: BindingContext): DeclarationDescriptor? { return when (this) { is ExpressionReceiver -> { - val thisRef = (KtPsiUtil.deparenthesize(this.expression) as? KtThisExpression)?.getInstanceReference() ?: return null + val thisRef = (KtPsiUtil.deparenthesize(this.expression) as? KtThisExpression)?.instanceReference ?: return null bindingContext[BindingContext.REFERENCE_TARGET, thisRef] } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt index a98818fb30c..ec14f32947f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt @@ -31,14 +31,14 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy import java.util.* -public fun LexicalScope.getImplicitReceiversWithInstance(): Collection +fun LexicalScope.getImplicitReceiversWithInstance(): Collection = getImplicitReceiversWithInstanceToExpression().keys -public interface ReceiverExpressionFactory { - public fun createExpression(psiFactory: KtPsiFactory, shortThis: Boolean = true): KtExpression +interface ReceiverExpressionFactory { + fun createExpression(psiFactory: KtPsiFactory, shortThis: Boolean = true): KtExpression } -public fun LexicalScope.getImplicitReceiversWithInstanceToExpression(): Map { +fun LexicalScope.getImplicitReceiversWithInstanceToExpression(): Map { // we use a set to workaround a bug with receiver for companion object present twice in the result of getImplicitReceiversHierarchy() val receivers = LinkedHashSet(getImplicitReceiversHierarchy()) @@ -46,19 +46,19 @@ public fun LexicalScope.getImplicitReceiversWithInstanceToExpression(): Map() for ((index, receiver) in receivers.withIndex()) { - val owner = receiver.getContainingDeclaration() + val owner = receiver.containingDeclaration val (expressionText, isImmediateThis) = if (owner in outerDeclarationsWithInstance) { val thisWithLabel = thisQualifierName(receiver)?.let { "this@${it.render()}" } if (index == 0) @@ -66,7 +66,7 @@ public fun LexicalScope.getImplicitReceiversWithInstanceToExpression(): Map { +fun LexicalScope.getAllAccessibleVariables(name: Name): Collection { return getVariablesFromImplicitReceivers(name) + collectVariables(name, NoLookupLocation.FROM_IDE) } -public fun LexicalScope.getAllAccessibleFunctions(name: Name): Collection { +fun LexicalScope.getAllAccessibleFunctions(name: Name): Collection { return getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) } + collectFunctions(name, NoLookupLocation.FROM_IDE) } -public fun LexicalScope.getVariablesFromImplicitReceivers(name: Name): Collection = getImplicitReceiversWithInstance().flatMap { +fun LexicalScope.getVariablesFromImplicitReceivers(name: Name): Collection = getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE) } -public fun LexicalScope.getVariableFromImplicitReceivers(name: Name): VariableDescriptor? { +fun LexicalScope.getVariableFromImplicitReceivers(name: Name): VariableDescriptor? { getImplicitReceiversWithInstance().forEach { it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE).singleOrNull()?.let { return it } } return null } -public fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolutionFacade: ResolutionFacade/*TODO: get rid of this parameter*/): LexicalScope { +fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolutionFacade: ResolutionFacade/*TODO: get rid of this parameter*/): LexicalScope { for (parent in parentsWithSelf) { if (parent is KtElement) { val scope = bindingContext[BindingContext.LEXICAL_SCOPE, parent] @@ -67,7 +67,7 @@ public fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolut if (parent is KtClassBody) { val classDescriptor = bindingContext[BindingContext.CLASS, parent.getParent()] as? ClassDescriptorWithResolutionScopes if (classDescriptor != null) { - return classDescriptor.getScopeForMemberDeclarationResolution() + return classDescriptor.scopeForMemberDeclarationResolution } } @@ -78,6 +78,6 @@ public fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolut error("Not in KtFile") } -public fun ResolutionFacade.getFileResolutionScope(file: KtFile): LexicalScope { +fun ResolutionFacade.getFileResolutionScope(file: KtFile): LexicalScope { return frontendService().getFileResolutionScope(file) } \ No newline at end of file diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/BodyResolveMode.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/BodyResolveMode.kt index 113795d574b..d67337bec75 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/BodyResolveMode.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/BodyResolveMode.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.resolve.lazy -public enum class BodyResolveMode { +enum class BodyResolveMode { FULL, PARTIAL, PARTIAL_FOR_COMPLETION diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index faaa4adca55..fc760d7208b 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -54,8 +54,8 @@ class PartialBodyResolveFilter( assert(!KtPsiUtil.isLocal(declaration)) { "Should never be invoked on local declaration otherwise we may miss some local declarations with type Nothing" } declaration.forEachDescendantOfType { declaration -> - if (declaration.getTypeReference().containsProbablyNothing()) { - val name = declaration.getName() + if (declaration.typeReference.containsProbablyNothing()) { + val name = declaration.name if (name != null) { if (declaration is KtNamedFunction) { nothingFunctionNames.add(name) @@ -91,8 +91,8 @@ class PartialBodyResolveFilter( } } else if (statement is KtDestructuringDeclaration) { - if (statement.getEntries().any { - val name = it.getName() + if (statement.entries.any { + val name = it.name name != null && nameFilter(name) }) { statementMarks.mark(statement, MarkLevel.NEED_REFERENCE_RESOLVE) @@ -164,25 +164,25 @@ class PartialBodyResolveFilter( override fun visitPostfixExpression(expression: KtPostfixExpression) { expression.acceptChildren(this) - if (expression.getOperationToken() == KtTokens.EXCLEXCL) { - addIfCanBeSmartCast(expression.getBaseExpression() ?: return) + if (expression.operationToken == KtTokens.EXCLEXCL) { + addIfCanBeSmartCast(expression.baseExpression ?: return) } } override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS) { expression.acceptChildren(this) - if (expression.getOperationReference().getReferencedNameElementType() == KtTokens.AS_KEYWORD) { - addIfCanBeSmartCast(expression.getLeft()) + if (expression.operationReference.getReferencedNameElementType() == KtTokens.AS_KEYWORD) { + addIfCanBeSmartCast(expression.left) } } override fun visitBinaryExpression(expression: KtBinaryExpression) { expression.acceptChildren(this) - if (expression.getOperationToken() == KtTokens.ELVIS) { - val left = expression.getLeft() - val right = expression.getRight() + if (expression.operationToken == KtTokens.ELVIS) { + val left = expression.left + val right = expression.right if (left != null && right != null) { val smartCastName = left.smartCastExpressionName() if (smartCastName != null && filter(smartCastName)) { @@ -194,9 +194,9 @@ class PartialBodyResolveFilter( } override fun visitIfExpression(expression: KtIfExpression) { - val condition = expression.getCondition() - val thenBranch = expression.getThen() - val elseBranch = expression.getElse() + val condition = expression.condition + val thenBranch = expression.then + val elseBranch = expression.`else` val (thenSmartCastNames, elseSmartCastNames) = possiblySmartCastInCondition(condition) @@ -239,11 +239,11 @@ class PartialBodyResolveFilter( override fun visitForExpression(expression: KtForExpression) { // analyze only the loop-range expression, do not enter the loop body - expression.getLoopRange()?.accept(this) + expression.loopRange?.accept(this) } override fun visitWhileExpression(expression: KtWhileExpression) { - val condition = expression.getCondition() + val condition = expression.condition // we need to enter the body only for "while(true)" if (condition.isTrueConstant()) { expression.acceptChildren(this) @@ -268,9 +268,9 @@ class PartialBodyResolveFilter( val emptyResult = Pair(setOf(), setOf()) when (condition) { is KtBinaryExpression -> { - val operation = condition.getOperationToken() - val left = condition.getLeft() ?: return emptyResult - val right = condition.getRight() ?: return emptyResult + val operation = condition.operationToken + val left = condition.left ?: return emptyResult + val right = condition.right ?: return emptyResult fun smartCastInEq(): Pair, Set> { if (left.isNullLiteral()) { @@ -307,19 +307,19 @@ class PartialBodyResolveFilter( } is KtIsExpression -> { - val cast = condition.getLeftHandSide().smartCastExpressionName().singletonOrEmptySet() - return if (condition.isNegated()) Pair(setOf(), cast) else Pair(cast, setOf()) + val cast = condition.leftHandSide.smartCastExpressionName().singletonOrEmptySet() + return if (condition.isNegated) Pair(setOf(), cast) else Pair(cast, setOf()) } is KtPrefixExpression -> { - if (condition.getOperationToken() == KtTokens.EXCL) { - val operand = condition.getBaseExpression() ?: return emptyResult + if (condition.operationToken == KtTokens.EXCL) { + val operand = condition.baseExpression ?: return emptyResult return possiblySmartCastInCondition(operand).swap() } } is KtParenthesizedExpression -> { - val operand = condition.getExpression() ?: return emptyResult + val operand = condition.expression ?: return emptyResult return possiblySmartCastInCondition(operand) } } @@ -345,10 +345,10 @@ class PartialBodyResolveFilter( } override fun visitIfExpression(expression: KtIfExpression) { - expression.getCondition()?.accept(this) + expression.condition?.accept(this) - val thenBranch = expression.getThen() - val elseBranch = expression.getElse() + val thenBranch = expression.then + val elseBranch = expression.`else` if (thenBranch != null && elseBranch != null) { // if we have only one branch it makes no sense to search exits in it val thenExits = collectAlwaysExitPoints(thenBranch) if (thenExits.isNotEmpty()) { @@ -362,15 +362,15 @@ class PartialBodyResolveFilter( } override fun visitForExpression(loop: KtForExpression) { - loop.getLoopRange()?.accept(this) + loop.loopRange?.accept(this) // do not make sense to search exits inside for as not necessary enter it at all } override fun visitWhileExpression(loop: KtWhileExpression) { - val condition = loop.getCondition() ?: return + val condition = loop.condition ?: return if (condition.isTrueConstant()) { insideLoopLevel++ - loop.getBody()?.accept(this) + loop.body?.accept(this) insideLoopLevel-- } else { @@ -380,9 +380,9 @@ class PartialBodyResolveFilter( } override fun visitDoWhileExpression(loop: KtDoWhileExpression) { - loop.getCondition()?.accept(this) + loop.condition?.accept(this) insideLoopLevel++ - loop.getBody()?.accept(this) + loop.body?.accept(this) insideLoopLevel-- } @@ -399,7 +399,7 @@ class PartialBodyResolveFilter( } override fun visitCallExpression(expression: KtCallExpression) { - val name = (expression.getCalleeExpression() as? KtSimpleNameExpression)?.getReferencedName() + val name = (expression.calleeExpression as? KtSimpleNameExpression)?.getReferencedName() if (name != null && name in nothingFunctionNames) { result.add(expression) } @@ -414,9 +414,9 @@ class PartialBodyResolveFilter( } override fun visitBinaryExpression(expression: KtBinaryExpression) { - if (expression.getOperationToken() == KtTokens.ELVIS) { + if (expression.operationToken == KtTokens.ELVIS) { // do not search exits after "?:" - expression.getLeft()?.accept(this) + expression.left?.accept(this) } else { super.visitBinaryExpression(expression) @@ -462,9 +462,9 @@ class PartialBodyResolveFilter( is KtSimpleNameExpression -> SmartCastName(null, this.getReferencedName()) is KtQualifiedExpression -> { - val selector = getSelectorExpression() as? KtSimpleNameExpression ?: return null + val selector = selectorExpression as? KtSimpleNameExpression ?: return null val selectorName = selector.getReferencedName() - val receiver = getReceiverExpression() + val receiver = receiverExpression if (receiver is KtThisExpression) { return SmartCastName(null, selectorName) } @@ -518,7 +518,7 @@ class PartialBodyResolveFilter( } companion object { - public fun findStatementToResolve(element: KtElement, declaration: KtDeclaration): KtExpression? { + fun findStatementToResolve(element: KtElement, declaration: KtDeclaration): KtExpression? { return element.parentsWithSelf.takeWhile { it != declaration }.firstOrNull { it.isStatement() } as KtExpression? } @@ -526,16 +526,16 @@ class PartialBodyResolveFilter( forEachDescendantOfType(canGoInside = { it !is KtBlockExpression }, action = action) } - private fun KtExpression?.isNullLiteral() = this?.getNode()?.getElementType() == KtNodeTypes.NULL + private fun KtExpression?.isNullLiteral() = this?.node?.elementType == KtNodeTypes.NULL private fun KtExpression?.isTrueConstant() - = this != null && getNode()?.getElementType() == KtNodeTypes.BOOLEAN_CONSTANT && getText() == "true" + = this != null && node?.elementType == KtNodeTypes.BOOLEAN_CONSTANT && text == "true" private fun T?.singletonOrEmptySet(): Set = if (this != null) setOf(this) else setOf() //TODO: review logic private fun isValueNeeded(expression: KtExpression): Boolean { - val parent = expression.getParent() + val parent = expression.parent return when (parent) { is KtBlockExpression -> expression == parent.lastStatement() && isValueNeeded(parent) @@ -545,7 +545,7 @@ class PartialBodyResolveFilter( } is KtDeclarationWithBody -> { - if (expression == parent.getBodyExpression()) + if (expression == parent.bodyExpression) !parent.hasBlockBody() && !parent.hasDeclaredReturnType() else true @@ -558,7 +558,7 @@ class PartialBodyResolveFilter( } private fun KtBlockExpression.lastStatement(): KtExpression? - = getLastChild()?.siblings(forward = false)?.firstIsInstanceOrNull() + = lastChild?.siblings(forward = false)?.firstIsInstanceOrNull() private fun PsiElement.isStatement() = this is KtExpression && getParent() is KtBlockExpression @@ -576,7 +576,7 @@ class PartialBodyResolveFilter( if (e.isStatement()) { markStatement(e as KtExpression, level) } - e = e.getParent()!! + e = e.parent!! } } @@ -585,7 +585,7 @@ class PartialBodyResolveFilter( if (currentLevel < level) { statementMarks[statement] = level - val block = statement.getParent() as KtBlockExpression + val block = statement.parent as KtBlockExpression val currentBlockLevel = blockLevels[block] ?: MarkLevel.NONE if (currentBlockLevel < level) { blockLevels[block] = level @@ -602,7 +602,7 @@ class PartialBodyResolveFilter( fun lastMarkedStatement(block: KtBlockExpression, minLevel: MarkLevel): KtExpression? { val level = blockLevels[block] ?: MarkLevel.NONE if (level < minLevel) return null // optimization - return block.getLastChild().siblings(forward = false) + return block.lastChild.siblings(forward = false) .filterIsInstance() .first { statementMark(it) >= minLevel } } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ProbablyNothingCallableNames.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ProbablyNothingCallableNames.kt index 1b4df3ebdc1..bef813d1b43 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ProbablyNothingCallableNames.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ProbablyNothingCallableNames.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.resolve.lazy -public interface ProbablyNothingCallableNames { - public fun functionNames(): Collection - public fun propertyNames(): Collection +interface ProbablyNothingCallableNames { + fun functionNames(): Collection + fun propertyNames(): Collection } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt index 403d84c1838..f4e67e17bd1 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt @@ -22,23 +22,23 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -public class ExplicitImportsScope(private val descriptors: Collection) : BaseImportingScope(null) { +class ExplicitImportsScope(private val descriptors: Collection) : BaseImportingScope(null) { override fun getContributedClassifier(name: Name, location: LookupLocation) - = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull() + = descriptors.filter { it.name == name }.firstIsInstanceOrNull() override fun getContributedPackage(name: Name) - = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull() + = descriptors.filter { it.name == name }.firstIsInstanceOrNull() override fun getContributedVariables(name: Name, location: LookupLocation) - = descriptors.filter { it.getName() == name }.filterIsInstance() + = descriptors.filter { it.name == name }.filterIsInstance() override fun getContributedFunctions(name: Name, location: LookupLocation) - = descriptors.filter { it.getName() == name }.filterIsInstance() + = descriptors.filter { it.name == name }.filterIsInstance() override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = descriptors override fun printStructure(p: Printer) { - p.println(javaClass.getName()) + p.println(javaClass.name) } } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/TypeIndexUtil.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/TypeIndexUtil.kt index a069fdf9a97..066c4bdb471 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/util/TypeIndexUtil.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/util/TypeIndexUtil.kt @@ -25,15 +25,15 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.psi.KtUserType -public fun KtUserType.aliasImportMap(): Multimap { +fun KtUserType.aliasImportMap(): Multimap { // we need to access containing file via stub because getPsi() may return null when indexing and getContainingFile() will crash - val file = getStub()?.getContainingFileStub()?.getPsi() ?: return HashMultimap.create() + val file = stub?.getContainingFileStub()?.psi ?: return HashMultimap.create() return (file as KtFile).aliasImportMap() } private fun KtFile.aliasImportMap(): Multimap { val cached = getUserData(ALIAS_IMPORT_DATA_KEY) - val modificationStamp = getModificationStamp() + val modificationStamp = modificationStamp if (cached != null && modificationStamp == cached.fileModificationStamp) { return cached.map } @@ -45,10 +45,10 @@ private fun KtFile.aliasImportMap(): Multimap { private fun KtFile.buildAliasImportMap(): Multimap { val map = HashMultimap.create() - val importList = getImportList() ?: return map - for (import in importList.getImports()) { - val aliasName = import.getAliasName() ?: continue - val name = import.getImportPath()?.fqnPart()?.shortName()?.asString() ?: continue + val importList = importList ?: return map + for (import in importList.imports) { + val aliasName = import.aliasName ?: continue + val name = import.importPath?.fqnPart()?.shortName()?.asString() ?: continue map.put(aliasName, name) } return map @@ -58,14 +58,14 @@ private class CachedAliasImportData(val map: Multimap, val fileM private val ALIAS_IMPORT_DATA_KEY = Key("ALIAS_IMPORT_MAP_KEY") -public fun KtTypeReference?.isProbablyNothing(): Boolean { +fun KtTypeReference?.isProbablyNothing(): Boolean { val userType = this?.typeElement as? KtUserType ?: return false return userType.isProbablyNothing() } -public fun KtUserType?.isProbablyNothing(): Boolean { +fun KtUserType?.isProbablyNothing(): Boolean { if (this == null) return false - val referencedName = getReferencedName() + val referencedName = referencedName return referencedName == "Nothing" || aliasImportMap()[referencedName].contains("Nothing") } @@ -73,5 +73,5 @@ private fun StubElement<*>.getContainingFileStub(): PsiFileStub<*> { return if (this is PsiFileStub) this else - getParentStub().getContainingFileStub() + parentStub.getContainingFileStub() } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt index 310b5a378c3..c7cabcdbec6 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt @@ -25,51 +25,51 @@ import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.equalTypesOrNulls -public fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?, descriptor2: DeclarationDescriptor?): Boolean { +fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?, descriptor2: DeclarationDescriptor?): Boolean { if (descriptor1 == descriptor2) return true if (descriptor1 == null || descriptor2 == null) return false - if (descriptor1.getOriginal() != descriptor2.getOriginal()) return false + if (descriptor1.original != descriptor2.original) return false if (descriptor1 !is CallableDescriptor) return true descriptor2 as CallableDescriptor val typeChecker = KotlinTypeChecker.withAxioms(object: KotlinTypeChecker.TypeConstructorEquality { override fun equals(a: TypeConstructor, b: TypeConstructor): Boolean { - val typeParam1 = a.getDeclarationDescriptor() as? TypeParameterDescriptor - val typeParam2 = b.getDeclarationDescriptor() as? TypeParameterDescriptor + val typeParam1 = a.declarationDescriptor as? TypeParameterDescriptor + val typeParam2 = b.declarationDescriptor as? TypeParameterDescriptor if (typeParam1 != null && typeParam2 != null - && typeParam1.getContainingDeclaration() == descriptor1 - && typeParam2.getContainingDeclaration() == descriptor2) { - return typeParam1.getIndex() == typeParam2.getIndex() + && typeParam1.containingDeclaration == descriptor1 + && typeParam2.containingDeclaration == descriptor2) { + return typeParam1.index == typeParam2.index } return a == b } }) - if (!typeChecker.equalTypesOrNulls(descriptor1.getReturnType(), descriptor2.getReturnType())) return false + if (!typeChecker.equalTypesOrNulls(descriptor1.returnType, descriptor2.returnType)) return false - val parameters1 = descriptor1.getValueParameters() - val parameters2 = descriptor2.getValueParameters() + val parameters1 = descriptor1.valueParameters + val parameters2 = descriptor2.valueParameters if (parameters1.size != parameters2.size) return false for ((param1, param2) in parameters1.zip(parameters2)) { - if (!typeChecker.equalTypes(param1.getType(), param2.getType())) return false + if (!typeChecker.equalTypes(param1.type, param2.type)) return false } return true } -public fun ClassDescriptor.findCallableMemberBySignature(signature: CallableMemberDescriptor): CallableMemberDescriptor? { +fun ClassDescriptor.findCallableMemberBySignature(signature: CallableMemberDescriptor): CallableMemberDescriptor? { val descriptorKind = if (signature is FunctionDescriptor) DescriptorKindFilter.FUNCTIONS else DescriptorKindFilter.VARIABLES - return getDefaultType().getMemberScope() + return defaultType.memberScope .getContributedDescriptors(descriptorKind) .filterIsInstance() .firstOrNull { - it.getContainingDeclaration() == this - && OverridingUtil.DEFAULT.isOverridableBy(it as CallableDescriptor, signature, null).getResult() == OVERRIDABLE + it.containingDeclaration == this + && OverridingUtil.DEFAULT.isOverridableBy(it as CallableDescriptor, signature, null).result == OVERRIDABLE } as? CallableMemberDescriptor } -public fun TypeConstructor.supertypesWithAny(): Collection { +fun TypeConstructor.supertypesWithAny(): Collection { val supertypes = supertypes val noSuperClass = supertypes .map { it.constructor.declarationDescriptor as? ClassDescriptor } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt index 4ee1bac0f34..0a919cc6d0c 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt @@ -22,39 +22,39 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure import java.util.LinkedHashMap -public fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): LinkedHashMap? { +fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): LinkedHashMap? { val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null - val substitution = LinkedHashMap(substitutedType.getArguments().size) - for ((param, arg) in baseType.getConstructor().getParameters().zip(substitutedType.getArguments())) { - substitution[param.getTypeConstructor()] = arg + val substitution = LinkedHashMap(substitutedType.arguments.size) + for ((param, arg) in baseType.constructor.parameters.zip(substitutedType.arguments)) { + substitution[param.typeConstructor] = arg } return substitution } -public fun getCallableSubstitution( +fun getCallableSubstitution( baseCallable: CallableDescriptor, derivedCallable: CallableDescriptor ): MutableMap? { - val baseClass = baseCallable.getContainingDeclaration() as? ClassDescriptor ?: return null - val derivedClass = derivedCallable.getContainingDeclaration() as? ClassDescriptor ?: return null - val substitution = getTypeSubstitution(baseClass.getDefaultType(), derivedClass.getDefaultType()) ?: return null + val baseClass = baseCallable.containingDeclaration as? ClassDescriptor ?: return null + val derivedClass = derivedCallable.containingDeclaration as? ClassDescriptor ?: return null + val substitution = getTypeSubstitution(baseClass.defaultType, derivedClass.defaultType) ?: return null - for ((baseParam, derivedParam) in baseCallable.getTypeParameters().zip(derivedCallable.getTypeParameters())) { - substitution[baseParam.getTypeConstructor()] = TypeProjectionImpl(derivedParam.getDefaultType()) + for ((baseParam, derivedParam) in baseCallable.typeParameters.zip(derivedCallable.typeParameters)) { + substitution[baseParam.typeConstructor] = TypeProjectionImpl(derivedParam.defaultType) } return substitution } -public fun getCallableSubstitutor( +fun getCallableSubstitutor( baseCallable: CallableDescriptor, derivedCallable: CallableDescriptor ): TypeSubstitutor? { return getCallableSubstitution(baseCallable, derivedCallable)?.let { TypeSubstitutor.create(it) } } -public fun getTypeSubstitutor(baseType: KotlinType, derivedType: KotlinType): TypeSubstitutor? { +fun getTypeSubstitutor(baseType: KotlinType, derivedType: KotlinType): TypeSubstitutor? { return getTypeSubstitution(baseType, derivedType)?.let { TypeSubstitutor.create(it) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalMode.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalMode.kt index 560299aa207..27f660c9138 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalMode.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalMode.kt @@ -18,11 +18,11 @@ package org.jetbrains.kotlin.idea.actions.internal import com.intellij.ide.util.PropertiesComponent -public class KotlinInternalMode { - public companion object Instance { +class KotlinInternalMode { + companion object Instance { val INTERNAL_MODE_PROPERTY = "kotlin.internal.mode.enabled" - public var enabled: Boolean + var enabled: Boolean get() = PropertiesComponent.getInstance()!!.getBoolean( INTERNAL_MODE_PROPERTY, System.getProperty(INTERNAL_MODE_PROPERTY) == "true" diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt index 74fc36af0e2..fa00efa348a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt @@ -30,8 +30,7 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor -@JvmOverloads -public fun KtExpression.computeTypeInfoInContext( +@JvmOverloads fun KtExpression.computeTypeInfoInContext( scope: LexicalScope, contextExpression: KtExpression = this, trace: BindingTrace = BindingTraceContext(), @@ -44,8 +43,7 @@ public fun KtExpression.computeTypeInfoInContext( .getTypeInfo(scope, this, expectedType, dataFlowInfo, trace, isStatement) } -@JvmOverloads -public fun KtExpression.analyzeInContext( +@JvmOverloads fun KtExpression.analyzeInContext( scope: LexicalScope, contextExpression: KtExpression = this, trace: BindingTrace = BindingTraceContext(), @@ -54,11 +52,10 @@ public fun KtExpression.analyzeInContext( isStatement: Boolean = false ): BindingContext { computeTypeInfoInContext(scope, contextExpression, trace, dataFlowInfo, expectedType, isStatement) - return trace.getBindingContext() + return trace.bindingContext } -@JvmOverloads -public fun KtExpression.computeTypeInContext( +@JvmOverloads fun KtExpression.computeTypeInContext( scope: LexicalScope, contextExpression: KtExpression = this, trace: BindingTrace = BindingTraceContext(), diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/FileAttributeService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/FileAttributeService.kt index 3907b3d7a85..29b76489c04 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/FileAttributeService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/FileAttributeService.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.idea.caches import com.intellij.openapi.vfs.VirtualFile -public data class CachedAttributeData>(val value: T?, val timeStamp: Long) +data class CachedAttributeData>(val value: T?, val timeStamp: Long) interface FileAttributeService { fun register(id: String, version: Int) {} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/JarUserDataManager.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/JarUserDataManager.kt index 9494c2ad888..d093594acaa 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/JarUserDataManager.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/JarUserDataManager.kt @@ -26,7 +26,7 @@ import com.intellij.util.io.URLUtil import org.jetbrains.kotlin.idea.util.application.runReadAction import java.util.concurrent.atomic.AtomicBoolean -public object JarUserDataManager { +object JarUserDataManager { enum class State { INIT, HAS_FILE, @@ -37,11 +37,11 @@ public object JarUserDataManager { val fileAttributeService: FileAttributeService? = ServiceManager.getService(FileAttributeService::class.java) - public fun register(counter: JarBooleanPropertyCounter) { + fun register(counter: JarBooleanPropertyCounter) { fileAttributeService?.register(counter.key.toString(), version) } - public fun hasFileWithProperty(counter: JarBooleanPropertyCounter, file: VirtualFile): Boolean? { + fun hasFileWithProperty(counter: JarBooleanPropertyCounter, file: VirtualFile): Boolean? { val localJarFile = JarFileSystemUtil.findLocalJarFile(file) ?: return null val stored = localJarFile.getUserData(counter.key) @@ -108,19 +108,19 @@ public object JarUserDataManager { } object JarFileSystemUtil { - public fun findJarFileRoot(inJarFile: VirtualFile): VirtualFile? { - if (!inJarFile.getUrl().startsWith("jar://")) return null + fun findJarFileRoot(inJarFile: VirtualFile): VirtualFile? { + if (!inJarFile.url.startsWith("jar://")) return null var jarFile = inJarFile - while (jarFile.getParent() != null) jarFile = jarFile.getParent() + while (jarFile.parent != null) jarFile = jarFile.parent return jarFile } - public fun findLocalJarFile(inJarFile: VirtualFile): VirtualFile? { - if (!inJarFile.getUrl().startsWith("jar://")) return null + fun findLocalJarFile(inJarFile: VirtualFile): VirtualFile? { + if (!inJarFile.url.startsWith("jar://")) return null - val path = inJarFile.getPath() + val path = inJarFile.path val jarSeparatorIndex = path.indexOf(URLUtil.JAR_SEPARATOR) assert(jarSeparatorIndex >= 0) { "Path passed to JarFileSystem must have jar separator '!/': $path" } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt index 9d91c2cde60..ab237018155 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.FqName import java.util.* -public class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache() { +class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache() { /** * Return kotlin class names from project sources which should be visible from java. */ @@ -80,7 +80,7 @@ public class KotlinShortNamesCache(private val project: Project) : PsiShortNames } override fun getAllClassNames(dest: HashSet) { - dest.addAll(getAllClassNames()) + dest.addAll(allClassNames) } override fun getMethodsByName(name: String, scope: GlobalSearchScope): Array diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt index 9cb0c07a349..30b7ec4a058 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt @@ -28,12 +28,12 @@ import com.intellij.util.cls.ClsFormatException import com.intellij.util.containers.ContainerUtil import java.io.IOException -public class ClsJavaStubByVirtualFileCache { +class ClsJavaStubByVirtualFileCache { private class CachedJavaStub(val modificationStamp: Long, val javaFileStub: PsiJavaFileStubImpl) private val cache = ContainerUtil.createConcurrentWeakKeySoftValueMap() - public fun get(classFile: VirtualFile): PsiJavaFileStubImpl? { + fun get(classFile: VirtualFile): PsiJavaFileStubImpl? { val cached = cache.get(classFile) val fileModificationStamp = classFile.modificationStamp if (cached != null && cached.modificationStamp == fileModificationStamp) { @@ -64,7 +64,7 @@ public class ClsJavaStubByVirtualFileCache { companion object { private val LOG = Logger.getInstance(ClsJavaStubByVirtualFileCache::class.java) - public fun getInstance(project: Project): ClsJavaStubByVirtualFileCache { + fun getInstance(project: Project): ClsJavaStubByVirtualFileCache { return ServiceManager.getService(project, ClsJavaStubByVirtualFileCache::class.java) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/CodeFragmentAnalyzer.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/CodeFragmentAnalyzer.kt index 4859a2344bf..7750e927ac1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/CodeFragmentAnalyzer.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/CodeFragmentAnalyzer.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import javax.inject.Inject -public class CodeFragmentAnalyzer( +class CodeFragmentAnalyzer( private val resolveSession: ResolveSession, private val qualifierResolver: QualifiedExpressionResolver, private val expressionTypingServices: ExpressionTypingServices, @@ -43,10 +43,10 @@ public class CodeFragmentAnalyzer( ) { // component dependency cycle - public var resolveElementCache: ResolveElementCache? = null + var resolveElementCache: ResolveElementCache? = null @Inject set - public fun analyzeCodeFragment(codeFragment: KtCodeFragment, trace: BindingTrace, bodyResolveMode: BodyResolveMode) { + fun analyzeCodeFragment(codeFragment: KtCodeFragment, trace: BindingTrace, bodyResolveMode: BodyResolveMode) { val codeFragmentElement = codeFragment.getContentElement() val (scopeForContextElement, dataFlowInfo) = getScopeAndDataFlowForAnalyzeFragment(codeFragment) { @@ -76,10 +76,10 @@ public class CodeFragmentAnalyzer( //TODO: this code should be moved into debugger which should set correct context for its code fragment private fun KtExpression.correctContextForExpression(): KtExpression { return when (this) { - is KtProperty -> this.getDelegateExpressionOrInitializer() - is KtFunctionLiteral -> this.getBodyExpression()?.getStatements()?.lastOrNull() - is KtDeclarationWithBody -> this.getBodyExpression() - is KtBlockExpression -> this.getStatements().lastOrNull() + is KtProperty -> this.delegateExpressionOrInitializer + is KtFunctionLiteral -> this.bodyExpression?.statements?.lastOrNull() + is KtDeclarationWithBody -> this.bodyExpression + is KtBlockExpression -> this.statements.lastOrNull() else -> { val previousSibling = this.siblings(forward = false, withItself = false).firstIsInstanceOrNull() if (previousSibling != null) return previousSibling @@ -96,7 +96,7 @@ public class CodeFragmentAnalyzer( codeFragment: KtCodeFragment, resolveToElement: (KtElement) -> BindingContext ): Pair? { - val context = codeFragment.getContext() + val context = codeFragment.context if (context !is KtExpression) return null val scopeForContextElement: LexicalScope? @@ -106,7 +106,7 @@ public class CodeFragmentAnalyzer( is KtPrimaryConstructor -> { val descriptor = resolveSession.getClassDescriptor(context.getContainingClassOrObject(), NoLookupLocation.FROM_IDE) as ClassDescriptorWithResolutionScopes - scopeForContextElement = descriptor.getScopeForInitializerResolution() + scopeForContextElement = descriptor.scopeForInitializerResolution dataFlowInfo = DataFlowInfo.EMPTY } is KtSecondaryConstructor -> { @@ -120,7 +120,7 @@ public class CodeFragmentAnalyzer( is KtClassOrObject -> { val descriptor = resolveSession.getClassDescriptor(context, NoLookupLocation.FROM_IDE) as ClassDescriptorWithResolutionScopes - scopeForContextElement = descriptor.getScopeForMemberDeclarationResolution() + scopeForContextElement = descriptor.scopeForMemberDeclarationResolution dataFlowInfo = DataFlowInfo.EMPTY } is KtExpression -> { @@ -132,7 +132,7 @@ public class CodeFragmentAnalyzer( dataFlowInfo = contextForElement.getDataFlowInfo(correctedContext) } is KtFile -> { - scopeForContextElement = resolveSession.getFileScopeProvider().getFileResolutionScope(context) + scopeForContextElement = resolveSession.fileScopeProvider.getFileResolutionScope(context) dataFlowInfo = DataFlowInfo.EMPTY } else -> return null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt index b7f9f401df7..827d4fc3267 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.utils.sure import java.util.* -public class IDELightClassGenerationSupport(private val project: Project) : LightClassGenerationSupport() { +class IDELightClassGenerationSupport(private val project: Project) : LightClassGenerationSupport() { private val scopeFileComparator = JavaElementFinder.byClasspathComparator(GlobalSearchScope.allScope(project)) private val psiManager: PsiManager = PsiManager.getInstance(project) @@ -182,7 +182,7 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh } } - public fun createLightClassForFileFacade( + fun createLightClassForFileFacade( facadeFqName: FqName, facadeFiles: List, moduleInfo: IdeaModuleInfo diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDEPackagePartProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDEPackagePartProvider.kt index 377771636b7..ec4d7851217 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDEPackagePartProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDEPackagePartProvider.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.vfilefinder.KotlinModuleMappingIndex import org.jetbrains.kotlin.descriptors.PackagePartProvider import org.jetbrains.kotlin.load.kotlin.PackageParts -public class IDEPackagePartProvider(val scope: GlobalSearchScope) : PackagePartProvider { +class IDEPackagePartProvider(val scope: GlobalSearchScope) : PackagePartProvider { override fun findPackageParts(packageFqName: String): List { val values: MutableList = FileBasedIndex.getInstance().getValues(KotlinModuleMappingIndex.KEY, packageFqName, scope) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt index 3b4ac6aeaf0..5cb7432d447 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt @@ -32,9 +32,9 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.emptyOrSingletonList import java.util.* -public val LIBRARY_NAME_PREFIX: String = "library " +val LIBRARY_NAME_PREFIX: String = "library " -public interface IdeaModuleInfo : ModuleInfo { +interface IdeaModuleInfo : ModuleInfo { fun contentScope(): GlobalSearchScope val moduleOrigin: ModuleOrigin @@ -51,14 +51,14 @@ private fun orderEntryToModuleInfo(project: Project, orderEntry: OrderEntry, pro orderEntry.getOwnerModule().toInfos() } is ModuleOrderEntry -> { - orderEntry.getModule()?.toInfos().orEmpty() + orderEntry.module?.toInfos().orEmpty() } is LibraryOrderEntry -> { - val library = orderEntry.getLibrary() ?: return listOf() + val library = orderEntry.library ?: return listOf() emptyOrSingletonList(LibraryInfo(project, library)) } is JdkOrderEntry -> { - val sdk = orderEntry.getJdk() ?: return listOf() + val sdk = orderEntry.jdk ?: return listOf() emptyOrSingletonList(SdkInfo(project, sdk)) } else -> { @@ -68,7 +68,7 @@ private fun orderEntryToModuleInfo(project: Project, orderEntry: OrderEntry, pro } private fun Module.cached(provider: CachedValueProvider): T { - return CachedValuesManager.getManager(getProject()).getCachedValue(this, provider) + return CachedValuesManager.getManager(project).getCachedValue(this, provider) } fun ideaModelDependencies(module: Module, productionOnly: Boolean): List { @@ -80,58 +80,58 @@ fun ideaModelDependencies(module: Module, productionOnly: Boolean): List - result.addAll(orderEntryToModuleInfo(module.getProject(), orderEntry!!, productionOnly)) + result.addAll(orderEntryToModuleInfo(module.project, orderEntry!!, productionOnly)) true } return result.toList() } -public interface ModuleSourceInfo : IdeaModuleInfo { +interface ModuleSourceInfo : IdeaModuleInfo { val module: Module override val moduleOrigin: ModuleOrigin get() = ModuleOrigin.MODULE } -public data class ModuleProductionSourceInfo(override val module: Module) : ModuleSourceInfo { - override val name = Name.special("") +data class ModuleProductionSourceInfo(override val module: Module) : ModuleSourceInfo { + override val name = Name.special("") override fun contentScope(): GlobalSearchScope = ModuleProductionSourceScope(module) override fun dependencies() = module.cached(CachedValueProvider { CachedValueProvider.Result( ideaModelDependencies(module, productionOnly = true), - ProjectRootModificationTracker.getInstance(module.getProject())) + ProjectRootModificationTracker.getInstance(module.project)) }) override fun friends() = listOf(module.testSourceInfo()) } //TODO: (module refactoring) do not create ModuleTestSourceInfo when there are no test roots for module -public data class ModuleTestSourceInfo(override val module: Module) : ModuleSourceInfo { - override val name = Name.special("") +data class ModuleTestSourceInfo(override val module: Module) : ModuleSourceInfo { + override val name = Name.special("") override fun contentScope(): GlobalSearchScope = ModuleTestSourceScope(module) override fun dependencies() = module.cached(CachedValueProvider { CachedValueProvider.Result( ideaModelDependencies(module, productionOnly = false), - ProjectRootModificationTracker.getInstance(module.getProject())) + ProjectRootModificationTracker.getInstance(module.project)) }) } internal fun ModuleSourceInfo.isTests() = this is ModuleTestSourceInfo -public fun Module.productionSourceInfo(): ModuleProductionSourceInfo = ModuleProductionSourceInfo(this) -public fun Module.testSourceInfo(): ModuleTestSourceInfo = ModuleTestSourceInfo(this) +fun Module.productionSourceInfo(): ModuleProductionSourceInfo = ModuleProductionSourceInfo(this) +fun Module.testSourceInfo(): ModuleTestSourceInfo = ModuleTestSourceInfo(this) -private abstract class ModuleSourceScope(val module: Module) : GlobalSearchScope(module.getProject()) { +private abstract class ModuleSourceScope(val module: Module) : GlobalSearchScope(module.project) { override fun compare(file1: VirtualFile, file2: VirtualFile) = 0 override fun isSearchInModuleContent(aModule: Module) = aModule == module override fun isSearchInLibraries() = false } private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(module) { - val moduleFileIndex = ModuleRootManager.getInstance(module).getFileIndex() + val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex override fun equals(other: Any?): Boolean { if (this === other) return true @@ -144,7 +144,7 @@ private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(mo } private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) { - val moduleFileIndex = ModuleRootManager.getInstance(module).getFileIndex() + val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex override fun equals(other: Any?): Boolean { if (this === other) return true @@ -156,11 +156,11 @@ private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) override fun contains(file: VirtualFile) = moduleFileIndex.isInTestSourceContent(file) } -public data class LibraryInfo(val project: Project, val library: Library) : IdeaModuleInfo { +data class LibraryInfo(val project: Project, val library: Library) : IdeaModuleInfo { override val moduleOrigin: ModuleOrigin get() = ModuleOrigin.LIBRARY - override val name: Name = Name.special("<$LIBRARY_NAME_PREFIX${library.getName()}>") + override val name: Name = Name.special("<$LIBRARY_NAME_PREFIX${library.name}>") override fun contentScope(): GlobalSearchScope = LibraryWithoutSourceScope(project, library) @@ -179,14 +179,14 @@ public data class LibraryInfo(val project: Project, val library: Library) : Idea return result.toList() } - override fun toString() = "LibraryInfo(libraryName=${library.getName()})" + override fun toString() = "LibraryInfo(libraryName=${library.name})" } internal data class LibrarySourceInfo(val project: Project, val library: Library) : IdeaModuleInfo { override val moduleOrigin: ModuleOrigin get() = ModuleOrigin.OTHER - override val name: Name = Name.special("") + override val name: Name = Name.special("") override fun contentScope() = GlobalSearchScope.EMPTY_SCOPE @@ -197,15 +197,15 @@ internal data class LibrarySourceInfo(val project: Project, val library: Library return listOf(this) + LibraryInfo(project, library).dependencies() } - override fun toString() = "LibrarySourceInfo(libraryName=${library.getName()})" + override fun toString() = "LibrarySourceInfo(libraryName=${library.name})" } //TODO: (module refactoring) there should be separate SdkSourceInfo but there are no kotlin source in existing sdks for now :) -public data class SdkInfo(val project: Project, val sdk: Sdk) : IdeaModuleInfo { +data class SdkInfo(val project: Project, val sdk: Sdk) : IdeaModuleInfo { override val moduleOrigin: ModuleOrigin get() = ModuleOrigin.LIBRARY - override val name: Name = Name.special("<$LIBRARY_NAME_PREFIX${sdk.getName()}>") + override val name: Name = Name.special("<$LIBRARY_NAME_PREFIX${sdk.name}>") override fun contentScope(): GlobalSearchScope = SdkScope(project, sdk) @@ -234,7 +234,7 @@ private class LibraryWithoutSourceScope(project: Project, private val library: L //TODO: (module refactoring) android sdk has modified scope private class SdkScope(project: Project, private val sdk: Sdk) : - LibraryScopeBase(project, sdk.getRootProvider().getFiles(OrderRootType.CLASSES), arrayOf()) { + LibraryScopeBase(project, sdk.rootProvider.getFiles(OrderRootType.CLASSES), arrayOf()) { override fun equals(other: Any?) = other is SdkScope && sdk == other.sdk diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt index e73f2b609d1..383ec4a4a3b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt @@ -97,7 +97,7 @@ private fun JavaDescriptorResolver.resolveMethod(method: JavaMethod): FunctionDe } private fun JavaDescriptorResolver.resolveConstructor(constructor: JavaConstructor): ConstructorDescriptor? { - return resolveClass(constructor.getContainingClass())?.getConstructors()?.findByJavaElement(constructor) + return resolveClass(constructor.containingClass)?.constructors?.findByJavaElement(constructor) } private fun JavaDescriptorResolver.resolveField(field: JavaField): PropertyDescriptor? { @@ -105,21 +105,21 @@ private fun JavaDescriptorResolver.resolveField(field: JavaField): PropertyDescr } private fun JavaDescriptorResolver.getContainingScope(member: JavaMember): MemberScope? { - val containingClass = resolveClass(member.getContainingClass()) - return if (member.isStatic()) - containingClass?.getStaticScope() + val containingClass = resolveClass(member.containingClass) + return if (member.isStatic) + containingClass?.staticScope else - containingClass?.getDefaultType()?.getMemberScope() + containingClass?.defaultType?.memberScope } private fun Collection.findByJavaElement(javaElement: JavaElement): T? { return firstOrNull { member -> - val memberJavaElement = (member.getOriginal().getSource() as? JavaSourceElement)?.javaElement + val memberJavaElement = (member.original.source as? JavaSourceElement)?.javaElement when { memberJavaElement == javaElement -> true memberJavaElement is JavaElementImpl<*> && javaElement is JavaElementImpl<*> -> - memberJavaElement.getPsi().isEquivalentTo(javaElement.getPsi()) + memberJavaElement.psi.isEquivalentTo(javaElement.psi) else -> false } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsAnalyzerFacade.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsAnalyzerFacade.kt index dead0d2724a..0743fbaf57d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsAnalyzerFacade.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsAnalyzerFacade.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils -public object JsAnalyzerFacade : AnalyzerFacade() { +object JsAnalyzerFacade : AnalyzerFacade() { override fun createResolverForModule( moduleInfo: M, @@ -55,7 +55,7 @@ public object JsAnalyzerFacade : AnalyzerFacade() { ) val container = createContainerForLazyResolve(moduleContext, declarationProviderFactory, BindingTraceContext(), JsPlatform, targetEnvironment) - var packageFragmentProvider = container.get().getPackageFragmentProvider() + var packageFragmentProvider = container.get().packageFragmentProvider if (moduleInfo is LibraryInfo && KotlinJavaScriptLibraryDetectionUtil.isKotlinJavaScriptLibrary(moduleInfo.library)) { val providers = moduleInfo.library.getFiles(OrderRootType.CLASSES) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt index ff1e44f81ef..0573b2879df 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt @@ -24,11 +24,10 @@ import com.intellij.psi.util.CachedValueProvider import com.intellij.openapi.roots.ProjectRootModificationTracker //TODO: this should go away to support cross-platform projects -public object JsProjectDetector { - @JvmStatic - public fun isJsProject(project: Project): Boolean { +object JsProjectDetector { + @JvmStatic fun isJsProject(project: Project): Boolean { return CachedValuesManager.getManager(project).getCachedValue(project) { - val result = ModuleManager.getInstance(project).getModules().any { ProjectStructureUtil.isJsKotlinModule(it) } + val result = ModuleManager.getInstance(project).modules.any { ProjectStructureUtil.isJsKotlinModule(it) } CachedValueProvider.Result(result, ProjectRootModificationTracker.getInstance(project)) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt index eb827968fc9..af7481999ba 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt @@ -44,17 +44,16 @@ import org.jetbrains.kotlin.utils.keysToMap internal val LOG = Logger.getInstance(KotlinCacheService::class.java) -public class KotlinCacheService(val project: Project) { +class KotlinCacheService(val project: Project) { companion object { - @JvmStatic - public fun getInstance(project: Project): KotlinCacheService = ServiceManager.getService(project, KotlinCacheService::class.java)!! + @JvmStatic fun getInstance(project: Project): KotlinCacheService = ServiceManager.getService(project, KotlinCacheService::class.java)!! } - public fun getResolutionFacade(elements: List): ResolutionFacade { + fun getResolutionFacade(elements: List): ResolutionFacade { return getFacadeToAnalyzeFiles(elements.map { it.getContainingKtFile() }) } - public fun getSuppressionCache(): KotlinSuppressCache = kotlinSuppressCache.value + fun getSuppressionCache(): KotlinSuppressCache = kotlinSuppressCache.value private val globalFacadesPerPlatform = listOf(JvmPlatform, JsPlatform).keysToMap { platform -> GlobalFacade(platform) } @@ -84,8 +83,7 @@ public class KotlinCacheService(val project: Project) { } } - @Deprecated("Use JetElement.getResolutionFacade(), please avoid introducing new usages") - public fun getProjectService(platform: TargetPlatform, ideaModuleInfo: IdeaModuleInfo, serviceClass: Class): T { + @Deprecated("Use JetElement.getResolutionFacade(), please avoid introducing new usages") fun getProjectService(platform: TargetPlatform, ideaModuleInfo: IdeaModuleInfo, serviceClass: Class): T { return globalFacade(platform).resolverForModuleInfo(ideaModuleInfo).componentProvider.getService(serviceClass) } @@ -219,7 +217,7 @@ public class KotlinCacheService(val project: Project) { }.toSet() private fun KtCodeFragment.getContextFile(): KtFile? { - val contextElement = getContext() ?: return null + val contextElement = context ?: return null val contextFile = (contextElement as? KtElement)?.getContainingKtFile() ?: throw AssertionError("Analyzing kotlin code fragment of type $javaClass with java context of type ${contextElement.javaClass}") return if (contextFile is KtCodeFragment) contextFile.getContextFile() else contextFile diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinOutOfBlockCompletionModificationTracker.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinOutOfBlockCompletionModificationTracker.kt index 41b57283495..d7b3633345c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinOutOfBlockCompletionModificationTracker.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinOutOfBlockCompletionModificationTracker.kt @@ -26,15 +26,15 @@ import org.jetbrains.kotlin.asJava.KotlinCodeBlockModificationListener // Synthetic file for completion can be modified without sending tree changed events and sequence of completions can lead to inconsistent // resolve session being cached for such a file otherwise. // This code is not tested. See KT-6216 for an example. -public class KotlinOutOfBlockCompletionModificationTracker() : SimpleModificationTracker() { +class KotlinOutOfBlockCompletionModificationTracker() : SimpleModificationTracker() { companion object { - public fun getInstance(project: Project): KotlinOutOfBlockCompletionModificationTracker + fun getInstance(project: Project): KotlinOutOfBlockCompletionModificationTracker = ServiceManager.getService(project, KotlinOutOfBlockCompletionModificationTracker::class.java)!! } } -public fun performCompletionWithOutOfBlockTracking(completionPosition: PsiElement, body: () -> Unit) { +fun performCompletionWithOutOfBlockTracking(completionPosition: PsiElement, body: () -> Unit) { if (KotlinCodeBlockModificationListener.isInsideCodeBlock(completionPosition)) { body() return @@ -43,6 +43,6 @@ public fun performCompletionWithOutOfBlockTracking(completionPosition: PsiElemen body() } finally { - KotlinOutOfBlockCompletionModificationTracker.getInstance(completionPosition.getProject()).incModificationCount() + KotlinOutOfBlockCompletionModificationTracker.getInstance(completionPosition.project).incModificationCount() } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt index 632d842f264..a45ed43335a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt @@ -84,7 +84,7 @@ internal class PerFileAnalysisCache(val file: KtFile, val componentProvider: Com } private fun analyze(analyzableElement: KtElement): AnalysisResult { - val project = analyzableElement.getProject() + val project = analyzableElement.project if (DumbService.isDumb(project)) { return AnalysisResult.EMPTY } @@ -158,7 +158,7 @@ private object KotlinResolveDataProvider { } val resolveSession = componentProvider.get() - val trace = DelegatingBindingTrace(resolveSession.getBindingContext(), "Trace for resolution of " + analyzableElement) + val trace = DelegatingBindingTrace(resolveSession.bindingContext, "Trace for resolution of " + analyzableElement) val targetPlatform = TargetPlatformDetector.getPlatform(analyzableElement.getContainingKtFile()) @@ -176,7 +176,7 @@ private object KotlinResolveDataProvider { listOf(analyzableElement) ) return AnalysisResult.success( - trace.getBindingContext(), + trace.bindingContext, module ) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KtLightClassForDecompiledDeclaration.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KtLightClassForDecompiledDeclaration.kt index 7ad78851ed6..d05c45f90e5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KtLightClassForDecompiledDeclaration.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KtLightClassForDecompiledDeclaration.kt @@ -25,20 +25,20 @@ import org.jetbrains.kotlin.psi.KtClassOrObject class KtLightClassForDecompiledDeclaration( private val clsClass: ClsClassImpl, private val origin: KtClassOrObject? -) : KtWrappingLightClass(clsClass.getManager()) { - private val fqName = origin?.getFqName() ?: FqName(clsClass.getQualifiedName()) +) : KtWrappingLightClass(clsClass.manager) { + private val fqName = origin?.fqName ?: FqName(clsClass.qualifiedName) override fun copy() = this override fun getOwnInnerClasses(): List { - val nestedClasses = origin?.getDeclarations()?.filterIsInstance() ?: emptyList() - return clsClass.getOwnInnerClasses().map { innerClsClass -> + val nestedClasses = origin?.declarations?.filterIsInstance() ?: emptyList() + return clsClass.ownInnerClasses.map { innerClsClass -> KtLightClassForDecompiledDeclaration(innerClsClass as ClsClassImpl, - nestedClasses.firstOrNull { innerClsClass.getName() == it.getName() }) + nestedClasses.firstOrNull { innerClsClass.name == it.name }) } } - override fun getNavigationElement() = origin?.getNavigationElement() ?: super.getNavigationElement() + override fun getNavigationElement() = origin?.navigationElement ?: super.getNavigationElement() override fun getDelegate() = clsClass diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/LibraryDependenciesCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/LibraryDependenciesCache.kt index 17d16519849..0dc39b24b48 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/LibraryDependenciesCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/LibraryDependenciesCache.kt @@ -36,14 +36,14 @@ import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.JdkOrderEntry import com.intellij.openapi.roots.ModuleSourceOrderEntry -public class LibraryDependenciesCache(private val project: Project) { +class LibraryDependenciesCache(private val project: Project) { //NOTE: used LibraryRuntimeClasspathScope as reference - public fun getLibrariesAndSdksUsedWith(library: Library): Pair, List> { + fun getLibrariesAndSdksUsedWith(library: Library): Pair, List> { val processedModules = LinkedHashSet() val condition = Condition() { orderEntry -> if (orderEntry is ModuleOrderEntry) { - val module = orderEntry.getModule() + val module = orderEntry.module module != null && module !in processedModules } else { @@ -59,17 +59,17 @@ public class LibraryDependenciesCache(private val project: Project) { ModuleRootManager.getInstance(module).orderEntries().recursively().satisfying(condition).process(object : RootPolicy() { override fun visitModuleSourceOrderEntry(moduleSourceOrderEntry: ModuleSourceOrderEntry?, value: Unit?): Unit? { - processedModules.addIfNotNull(moduleSourceOrderEntry?.getOwnerModule()) + processedModules.addIfNotNull(moduleSourceOrderEntry?.ownerModule) return Unit } - public override fun visitLibraryOrderEntry(libraryOrderEntry: LibraryOrderEntry?, value: Unit?): Unit? { - libraries.addIfNotNull(libraryOrderEntry?.getLibrary()) + override fun visitLibraryOrderEntry(libraryOrderEntry: LibraryOrderEntry?, value: Unit?): Unit? { + libraries.addIfNotNull(libraryOrderEntry?.library) return Unit } override fun visitJdkOrderEntry(jdkOrderEntry: JdkOrderEntry?, value: Unit?): Unit? { - sdks.addIfNotNull(jdkOrderEntry?.getJdk()) + sdks.addIfNotNull(jdkOrderEntry?.jdk) return Unit } }, Unit) @@ -90,12 +90,12 @@ public class LibraryDependenciesCache(private val project: Project) { val modulesLibraryIsUsedIn: MultiMap = MultiMap.createSet() init { - ModuleManager.getInstance(project).getModules().forEach { + ModuleManager.getInstance(project).modules.forEach { module -> - ModuleRootManager.getInstance(module).getOrderEntries().forEach { + ModuleRootManager.getInstance(module).orderEntries.forEach { entry -> if (entry is LibraryOrderEntry) { - val library = entry.getLibrary() + val library = entry.library if (library != null) { modulesLibraryIsUsedIn.putValue(library, module) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ModuleDependencyMapper.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ModuleDependencyMapper.kt index 63907c46036..9b77194eb2a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ModuleDependencyMapper.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ModuleDependencyMapper.kt @@ -58,7 +58,7 @@ fun createModuleResolverProvider( val jvmPlatformParameters = JvmPlatformParameters { javaClass: JavaClass -> - val psiClass = (javaClass as JavaClassImpl).getPsi() + val psiClass = (javaClass as JavaClassImpl).psi psiClass.getNullableModuleInfo() } @@ -79,21 +79,21 @@ fun createModuleResolverProvider( } private fun collectAllModuleInfosFromIdeaModel(project: Project): List { - val ideaModules = ModuleManager.getInstance(project).getModules().toList() + val ideaModules = ModuleManager.getInstance(project).modules.toList() val modulesSourcesInfos = ideaModules.flatMap { listOf(it.productionSourceInfo(), it.testSourceInfo()) } //TODO: (module refactoring) include libraries that are not among dependencies of any module val ideaLibraries = ideaModules.flatMap { - ModuleRootManager.getInstance(it).getOrderEntries().filterIsInstance().map { - it.getLibrary() + ModuleRootManager.getInstance(it).orderEntries.filterIsInstance().map { + it.library } }.filterNotNull().toSet() val librariesInfos = ideaLibraries.map { LibraryInfo(project, it) } val ideaSdks = ideaModules.flatMap { - ModuleRootManager.getInstance(it).getOrderEntries().filterIsInstance().map { - it.getJdk() + ModuleRootManager.getInstance(it).orderEntries.filterIsInstance().map { + it.jdk } }.filterNotNull().toSet() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt index 61f84e77e12..c9e28ed68c2 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt @@ -67,7 +67,7 @@ internal class ProjectResolutionFacade( fun getAnalysisResultsForElements(elements: Collection): AnalysisResult { assert(elements.isNotEmpty()) { "elements collection should not be empty" } val slruCache = synchronized(analysisResults) { - analysisResults.getValue()!! + analysisResults.value!! } val results = elements.map { val perFileCache = synchronized(slruCache) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/cacheUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/cacheUtils.kt index c3abb8e7231..b05188a3f74 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/cacheUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/cacheUtils.kt @@ -26,9 +26,9 @@ class SynchronizedCachedValue(project: Project, provider: () -> CachedValuePr trackValue ) - public fun getValue(): V { + fun getValue(): V { return synchronized(cachedValue) { - cachedValue.getValue() + cachedValue.value } } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt index 07824d0e478..dbcc15d6cee 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt @@ -44,14 +44,14 @@ fun PsiElement.getNullableModuleInfo(): IdeaModuleInfo? = this.getModuleInfo { r private fun PsiElement.getModuleInfo(onFailure: (String) -> IdeaModuleInfo?): IdeaModuleInfo? { if (this is KtLightElement<*, *>) return this.getModuleInfoForLightElement() - val containingJetFile = (this as? KtElement)?.getContainingFile() as? KtFile + val containingJetFile = (this as? KtElement)?.containingFile as? KtFile val context = containingJetFile?.analysisContext if (context != null) return context.getModuleInfo() val doNotAnalyze = containingJetFile?.doNotAnalyze if (doNotAnalyze != null) { return onFailure( - "Should not analyze element: ${getText()} in file ${containingJetFile?.getName() ?: " "}\n$doNotAnalyze" + "Should not analyze element: ${text} in file ${containingJetFile?.name ?: " "}\n$doNotAnalyze" ) } @@ -71,7 +71,7 @@ private fun PsiElement.getModuleInfo(onFailure: (String) -> IdeaModuleInfo?): Id return getModuleInfoByVirtualFile( project, virtualFile, - isDecompiledFile = (containingFile as? KtFile)?.isCompiled() ?: false + isDecompiledFile = (containingFile as? KtFile)?.isCompiled ?: false ) } @@ -82,11 +82,11 @@ private fun getModuleInfoByVirtualFile(project: Project, virtualFile: VirtualFil if (module != null) { fun warnIfDecompiled() { if (isDecompiledFile) { - LOG.warn("Decompiled file for ${virtualFile.getCanonicalPath()} is in content of $module") + LOG.warn("Decompiled file for ${virtualFile.canonicalPath} is in content of $module") } } - val moduleFileIndex = ModuleRootManager.getInstance(module).getFileIndex() + val moduleFileIndex = ModuleRootManager.getInstance(module).fileIndex if (moduleFileIndex.isInTestSourceContent(virtualFile)) { warnIfDecompiled() return module.testSourceInfo() @@ -102,7 +102,7 @@ private fun getModuleInfoByVirtualFile(project: Project, virtualFile: VirtualFil entries@ for (orderEntry in orderEntries) { when (orderEntry) { is LibraryOrderEntry -> { - val library = orderEntry.getLibrary() ?: continue@entries + val library = orderEntry.library ?: continue@entries if (ProjectRootsUtil.isLibraryClassFile(project, virtualFile) && !isDecompiledFile) { return LibraryInfo(project, library) } @@ -111,7 +111,7 @@ private fun getModuleInfoByVirtualFile(project: Project, virtualFile: VirtualFil } } is JdkOrderEntry -> { - val sdk = orderEntry.getJdk() ?: continue@entries + val sdk = orderEntry.jdk ?: continue@entries return SdkInfo(project, sdk) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/globalContextUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/globalContextUtils.kt index b37e706837b..8b485da4671 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/globalContextUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/globalContextUtils.kt @@ -30,7 +30,7 @@ fun GlobalContextImpl.withCompositeExceptionTrackerUnderSameLock(): GlobalContex private class CompositeExceptionTracker(val delegate: ExceptionTracker) : ExceptionTracker() { override fun getModificationCount(): Long { - return super.getModificationCount() + delegate.getModificationCount() + return super.getModificationCount() + delegate.modificationCount } } @@ -48,7 +48,7 @@ private class ExceptionTrackerWithProcessCanceledReport() : ExceptionTracker() { } } -public fun GlobalContext(logProcessCanceled: Boolean): GlobalContextImpl { +fun GlobalContext(logProcessCanceled: Boolean): GlobalContextImpl { val tracker = if (logProcessCanceled) ExceptionTrackerWithProcessCanceledReport() else ExceptionTracker() return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling(tracker), tracker) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/moduleDependents.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/moduleDependents.kt index 9a71fab9743..0b45238e2bc 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/moduleDependents.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/moduleDependents.kt @@ -30,7 +30,7 @@ import com.intellij.openapi.roots.ProjectRootModificationTracker import java.util.HashSet //NOTE: this is an approximation that may contain more module infos then the exact solution -public fun ModuleSourceInfo.getDependentModules(): Set { +fun ModuleSourceInfo.getDependentModules(): Set { val dependents = getDependents(module) if (isTests()) { return dependents.mapTo(HashSet()) { it.testSourceInfo() } @@ -47,12 +47,12 @@ private fun getDependents(module: Module): Set { val processedExporting = THashSet() - val index = getModuleIndex(module.getProject()) + val index = getModuleIndex(module.project) val walkingQueue = Queue(10) walkingQueue.addLast(module) - while (!walkingQueue.isEmpty()) { + while (!walkingQueue.isEmpty) { val current = walkingQueue.pullFirst() processedExporting.add(current!!) result.addAll(index.plainUsages[current]) @@ -74,12 +74,12 @@ private class ModuleIndex { private fun getModuleIndex(project: Project): ModuleIndex { return CachedValuesManager.getManager(project).getCachedValue(project) { val index = ModuleIndex() - for (module in ModuleManager.getInstance(project).getModules()) { - for (orderEntry in ModuleRootManager.getInstance(module).getOrderEntries()) { + for (module in ModuleManager.getInstance(project).modules) { + for (orderEntry in ModuleRootManager.getInstance(module).orderEntries) { if (orderEntry is ModuleOrderEntry) { - val referenced = orderEntry.getModule() + val referenced = orderEntry.module if (referenced != null) { - val map = if (orderEntry.isExported()) index.exportingUsages else index.plainUsages + val map = if (orderEntry.isExported) index.exportingUsages else index.plainUsages map.putValue(referenced, module) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt index 6d947f7baad..3b26fcbc20b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt @@ -32,19 +32,19 @@ import org.jetbrains.kotlin.resolve.ImportPath import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public fun KtElement.getResolutionFacade(): ResolutionFacade { - return KotlinCacheService.getInstance(getProject()).getResolutionFacade(listOf(this)) +fun KtElement.getResolutionFacade(): ResolutionFacade { + return KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this)) } -public fun KtDeclaration.resolveToDescriptor(): DeclarationDescriptor { +fun KtDeclaration.resolveToDescriptor(): DeclarationDescriptor { return getResolutionFacade().resolveToDescriptor(this) } -public fun KtDeclaration.resolveToDescriptorIfAny(): DeclarationDescriptor? { +fun KtDeclaration.resolveToDescriptorIfAny(): DeclarationDescriptor? { return analyze(BodyResolveMode.PARTIAL).get(BindingContext.DECLARATION_TO_DESCRIPTOR, this) } -public fun KtFile.resolveImportReference(fqName: FqName): Collection { +fun KtFile.resolveImportReference(fqName: FqName): Collection { val facade = getResolutionFacade() return facade.resolveImportReference(facade.moduleDescriptor, fqName) } @@ -54,30 +54,29 @@ public fun KtFile.resolveImportReference(fqName: FqName): Collection { @@ -90,7 +89,7 @@ public fun ResolutionFacade.resolveImportReference( //NOTE: idea default API returns module search scope for file under module but not in source or production source (for example, test data ) // this scope can't be used to search for kotlin declarations in index in order to resolve in that case // see com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl.getInherentResolveScope -public fun getResolveScope(file: KtFile): GlobalSearchScope { +fun getResolveScope(file: KtFile): GlobalSearchScope { if (file is KtCodeFragment) { file.forcedResolveScope?.let { return KotlinSourceFilterScope.sourceAndClassFiles(it, file.project) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/DescriptorToSourceUtilsIde.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/DescriptorToSourceUtilsIde.kt index e11a608a9f4..d770206641f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/DescriptorToSourceUtilsIde.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/DescriptorToSourceUtilsIde.kt @@ -23,19 +23,19 @@ import org.jetbrains.kotlin.idea.decompiler.navigation.findDecompiledDeclaration import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.utils.addToStdlib.sequenceOfLazyValues -public object DescriptorToSourceUtilsIde { +object DescriptorToSourceUtilsIde { // Returns PSI element for descriptor. If there are many relevant elements (e.g. it is fake override // with multiple declarations), finds any of them. It can find declarations in builtins or decompiled code. - public fun getAnyDeclaration(project: Project, descriptor: DeclarationDescriptor): PsiElement? { + fun getAnyDeclaration(project: Project, descriptor: DeclarationDescriptor): PsiElement? { return getDeclarationsStream(project, descriptor).firstOrNull() } // Returns all PSI elements for descriptor. It can find declarations in builtins or decompiled code. - public fun getAllDeclarations(project: Project, targetDescriptor: DeclarationDescriptor): Collection { + fun getAllDeclarations(project: Project, targetDescriptor: DeclarationDescriptor): Collection { val result = getDeclarationsStream(project, targetDescriptor).toHashSet() // filter out elements which are navigate to some other element of the result // this is needed to avoid duplicated results for references to declaration in same library source file - return result.filter { element -> result.none { element != it && it.getNavigationElement() == element } } + return result.filter { element -> result.none { element != it && it.navigationElement == element } } } private fun getDeclarationsStream(project: Project, targetDescriptor: DeclarationDescriptor): Sequence { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/KotlinFileReferencesResolver.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/KotlinFileReferencesResolver.kt index 5ab0533d5e0..ece2b73a042 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/KotlinFileReferencesResolver.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/KotlinFileReferencesResolver.kt @@ -27,7 +27,7 @@ object KotlinFileReferencesResolver { resolveQualifiers: Boolean = true, resolveShortNames: Boolean = true ): Map { - return (element.getContainingFile() as? KtFile)?.let { file -> + return (element.containingFile as? KtFile)?.let { file -> resolve(file, listOf(element), resolveQualifiers, resolveShortNames) } ?: Collections.emptyMap() } @@ -52,15 +52,15 @@ object KotlinFileReferencesResolver { private val resolutionFacade = file.getResolutionFacade() private val resolveMap = LinkedHashMap() - public val result: Map = resolveMap + val result: Map = resolveMap override fun visitUserType(userType: KtUserType) { if (resolveQualifiers) { userType.acceptChildren(this) } - if (resolveShortNames || userType.getQualifier() != null) { - val referenceExpression = userType.getReferenceExpression() + if (resolveShortNames || userType.qualifier != null) { + val referenceExpression = userType.referenceExpression if (referenceExpression != null) { resolveMap[referenceExpression] = resolutionFacade.analyze(referenceExpression) } @@ -68,16 +68,16 @@ object KotlinFileReferencesResolver { } override fun visitQualifiedExpression(expression: KtQualifiedExpression) { - val receiverExpression = expression.getReceiverExpression() + val receiverExpression = expression.receiverExpression if (resolveQualifiers || resolutionFacade.analyze(expression)[BindingContext.QUALIFIER, receiverExpression] == null) { receiverExpression.accept(this) } - val referenceExpression = expression.getSelectorExpression()?.referenceExpression() + val referenceExpression = expression.selectorExpression?.referenceExpression() if (referenceExpression != null) { resolveMap[referenceExpression] = resolutionFacade.analyze(referenceExpression) } - expression.getSelectorExpression()?.accept(this) + expression.selectorExpression?.accept(this) } override fun visitSimpleNameExpression(expression: KtSimpleNameExpression) { @@ -89,4 +89,4 @@ object KotlinFileReferencesResolver { } fun KtExpression.referenceExpression(): KtReferenceExpression? = - (if (this is KtCallExpression) getCalleeExpression() else this) as? KtReferenceExpression + (if (this is KtCallExpression) calleeExpression else this) as? KtReferenceExpression diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/shorten/shortenWaitingSet.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/shorten/shortenWaitingSet.kt index 0fc1d14565d..1b5afb9a12b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/shorten/shortenWaitingSet.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/codeInsight/shorten/shortenWaitingSet.kt @@ -38,10 +38,10 @@ private var Project.elementsToShorten: MutableSet? * When one refactoring invokes another this value must be set to false so that shortening wait-set is not cleared * and previously collected references are processed correctly. Afterwards it must be reset to original value */ -public var Project.ensureElementsToShortenIsEmptyBeforeRefactoring: Boolean +var Project.ensureElementsToShortenIsEmptyBeforeRefactoring: Boolean by NotNullableUserDataProperty(Key.create("ENSURE_ELEMENTS_TO_SHORTEN_IS_EMPTY"), true) -public fun Project.runWithElementsToShortenIsEmptyIgnored(action: () -> Unit) { +fun Project.runWithElementsToShortenIsEmptyIgnored(action: () -> Unit) { val ensureElementsToShortenIsEmpty = ensureElementsToShortenIsEmptyBeforeRefactoring try { @@ -62,14 +62,14 @@ private fun Project.getOrCreateElementsToShorten(): MutableSet project.elementsToShorten = null val elementToOptions = requests.mapNotNull { req -> req.pointer.element?.let { it to req.options } }.toMap() @@ -79,9 +79,9 @@ public fun performDelayedShortening(project: Project) { } } -private val LOG = Logger.getInstance(Project::class.java.getCanonicalName()) +private val LOG = Logger.getInstance(Project::class.java.canonicalName) -public fun prepareElementsToShorten(project: Project) { +fun prepareElementsToShorten(project: Project) { val elementsToShorten = project.elementsToShorten if (project.ensureElementsToShortenIsEmptyBeforeRefactoring && elementsToShorten != null && !elementsToShorten.isEmpty()) { LOG.warn("Waiting set for reference shortening is not empty") diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/configuration/ModuleTypeCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/configuration/ModuleTypeCache.kt index 2f91b308dff..b2f6d532eb5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/configuration/ModuleTypeCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/configuration/ModuleTypeCache.kt @@ -53,7 +53,7 @@ class ModuleTypeCacheManager private constructor(project: Project) { private class VfsModificationTracker(project: Project): SimpleModificationTracker() { init { - val connection = project.getMessageBus().connect(); + val connection = project.messageBus.connect(); connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter( object : VirtualFileAdapter() { override fun propertyChanged(event: VirtualFilePropertyEvent) { @@ -95,11 +95,11 @@ private fun computeType(module: Module) = private val DEFAULT_SCRIPT_NAME = "build.gradle" private fun isGradleModule(module: Module): Boolean { - val moduleFile = module.getModuleFile() + val moduleFile = module.moduleFile if (moduleFile == null){ return false } - val buildFile = moduleFile.getParent()?.findChild(DEFAULT_SCRIPT_NAME) + val buildFile = moduleFile.parent?.findChild(DEFAULT_SCRIPT_NAME) return buildFile != null && buildFile.exists() } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KotlinDecompiledFileViewProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KotlinDecompiledFileViewProvider.kt index 11fa18472a4..790ee1e08a4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KotlinDecompiledFileViewProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KotlinDecompiledFileViewProvider.kt @@ -35,8 +35,8 @@ class KotlinDecompiledFileViewProvider( private val factory: (KotlinDecompiledFileViewProvider) -> KtDecompiledFile? ) : SingleRootFileViewProvider(manager, file, physical, KotlinLanguage.INSTANCE) { val content : LockedClearableLazyValue = LockedClearableLazyValue(Any()) { - val psiFile = createFile(manager.getProject(), file, KotlinFileType.INSTANCE) - val text = psiFile?.getText() ?: "" + val psiFile = createFile(manager.project, file, KotlinFileType.INSTANCE) + val text = psiFile?.text ?: "" DebugUtil.startPsiModification("Invalidating throw-away copy of file that was used for getting text") try { @@ -53,7 +53,7 @@ class KotlinDecompiledFileViewProvider( return factory(this) } - override fun createCopy(copy: VirtualFile) = KotlinDecompiledFileViewProvider(getManager(), copy, false, factory) + override fun createCopy(copy: VirtualFile) = KotlinDecompiledFileViewProvider(manager, copy, false, factory) override fun getContents() = content.get() } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KtDecompiledFile.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KtDecompiledFile.kt index 7d91877037c..8a6337249dd 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KtDecompiledFile.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/KtDecompiledFile.kt @@ -46,17 +46,17 @@ open class KtDecompiledFile( buildDecompiledText(provider.virtualFile) } - public fun getDeclarationForDescriptor(descriptor: DeclarationDescriptor): KtDeclaration? { - val original = descriptor.getOriginal() + fun getDeclarationForDescriptor(descriptor: DeclarationDescriptor): KtDeclaration? { + val original = descriptor.original if (original is ValueParameterDescriptor) { - val callable = original.getContainingDeclaration() + val callable = original.containingDeclaration val callableDeclaration = getDeclarationForDescriptor(callable) as? KtCallableDeclaration ?: return null - return callableDeclaration.getValueParameters()[original.index] + return callableDeclaration.valueParameters[original.index] } - if (original is ConstructorDescriptor && original.isPrimary()) { - val classOrObject = getDeclarationForDescriptor(original.getContainingDeclaration()) as? KtClassOrObject + if (original is ConstructorDescriptor && original.isPrimary) { + val classOrObject = getDeclarationForDescriptor(original.containingDeclaration) as? KtClassOrObject return classOrObject?.getPrimaryConstructor() ?: classOrObject } @@ -74,7 +74,7 @@ open class KtDecompiledFile( private fun DeclarationDescriptor.findElementForDescriptor(): KtDeclaration? { return decompiledText.get().renderedDescriptorsToRange[descriptorToKey(this)]?.let { range -> - PsiTreeUtil.findElementOfClassAtRange(this@KtDecompiledFile, range.getStartOffset(), range.getEndOffset(), KtDeclaration::class.java) + PsiTreeUtil.findElementOfClassAtRange(this@KtDecompiledFile, range.startOffset, range.endOffset, KtDeclaration::class.java) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDecompiler.kt index d225f98a005..9ea51352e5e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDecompiler.kt @@ -65,7 +65,7 @@ class KotlinBuiltInDecompiler : ClassFileDecompilers.Full() { private val decompilerRendererForBuiltIns = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() } -public fun buildDecompiledTextForBuiltIns( +fun buildDecompiledTextForBuiltIns( builtInFile: VirtualFile ): DecompiledText { val directory = builtInFile.parent!! diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDeserializerForDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDeserializerForDecompiler.kt index 31dd5978473..bdb501fbec9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDeserializerForDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInDeserializerForDecompiler.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.TargetPlatform import org.jetbrains.kotlin.serialization.deserialization.* -public class KotlinBuiltInDeserializerForDecompiler( +class KotlinBuiltInDeserializerForDecompiler( packageDirectory: VirtualFile, packageFqName: FqName, private val nameResolver: NameResolver diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt index fde646cbe0c..d86aaabd664 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.serialization.deserialization.NameResolverImpl import org.jetbrains.kotlin.serialization.deserialization.TypeTable import java.io.ByteArrayInputStream -public class KotlinBuiltInStubBuilder : ClsStubBuilder() { +class KotlinBuiltInStubBuilder : ClsStubBuilder() { override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1 override fun buildFileStub(content: FileContent): PsiFileStub<*>? { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/fileTypes.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/fileTypes.kt index 809b9331131..63fd0cdedb1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/fileTypes.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/fileTypes.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.builtins.BuiltInsSerializedResourcePaths import org.jetbrains.kotlin.idea.KotlinIcons -public object KotlinBuiltInClassFileType : FileType { +object KotlinBuiltInClassFileType : FileType { override fun getName() = "kotlin_class" override fun getDescription() = "Kotlin builtin class" @@ -37,7 +37,7 @@ public object KotlinBuiltInClassFileType : FileType { override fun getCharset(file: VirtualFile, content: ByteArray) = null } -public object KotlinBuiltInPackageFileType : FileType { +object KotlinBuiltInPackageFileType : FileType { override fun getName() = "kotlin_package" override fun getDescription() = "Kotlin builtin package" diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt index bf23bd95131..998f1d94d7c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt @@ -29,8 +29,8 @@ import org.jetbrains.kotlin.name.Name /** * Checks if this file is a compiled Kotlin class file (not necessarily ABI-compatible with the current plugin) */ -public fun isKotlinJvmCompiledFile(file: VirtualFile): Boolean { - if (file.getExtension() != JavaClassFileType.INSTANCE!!.getDefaultExtension()) { +fun isKotlinJvmCompiledFile(file: VirtualFile): Boolean { + if (file.extension != JavaClassFileType.INSTANCE!!.defaultExtension) { return false } @@ -45,10 +45,10 @@ public fun isKotlinJvmCompiledFile(file: VirtualFile): Boolean { /** * Checks if this file is a compiled Kotlin class file ABI-compatible with the current plugin */ -public fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean { +fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean { if (!isKotlinJvmCompiledFile(file)) return false - val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader() + val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.classHeader return header != null && header.isCompatibleAbiVersion } @@ -56,7 +56,7 @@ public fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean { * Checks if this file is a compiled "internal" Kotlin class, i.e. a Kotlin class (not necessarily ABI-compatible with the current plugin) * which should NOT be decompiled (and, as a result, shown under the library in the Project view, be searchable via Find class, etc.) */ -public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean { +fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean { if (!isKotlinJvmCompiledFile(file)) { return false } @@ -71,14 +71,14 @@ public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean { header.isLocalClass || header.syntheticClassKind == "PACKAGE_PART" } -public object HasCompiledKotlinInJar : JarUserDataManager.JarBooleanPropertyCounter(HasCompiledKotlinInJar::class.simpleName!!) { +object HasCompiledKotlinInJar : JarUserDataManager.JarBooleanPropertyCounter(HasCompiledKotlinInJar::class.simpleName!!) { override fun hasProperty(file: VirtualFile) = isKotlinJvmCompiledFile(file) fun isInNoKotlinJar(file: VirtualFile): Boolean = JarUserDataManager.hasFileWithProperty(HasCompiledKotlinInJar, file) == false } -public fun findMultifileClassParts(file: VirtualFile, multifileClass: KotlinJvmBinaryClass): List { +fun findMultifileClassParts(file: VirtualFile, multifileClass: KotlinJvmBinaryClass): List { val packageFqName = multifileClass.classId.packageFqName val partsFinder = DirectoryBasedClassFinder(file.parent!!, packageFqName) val partNames = multifileClass.classHeader.filePartClassNames ?: return emptyList() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/DeserializerForClassfileDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/DeserializerForClassfileDecompiler.kt index f6881d51beb..1e7cbfa7233 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/DeserializerForClassfileDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/DeserializerForClassfileDecompiler.kt @@ -36,14 +36,14 @@ import org.jetbrains.kotlin.serialization.deserialization.DeserializationCompone import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil -public fun DeserializerForClassfileDecompiler(classFile: VirtualFile): DeserializerForClassfileDecompiler { +fun DeserializerForClassfileDecompiler(classFile: VirtualFile): DeserializerForClassfileDecompiler { val kotlinClass = KotlinBinaryClassCache.getKotlinBinaryClass(classFile) assert(kotlinClass != null) { "Decompiled data factory shouldn't be called on an unsupported file: " + classFile } val packageFqName = kotlinClass!!.classId.packageFqName return DeserializerForClassfileDecompiler(classFile.parent!!, packageFqName) } -public class DeserializerForClassfileDecompiler( +class DeserializerForClassfileDecompiler( packageDirectory: VirtualFile, directoryPackageFqName: FqName ) : DeserializerForDecompilerBase(packageDirectory, directoryPackageFqName) { @@ -74,7 +74,7 @@ public class DeserializerForClassfileDecompiler( val annotationData = header?.annotationData val strings = header?.strings if (annotationData == null || strings == null) { - LOG.error("Could not read annotation data for $facadeFqName from ${binaryClassForPackageClass?.getClassId()}") + LOG.error("Could not read annotation data for $facadeFqName from ${binaryClassForPackageClass?.classId}") return emptyList() } val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData, strings) @@ -97,10 +97,10 @@ class DirectoryBasedClassFinder( override fun findKotlinClass(javaClass: JavaClass) = findKotlinClass(javaClass.classId) override fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass? { - if (classId.getPackageFqName() != directoryPackageFqName) { + if (classId.packageFqName != directoryPackageFqName) { return null } - val targetName = classId.getRelativeClassName().pathSegments().joinToString("$", postfix = ".class") + val targetName = classId.relativeClassName.pathSegments().joinToString("$", postfix = ".class") val virtualFile = packageDirectory.findChild(targetName) if (virtualFile != null && isKotlinWithCompatibleAbiVersion(virtualFile)) { return KotlinBinaryClassCache.getKotlinBinaryClass(virtualFile) @@ -134,6 +134,6 @@ class DirectoryBasedDataFinder( private val JavaClass.classId: ClassId get() { - val outer = getOuterClass() - return if (outer == null) ClassId.topLevel(getFqName()!!) else outer.classId.createNestedClassId(getName()) + val outer = outerClass + return if (outer == null) ClassId.topLevel(fqName!!) else outer.classId.createNestedClassId(name) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClassFileDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClassFileDecompiler.kt index 22035a81342..db4fa6c146f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClassFileDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClassFileDecompiler.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible import java.util.* -public class KotlinClassFileDecompiler : ClassFileDecompilers.Full() { +class KotlinClassFileDecompiler : ClassFileDecompilers.Full() { private val stubBuilder = KotlinClsStubBuilder() override fun accepts(file: VirtualFile) = isKotlinJvmCompiledFile(file) @@ -68,22 +68,22 @@ private val decompilerRendererForClassFiles = DescriptorRenderer.withOptions { private val FILE_ABI_VERSION_MARKER: String = "FILE_ABI" private val CURRENT_ABI_VERSION_MARKER: String = "CURRENT_ABI" -public val INCOMPATIBLE_ABI_VERSION_GENERAL_COMMENT: String = "// This class file was compiled with different version of Kotlin compiler and can't be decompiled." -public val INCOMPATIBLE_ABI_VERSION_COMMENT: String = +val INCOMPATIBLE_ABI_VERSION_GENERAL_COMMENT: String = "// This class file was compiled with different version of Kotlin compiler and can't be decompiled." +val INCOMPATIBLE_ABI_VERSION_COMMENT: String = "$INCOMPATIBLE_ABI_VERSION_GENERAL_COMMENT\n" + "//\n" + "// Current compiler ABI version is $CURRENT_ABI_VERSION_MARKER\n" + "// File ABI version is $FILE_ABI_VERSION_MARKER" -public fun buildDecompiledTextForClassFile( +fun buildDecompiledTextForClassFile( classFile: VirtualFile, resolver: ResolverForDecompiler = DeserializerForClassfileDecompiler(classFile) ): DecompiledText { val kotlinClass = KotlinBinaryClassCache.getKotlinBinaryClass(classFile) assert(kotlinClass != null) { "Decompiled data factory shouldn't be called on an unsupported file: " + classFile } - val classId = kotlinClass!!.getClassId() - val classHeader = kotlinClass.getClassHeader() - val packageFqName = classId.getPackageFqName() + val classId = kotlinClass!!.classId + val classHeader = kotlinClass.classHeader + val packageFqName = classId.packageFqName return when { !classHeader.isCompatibleAbiVersion -> { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt index dc7a3a8346d..1f4c3073636 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt @@ -44,11 +44,11 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil import org.jetbrains.kotlin.storage.LockBasedStorageManager -public open class KotlinClsStubBuilder : ClsStubBuilder() { +open class KotlinClsStubBuilder : ClsStubBuilder() { override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1 override fun buildFileStub(content: FileContent): PsiFileStub<*>? { - val file = content.getFile() + val file = content.file if (isKotlinInternalCompiledFile(file)) { return null @@ -59,9 +59,9 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() { fun doBuildFileStub(file: VirtualFile): PsiFileStub? { val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file)!! - val header = kotlinBinaryClass.getClassHeader() - val classId = kotlinBinaryClass.getClassId() - val packageFqName = classId.getPackageFqName() + val header = kotlinBinaryClass.classHeader + val classId = kotlinBinaryClass.classId + val packageFqName = classId.packageFqName if (!header.isCompatibleAbiVersion) { return createIncompatibleAbiVersionFileStub() } @@ -74,12 +74,12 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() { val annotationData = header.annotationData if (annotationData == null) { - LOG.error("Corrupted kotlin header for file ${file.getName()}") + LOG.error("Corrupted kotlin header for file ${file.name}") return null } val strings = header.strings if (strings == null) { - LOG.error("String table not found in file ${file.getName()}") + LOG.error("String table not found in file ${file.name}") return null } return when { @@ -94,12 +94,12 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() { val context = components.createContext(nameResolver, packageFqName, TypeTable(packageProto.typeTable)) createFileFacadeStub(packageProto, classId.asSingleFqName(), context) } - else -> throw IllegalStateException("Should have processed " + file.getPath() + " with header $header") + else -> throw IllegalStateException("Should have processed " + file.path + " with header $header") } } private fun createStubBuilderComponents(file: VirtualFile, packageFqName: FqName): ClsStubBuilderComponents { - val classFinder = DirectoryBasedClassFinder(file.getParent()!!, packageFqName) + val classFinder = DirectoryBasedClassFinder(file.parent!!, packageFqName) val classDataFinder = DirectoryBasedDataFinder(classFinder, LOG) val annotationLoader = AnnotationLoaderForClassFileStubBuilder(classFinder, LoggingErrorReporter(LOG)) return ClsStubBuilderComponents(classDataFinder, annotationLoader, file) @@ -127,7 +127,7 @@ class AnnotationLoaderForClassFileStubBuilder( } override fun loadTypeAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): ClassId = - nameResolver.getClassId(proto.getId()) + nameResolver.getClassId(proto.id) override fun loadConstant(desc: String, initializer: Any) = null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/AnnotationLoaderForStubBuilderImpl.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/AnnotationLoaderForStubBuilderImpl.kt index 5945296070a..bdfc015941b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/AnnotationLoaderForStubBuilderImpl.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/AnnotationLoaderForStubBuilderImpl.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer import org.jetbrains.kotlin.types.KotlinType -public class AnnotationLoaderForStubBuilderImpl( +class AnnotationLoaderForStubBuilderImpl( private val protocol: SerializerExtensionProtocol ) : AnnotationAndConstantLoader { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/JsMetaFileUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/JsMetaFileUtils.kt index b744eca58de..5d10552f3a5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/JsMetaFileUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/JsMetaFileUtils.kt @@ -23,21 +23,21 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.js.isDefaultPackageMetafile import org.jetbrains.kotlin.serialization.js.isPackageClassFqName -public object JsMetaFileUtils { - public fun isKotlinJsMetaFile(file: VirtualFile): Boolean = file.getFileType() == KotlinJavaScriptMetaFileType +object JsMetaFileUtils { + fun isKotlinJsMetaFile(file: VirtualFile): Boolean = file.fileType == KotlinJavaScriptMetaFileType - public fun isKotlinJavaScriptInternalCompiledFile(file: VirtualFile): Boolean = - isKotlinJsMetaFile(file) && file.getNameWithoutExtension().contains('.') + fun isKotlinJavaScriptInternalCompiledFile(file: VirtualFile): Boolean = + isKotlinJsMetaFile(file) && file.nameWithoutExtension.contains('.') - public fun getPackageFqName(file: VirtualFile): FqName = getPackageFqName(getRelativeToRootPath(file)) + fun getPackageFqName(file: VirtualFile): FqName = getPackageFqName(getRelativeToRootPath(file)) - public fun getClassFqName(file: VirtualFile): FqName = getClassFqName(getRelativeToRootPath(file)) + fun getClassFqName(file: VirtualFile): FqName = getClassFqName(getRelativeToRootPath(file)) - public fun getClassId(file: VirtualFile): ClassId = getClassId(getRelativeToRootPath(file)) + fun getClassId(file: VirtualFile): ClassId = getClassId(getRelativeToRootPath(file)) - public fun isPackageHeader(file: VirtualFile): Boolean = isPackageHeader(getRelativeToRootPath(file)) + fun isPackageHeader(file: VirtualFile): Boolean = isPackageHeader(getRelativeToRootPath(file)) - public fun getModuleDirectory(file: VirtualFile): VirtualFile = + fun getModuleDirectory(file: VirtualFile): VirtualFile = getRoot(file).findChild(getModuleName(getRelativeToRootPath(file)))!! private fun getRelativeToRootPath(file: VirtualFile): String = VfsUtilCore.getRelativePath(file, getRoot(file))!! @@ -70,6 +70,6 @@ public object JsMetaFileUtils { return classFqName.isPackageClassFqName() } - private fun getRoot(file: VirtualFile): VirtualFile = if (file.getParent() == null) file else getRoot(file.getParent()) + private fun getRoot(file: VirtualFile): VirtualFile = if (file.parent == null) file else getRoot(file.parent) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptDeserializerForDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptDeserializerForDecompiler.kt index 3cf88014fda..8f399be50df 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptDeserializerForDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptDeserializerForDecompiler.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializedResourcePaths import java.io.ByteArrayInputStream -public class KotlinJavaScriptDeserializerForDecompiler( +class KotlinJavaScriptDeserializerForDecompiler( classFile: VirtualFile ) : DeserializerForDecompilerBase(classFile.parent!!, JsMetaFileUtils.getPackageFqName(classFile)) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileDecompiler.kt index cecaff07398..a9450eec26e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileDecompiler.kt @@ -58,7 +58,7 @@ class KotlinJavaScriptMetaFileDecompiler : ClassFileDecompilers.Full() { private val decompilerRendererForJS = DescriptorRenderer.withOptions { defaultDecompilerRendererOptions() } -public fun buildDecompiledTextFromJsMetadata( +fun buildDecompiledTextFromJsMetadata( classFile: VirtualFile, resolver: ResolverForDecompiler = KotlinJavaScriptDeserializerForDecompiler(classFile) ): DecompiledText { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileType.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileType.kt index a24e0206bb5..d6d93384529 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileType.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptMetaFileType.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil -public object KotlinJavaScriptMetaFileType : FileType { +object KotlinJavaScriptMetaFileType : FileType { override fun getName() = "KJSM" diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt index 173803ddf36..b6045f424fa 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializedResourcePaths import java.io.ByteArrayInputStream -public class KotlinJavaScriptStubBuilder : ClsStubBuilder() { +class KotlinJavaScriptStubBuilder : ClsStubBuilder() { override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1 override fun buildFileStub(content: FileContent): PsiFileStub<*>? { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/KotlinDeclarationNavigationPolicyImpl.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/KotlinDeclarationNavigationPolicyImpl.kt index ab817c3d535..0f2cdfa8fa9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/KotlinDeclarationNavigationPolicyImpl.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/KotlinDeclarationNavigationPolicyImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtDeclaration import com.intellij.openapi.project.DumbService -public class KotlinDeclarationNavigationPolicyImpl : KotlinDeclarationNavigationPolicy { +class KotlinDeclarationNavigationPolicyImpl : KotlinDeclarationNavigationPolicy { override fun getOriginalElement(declaration: KtDeclaration) = SourceNavigationHelper.getOriginalElement(declaration) override fun getNavigationElement(declaration: KtDeclaration) = diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt index cbf40d1c1eb..3786352dceb 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt @@ -78,7 +78,7 @@ private class ClassClsStubBuilder( private val classOrObjectStub = createClassOrObjectStubAndModifierListStub() fun build() { - val typeConstraintListData = typeStubBuilder.createTypeParameterListStub(classOrObjectStub, classProto.getTypeParameterList()) + val typeConstraintListData = typeStubBuilder.createTypeParameterListStub(classOrObjectStub, classProto.typeParameterList) createConstructorStub() createDelegationSpecifierList() typeStubBuilder.createTypeConstraintListStub(classOrObjectStub, typeConstraintListData) @@ -105,7 +105,7 @@ private class ClassClsStubBuilder( ProtoBuf.Class.Kind.ANNOTATION_CLASS -> listOf(KtTokens.ANNOTATION_KEYWORD) else -> listOf() } - return createModifierListStubForDeclaration(parent, classProto.getFlags(), relevantFlags, additionalModifiers) + return createModifierListStubForDeclaration(parent, classProto.flags, relevantFlags, additionalModifiers) } private fun doCreateClassOrObjectStub(): StubElement { @@ -115,12 +115,12 @@ private class ClassClsStubBuilder( val superTypeRefs = supertypeIds.filterNot { //TODO: filtering function types should go away KotlinBuiltIns.isNumberedFunctionClassFqName(it.asSingleFqName().toUnsafe()) - }.map { it.getShortClassName().ref() }.toTypedArray() + }.map { it.shortClassName.ref() }.toTypedArray() return when (classKind) { ProtoBuf.Class.Kind.OBJECT, ProtoBuf.Class.Kind.COMPANION_OBJECT -> { KotlinObjectStubImpl( parentStub, shortName, fqName, superTypeRefs, - isTopLevel = !classId.isNestedClass(), + isTopLevel = !classId.isNestedClass, isDefault = isCompanionObject, isLocal = false, isObjectLiteral = false @@ -136,7 +136,7 @@ private class ClassClsStubBuilder( isTrait = classKind == ProtoBuf.Class.Kind.INTERFACE, isEnumEntry = classKind == ProtoBuf.Class.Kind.ENUM_ENTRY, isLocal = false, - isTopLevel = !classId.isNestedClass() + isTopLevel = !classId.isNestedClass ) } } @@ -222,7 +222,7 @@ private class ClassClsStubBuilder( } private fun createInnerAndNestedClasses(classBody: KotlinPlaceHolderStubImpl) { - classProto.getNestedClassNameList().forEach { id -> + classProto.nestedClassNameList.forEach { id -> val nestedClassName = c.nameResolver.getName(id) if (nestedClassName != companionObjectName) { val nestedClassId = classId.createNestedClassId(nestedClassName) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderContext.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderContext.kt index 9ecb5858474..f4b8b8cc5ea 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderContext.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderContext.kt @@ -59,7 +59,7 @@ class TypeParametersImpl( typeParameterProtos: Collection, private val parent: TypeParameters ) : TypeParameters { - private val typeParametersById = typeParameterProtos.map { Pair(it.getId(), nameResolver.getName(it.getName())) }.toMap() + private val typeParametersById = typeParameterProtos.map { Pair(it.id, nameResolver.getName(it.name)) }.toMap() override fun get(id: Int): Name = typeParametersById[id] ?: parent[id] } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt index 6c9794aac5e..9b9ed08c7b7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt @@ -46,12 +46,12 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { val typeReference = KotlinPlaceHolderStubImpl(parent, KtStubElementTypes.TYPE_REFERENCE) val annotations = c.components.annotationLoader.loadTypeAnnotations(type, c.nameResolver).filterNot { - val isTopLevelClass = !it.isNestedClass() + val isTopLevelClass = !it.isNestedClass isTopLevelClass && it.asSingleFqName() in JvmAnnotationNames.ANNOTATIONS_COPIED_TO_TYPES } val effectiveParent = - if (type.getNullable()) KotlinPlaceHolderStubImpl(typeReference, KtStubElementTypes.NULLABLE_TYPE) + if (type.nullable) KotlinPlaceHolderStubImpl(typeReference, KtStubElementTypes.NULLABLE_TYPE) else typeReference fun createTypeParameterStub(name: Name) { @@ -68,7 +68,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { private fun createClassReferenceTypeStub(parent: KotlinStubBaseImpl<*>, type: Type, annotations: List) { if (type.hasFlexibleTypeCapabilitiesId()) { - val id = c.nameResolver.getString(type.getFlexibleTypeCapabilitiesId()) + val id = c.nameResolver.getString(type.flexibleTypeCapabilitiesId) if (id == DynamicTypeCapabilities.id) { KotlinPlaceHolderStubImpl(parent, KtStubElementTypes.DYNAMIC_TYPE) @@ -78,7 +78,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { val classId = c.nameResolver.getClassId(type.className) val shouldBuildAsFunctionType = KotlinBuiltIns.isNumberedFunctionClassFqName(classId.asSingleFqName().toUnsafe()) - && type.getArgumentList().none { it.getProjection() == Projection.STAR } + && type.argumentList.none { it.projection == Projection.STAR } if (shouldBuildAsFunctionType) { val extension = annotations.any { annotation -> val fqName = annotation.asSingleFqName() @@ -233,11 +233,11 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { typeParameterProto: ProtoBuf.TypeParameter ) { val modifiers = ArrayList() - when (typeParameterProto.getVariance()) { + when (typeParameterProto.variance) { Variance.IN -> modifiers.add(KtTokens.IN_KEYWORD) Variance.OUT -> modifiers.add(KtTokens.OUT_KEYWORD) } - if (typeParameterProto.getReified()) { + if (typeParameterProto.reified) { modifiers.add(KtTokens.REIFIED_KEYWORD) } createModifierListStub(typeParameterStub, modifiers) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt index b5206eed937..9a83d75e2ef 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt @@ -137,7 +137,7 @@ fun createStubForTypeName( onUserTypeLevel: (KotlinUserTypeStub, Int) -> Unit = { x, y -> } ): KotlinUserTypeStub { val fqName = - if (typeClassId.isLocal()) KotlinBuiltIns.FQ_NAMES.any + if (typeClassId.isLocal) KotlinBuiltIns.FQ_NAMES.any else typeClassId.asSingleFqName().toUnsafe() val segments = fqName.pathSegments().asReversed() assert(segments.isNotEmpty()) @@ -288,7 +288,7 @@ fun createTargetedAnnotationStubs( val (annotationClassId, target) = annotation val annotationEntryStubImpl = KotlinAnnotationEntryStubImpl( parent, - shortName = annotationClassId.getShortClassName().ref(), + shortName = annotationClassId.shortClassName.ref(), hasValueArguments = false ) if (target != null) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt index dd4ff1150e1..f7be0434633 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt @@ -38,11 +38,11 @@ private val descriptorRendererForKeys = DescriptorRenderer.COMPACT_WITH_MODIFIER modifiers = DescriptorRendererModifier.ALL } -public fun descriptorToKey(descriptor: DeclarationDescriptor): String { +fun descriptorToKey(descriptor: DeclarationDescriptor): String { return descriptorRendererForKeys.render(descriptor) } -public data class DecompiledText(public val text: String, public val renderedDescriptorsToRange: Map) +data class DecompiledText(val text: String, val renderedDescriptorsToRange: Map) fun DescriptorRendererOptions.defaultDecompilerRendererOptions() { withDefinedIn = false @@ -53,7 +53,7 @@ fun DescriptorRendererOptions.defaultDecompilerRendererOptions() { alwaysRenderModifiers = true } -public fun buildDecompiledText( +fun buildDecompiledText( packageFqName: FqName, descriptors: List, descriptorRenderer: DescriptorRenderer @@ -64,7 +64,7 @@ public fun buildDecompiledText( fun appendDecompiledTextAndPackageName() { builder.append("// IntelliJ API Decompiler stub source generated from a class file\n" + "// Implementation of methods is not available") builder.append("\n\n") - if (!packageFqName.isRoot()) { + if (!packageFqName.isRoot) { builder.append("package ").append(packageFqName).append("\n\n") } } @@ -75,7 +75,7 @@ public fun buildDecompiledText( fun appendDescriptor(descriptor: DeclarationDescriptor, indent: String, lastEnumEntry: Boolean? = null) { if (descriptor is MissingDependencyErrorClass) { - throw IllegalStateException("${descriptor.javaClass.getSimpleName()} cannot be rendered. FqName: ${descriptor.fullFqName}") + throw IllegalStateException("${descriptor.javaClass.simpleName} cannot be rendered. FqName: ${descriptor.fullFqName}") } val startOffset = builder.length if (isEnumEntry(descriptor)) { @@ -93,13 +93,13 @@ public fun buildDecompiledText( if (descriptor is CallableDescriptor) { //NOTE: assuming that only return types can be flexible - if (descriptor.getReturnType()!!.isFlexible()) { + if (descriptor.returnType!!.isFlexible()) { builder.append(" ").append(FLEXIBLE_TYPE_COMMENT) } } if (descriptor is FunctionDescriptor || descriptor is PropertyDescriptor) { - if ((descriptor as MemberDescriptor).getModality() != Modality.ABSTRACT) { + if ((descriptor as MemberDescriptor).modality != Modality.ABSTRACT) { if (descriptor is FunctionDescriptor) { builder.append(" { ").append(DECOMPILED_CODE_COMMENT).append(" }") } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt index bc09643b3c8..8dc808cec11 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.storage.StorageManager -public abstract class DeserializerForDecompilerBase( +abstract class DeserializerForDecompilerBase( val packageDirectory: VirtualFile, val directoryPackageFqName: FqName ) : ResolverForDecompiler { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/ResolverForDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/ResolverForDecompiler.kt index 61b967e45b8..ad9adcf53be 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/ResolverForDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/ResolverForDecompiler.kt @@ -21,8 +21,8 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.name.ClassId -public interface ResolverForDecompiler { - public fun resolveTopLevelClass(classId: ClassId): ClassDescriptor? +interface ResolverForDecompiler { + fun resolveTopLevelClass(classId: ClassId): ClassDescriptor? - public fun resolveDeclarationsInFacade(facadeFqName: FqName): List + fun resolveDeclarationsInFacade(facadeFqName: FqName): List } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt index d90c0afa83b..ff535919e06 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt @@ -74,7 +74,7 @@ private class MissingDependencyErrorClassDescriptor( init { val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE) emptyConstructor.initialize(listOf(), Visibilities.DEFAULT_VISIBILITY) - emptyConstructor.setReturnType(createErrorType("")) + emptyConstructor.returnType = createErrorType("") initialize(MemberScope.Empty, setOf(emptyConstructor), emptyConstructor) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt index f93540117bf..95ad4ef6465 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt @@ -21,20 +21,20 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiNamedElement import org.jetbrains.kotlin.psi.* -public class KotlinFindUsagesProvider : FindUsagesProvider { - public override fun canFindUsagesFor(psiElement: PsiElement): Boolean = +class KotlinFindUsagesProvider : FindUsagesProvider { + override fun canFindUsagesFor(psiElement: PsiElement): Boolean = psiElement is KtNamedDeclaration - public override fun getWordsScanner() = null + override fun getWordsScanner() = null - public override fun getHelpId(psiElement: PsiElement): String? = null + override fun getHelpId(psiElement: PsiElement): String? = null - public override fun getType(element: PsiElement): String { + override fun getType(element: PsiElement): String { return when(element) { is KtNamedFunction -> "function" is KtClass -> "class" is KtParameter -> "parameter" - is KtProperty -> if (element.isLocal()) "variable" else "property" + is KtProperty -> if (element.isLocal) "variable" else "property" is KtDestructuringDeclarationEntry -> "variable" is KtTypeParameter -> "type parameter" is KtSecondaryConstructor -> "constructor" @@ -43,10 +43,10 @@ public class KotlinFindUsagesProvider : FindUsagesProvider { } } - public override fun getDescriptiveName(element: PsiElement): String { - return if (element is PsiNamedElement) element.getName() ?: "" else "" + override fun getDescriptiveName(element: PsiElement): String { + return if (element is PsiNamedElement) element.name ?: "" else "" } - public override fun getNodeText(element: PsiElement, useFullName: Boolean): String = + override fun getNodeText(element: PsiElement, useFullName: Boolean): String = getDescriptiveName(element) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt index 2f70dc10bce..b5fe352f8f0 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt @@ -30,8 +30,8 @@ import org.jetbrains.kotlin.psi.psiUtil.isAncestor import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils -public object UsageTypeUtils { - public fun getUsageType(element: PsiElement?): UsageTypeEnum? { +object UsageTypeUtils { + fun getUsageType(element: PsiElement?): UsageTypeEnum? { when (element) { is KtForExpression -> return IMPLICIT_ITERATION is KtDestructuringDeclaration -> return READ @@ -48,7 +48,7 @@ public object UsageTypeUtils { return when { refExpr.getNonStrictParentOfType() != null -> CLASS_IMPORT - refExpr.getParentOfTypeAndBranch(){ getCallableReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ callableReference } != null -> CALLABLE_REFERENCE else -> null } @@ -60,10 +60,10 @@ public object UsageTypeUtils { val property = refExpr.getNonStrictParentOfType() if (property != null) { when { - property.getTypeReference().isAncestor(refExpr) -> - return if (property.isLocal()) CLASS_LOCAL_VAR_DECLARATION else NON_LOCAL_PROPERTY_TYPE + property.typeReference.isAncestor(refExpr) -> + return if (property.isLocal) CLASS_LOCAL_VAR_DECLARATION else NON_LOCAL_PROPERTY_TYPE - property.getReceiverTypeReference().isAncestor(refExpr) -> + property.receiverTypeReference.isAncestor(refExpr) -> return EXTENSION_RECEIVER_TYPE } } @@ -71,48 +71,48 @@ public object UsageTypeUtils { val function = refExpr.getNonStrictParentOfType() if (function != null) { when { - function.getTypeReference().isAncestor(refExpr) -> + function.typeReference.isAncestor(refExpr) -> return FUNCTION_RETURN_TYPE - function.getReceiverTypeReference().isAncestor(refExpr) -> + function.receiverTypeReference.isAncestor(refExpr) -> return EXTENSION_RECEIVER_TYPE } } return when { - refExpr.getParentOfTypeAndBranch(){ getExtendsBound() } != null - || refExpr.getParentOfTypeAndBranch(){ getBoundTypeReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ extendsBound } != null + || refExpr.getParentOfTypeAndBranch(){ boundTypeReference } != null -> TYPE_CONSTRAINT refExpr is KtSuperTypeListEntry - || refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null -> + || refExpr.getParentOfTypeAndBranch(){ typeReference } != null -> SUPER_TYPE - refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ typeReference } != null -> TYPE_DEFINITION - refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ typeReference } != null -> VALUE_PARAMETER_TYPE - refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null - || refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ typeReference } != null + || refExpr.getParentOfTypeAndBranch(){ typeReference } != null -> IS - with(refExpr.getParentOfTypeAndBranch(){ getRight() }) { - val opType = this?.getOperationReference()?.getReferencedNameElementType() + with(refExpr.getParentOfTypeAndBranch(){ right }) { + val opType = this?.operationReference?.getReferencedNameElementType() opType == KtTokens.AS_KEYWORD || opType == KtTokens.AS_SAFE } -> CLASS_CAST_TO with(refExpr.getNonStrictParentOfType()) { if (this == null) false - else if (getReceiverExpression() == refExpr) true + else if (receiverExpression == refExpr) true else - getSelectorExpression() == refExpr - && getParentOfTypeAndBranch(strict = true) { getReceiverExpression() } != null + selectorExpression == refExpr + && getParentOfTypeAndBranch(strict = true) { receiverExpression } != null } -> CLASS_OBJECT_ACCESS - refExpr.getParentOfTypeAndBranch(){ getSuperTypeQualifier() } != null -> + refExpr.getParentOfTypeAndBranch(){ superTypeQualifier } != null -> SUPER_TYPE_QUALIFIER else -> null @@ -120,21 +120,21 @@ public object UsageTypeUtils { } fun getVariableUsageType(): UsageTypeEnum? { - if (refExpr.getParentOfTypeAndBranch(){ getDelegateExpression() } != null) { + if (refExpr.getParentOfTypeAndBranch(){ delegateExpression } != null) { return DELEGATE } - if (refExpr.getParent() is KtValueArgumentName) return NAMED_ARGUMENT + if (refExpr.parent is KtValueArgumentName) return NAMED_ARGUMENT val dotQualifiedExpression = refExpr.getNonStrictParentOfType() if (dotQualifiedExpression != null) { - val parent = dotQualifiedExpression.getParent() + val parent = dotQualifiedExpression.parent when { - dotQualifiedExpression.getReceiverExpression().isAncestor(refExpr) -> + dotQualifiedExpression.receiverExpression.isAncestor(refExpr) -> return RECEIVER - parent is KtDotQualifiedExpression && parent.getReceiverExpression().isAncestor(refExpr) -> + parent is KtDotQualifiedExpression && parent.receiverExpression.isAncestor(refExpr) -> return RECEIVER } } @@ -158,21 +158,21 @@ public object UsageTypeUtils { } return when { - refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ typeReference } != null -> SUPER_TYPE descriptor is ConstructorDescriptor - && refExpr.getParentOfTypeAndBranch(){ getTypeReference() } != null -> + && refExpr.getParentOfTypeAndBranch(){ typeReference } != null -> ANNOTATION - with(refExpr.getParentOfTypeAndBranch(){ getCalleeExpression() }) { - this?.getCalleeExpression() is KtSimpleNameExpression + with(refExpr.getParentOfTypeAndBranch(){ calleeExpression }) { + this?.calleeExpression is KtSimpleNameExpression } -> if (descriptor is ConstructorDescriptor) CLASS_NEW_OPERATOR else FUNCTION_CALL - refExpr.getParentOfTypeAndBranch(){ getOperationReference() } != null || - refExpr.getParentOfTypeAndBranch(){ getOperationReference() } != null || - refExpr.getParentOfTypeAndBranch(){ getOperationReference() } != null -> + refExpr.getParentOfTypeAndBranch(){ operationReference } != null || + refExpr.getParentOfTypeAndBranch(){ operationReference } != null || + refExpr.getParentOfTypeAndBranch(){ operationReference } != null -> FUNCTION_CALL else -> null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/KotlinJavaScriptLibraryDetectionUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/KotlinJavaScriptLibraryDetectionUtil.kt index 62e655148b1..b908289a807 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/KotlinJavaScriptLibraryDetectionUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/KotlinJavaScriptLibraryDetectionUtil.kt @@ -26,13 +26,11 @@ import org.jetbrains.kotlin.idea.caches.JarUserDataManager import org.jetbrains.kotlin.js.JavaScript import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils -public object KotlinJavaScriptLibraryDetectionUtil { - @JvmStatic - public fun isKotlinJavaScriptLibrary(library: Library): Boolean = +object KotlinJavaScriptLibraryDetectionUtil { + @JvmStatic fun isKotlinJavaScriptLibrary(library: Library): Boolean = isKotlinJavaScriptLibrary(library.getFiles(OrderRootType.CLASSES).toList()) - @JvmStatic - public fun isKotlinJavaScriptLibrary(classesRoots: List): Boolean { + @JvmStatic fun isKotlinJavaScriptLibrary(classesRoots: List): Boolean { // Prevent clashing with java runtime if (JavaRuntimeDetectionUtil.getJavaRuntimeVersion(classesRoots) != null) return false @@ -51,11 +49,11 @@ public object KotlinJavaScriptLibraryDetectionUtil { } private fun isJsFileWithMetadata(file: VirtualFile): Boolean = - !file.isDirectory() && - JavaScript.EXTENSION == file.getExtension() && + !file.isDirectory && + JavaScript.EXTENSION == file.extension && KotlinJavascriptMetadataUtils.hasMetadata(String(file.contentsToByteArray(false))) - public object HasKotlinJSMetadataInJar : JarUserDataManager.JarBooleanPropertyCounter(HasKotlinJSMetadataInJar::class.simpleName!!) { + object HasKotlinJSMetadataInJar : JarUserDataManager.JarBooleanPropertyCounter(HasKotlinJSMetadataInJar::class.simpleName!!) { override fun hasProperty(file: VirtualFile) = KotlinJavaScriptLibraryDetectionUtil.isJsFileWithMetadata(file) fun hasMetadataFromCache(root: VirtualFile): Boolean? = JarUserDataManager.hasFileWithProperty(HasKotlinJSMetadataInJar, root) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt index ac83eeb1155..8fb33f0a686 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt @@ -27,65 +27,55 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData import org.jetbrains.kotlin.types.KotlinType -public object IdeRenderers { +object IdeRenderers { - @JvmField - public val HTML_AMBIGUOUS_CALLS: Renderer>> = Renderer { + @JvmField val HTML_AMBIGUOUS_CALLS: Renderer>> = Renderer { calls: Collection> -> calls - .map { it.getResultingDescriptor() } + .map { it.resultingDescriptor } .sortedWith(MemberComparator.INSTANCE) .joinToString("") { "
  • " + DescriptorRenderer.HTML.render(it) + "
  • " } } - @JvmField - public val HTML_RENDER_TYPE: Renderer = Renderer { + @JvmField val HTML_RENDER_TYPE: Renderer = Renderer { DescriptorRenderer.HTML.renderType(it) } - @JvmField - public val HTML_NONE_APPLICABLE_CALLS: Renderer>> = Renderer { + @JvmField val HTML_NONE_APPLICABLE_CALLS: Renderer>> = Renderer { calls: Collection> -> // TODO: compareBy(comparator, selector) in stdlib - val comparator = comparator> { c1, c2 -> MemberComparator.INSTANCE.compare(c1.getResultingDescriptor(), c2.getResultingDescriptor()) } + val comparator = comparator> { c1, c2 -> MemberComparator.INSTANCE.compare(c1.resultingDescriptor, c2.resultingDescriptor) } calls .sortedWith(comparator) .joinToString("") { "
  • " + renderResolvedCall(it) + "
  • " } } - @JvmField - public val HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER: Renderer = Renderer { + @JvmField val HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER: Renderer = Renderer { Renderers.renderConflictingSubstitutionsInferenceError(it, HtmlTabledDescriptorRenderer.create()).toString() } - @JvmField - public val HTML_TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER: Renderer = Renderer { + @JvmField val HTML_TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER: Renderer = Renderer { Renderers.renderParameterConstraintError(it, HtmlTabledDescriptorRenderer.create()).toString() } - @JvmField - public val HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER: Renderer = Renderer { + @JvmField val HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER: Renderer = Renderer { Renderers.renderNoInformationForParameterError(it, HtmlTabledDescriptorRenderer.create()).toString() } - @JvmField - public val HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER: Renderer = Renderer { + @JvmField val HTML_TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER: Renderer = Renderer { Renderers.renderUpperBoundViolatedInferenceError(it, HtmlTabledDescriptorRenderer.create()).toString() } - @JvmField - public val HTML_RENDER_RETURN_TYPE: Renderer = Renderer { - val returnType = it.getReturnType()!! + @JvmField val HTML_RENDER_RETURN_TYPE: Renderer = Renderer { + val returnType = it.returnType!! DescriptorRenderer.HTML.renderType(returnType) } - @JvmField - public val HTML_COMPACT_WITH_MODIFIERS: DescriptorRenderer = DescriptorRenderer.HTML.withOptions { + @JvmField val HTML_COMPACT_WITH_MODIFIERS: DescriptorRenderer = DescriptorRenderer.HTML.withOptions { withDefinedIn = false } - @JvmField - public val HTML_CONFLICTING_JVM_DECLARATIONS_DATA: Renderer = Renderer { + @JvmField val HTML_CONFLICTING_JVM_DECLARATIONS_DATA: Renderer = Renderer { data: ConflictingJvmDeclarationsData -> val conflicts = data.signatureOrigins @@ -96,8 +86,7 @@ public object IdeRenderers { "The following declarations have the same JVM signature (${data.signature.name}${data.signature.desc}):
    \n
      \n$conflicts
    " } - @JvmField - public val HTML_THROWABLE: Renderer = Renderer { + @JvmField val HTML_THROWABLE: Renderer = Renderer { Renderers.THROWABLE.render(it).replace("\n", "
    ") } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt index d6c5b05b09a..182e7a3a40a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt @@ -36,7 +36,7 @@ import com.intellij.psi.PsiRecursiveElementVisitor import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor import org.jetbrains.kotlin.psi.KtFile -public class KotlinBeforeResolveHighlightingPass( +class KotlinBeforeResolveHighlightingPass( private val file: KtFile, document: Document ) : TextEditorHighlightingPass(file.project, document), DumbAware { @@ -68,7 +68,7 @@ public class KotlinBeforeResolveHighlightingPass( annotationHolder = null } - public class Factory(project: Project, registrar: TextEditorHighlightingPassRegistrar) : AbstractProjectComponent(project), TextEditorHighlightingPassFactory { + class Factory(project: Project, registrar: TextEditorHighlightingPassRegistrar) : AbstractProjectComponent(project), TextEditorHighlightingPassFactory { init { registrar.registerTextEditorHighlightingPass(this, TextEditorHighlightingPassRegistrar.Anchor.BEFORE, Pass.UPDATE_FOLDING, false, false) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinProblemHighlightFilter.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinProblemHighlightFilter.kt index 81a009f12d8..3671be71da3 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinProblemHighlightFilter.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinProblemHighlightFilter.kt @@ -24,7 +24,7 @@ import com.intellij.ide.projectView.impl.ProjectRootsUtil class KotlinProblemHighlightFilter : ProblemHighlightFilter() { override fun shouldHighlight(psiFile: PsiFile): Boolean { - return psiFile.getFileType() != KotlinFileType.INSTANCE || !ProjectRootsUtil.isOutsideSourceRoot(psiFile) + return psiFile.fileType != KotlinFileType.INSTANCE || !ProjectRootsUtil.isOutsideSourceRoot(psiFile) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt index f930d509e3d..47d28d8eaf2 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt @@ -54,12 +54,12 @@ import org.jetbrains.kotlin.utils.singletonOrEmptyList import java.lang.reflect.* import java.util.* -public open class KotlinPsiChecker : Annotator, HighlightRangeExtension { +open class KotlinPsiChecker : Annotator, HighlightRangeExtension { override fun annotate(element: PsiElement, holder: AnnotationHolder) { - if (!(ProjectRootsUtil.isInProjectOrLibraryContent(element) || element.getContainingFile() is KtCodeFragment)) return + if (!(ProjectRootsUtil.isInProjectOrLibraryContent(element) || element.containingFile is KtCodeFragment)) return - val file = element.getContainingFile() as KtFile + val file = element.containingFile as KtFile val analysisResult = file.analyzeFullyAndGetResult() if (analysisResult.isError()) { @@ -80,7 +80,7 @@ public open class KotlinPsiChecker : Annotator, HighlightRangeExtension { open protected fun shouldSuppressUnusedParameter(parameter: KtParameter): Boolean = false fun annotateElement(element: PsiElement, holder: AnnotationHolder, diagnostics: Diagnostics) { - if (ProjectRootsUtil.isInProjectSource(element) || element.getContainingFile() is KtCodeFragment) { + if (ProjectRootsUtil.isInProjectSource(element) || element.containingFile is KtCodeFragment) { ElementAnnotator(element, holder, { param -> shouldSuppressUnusedParameter(param) }).registerDiagnosticsAnnotations(diagnostics.forElement(element)) } } @@ -93,7 +93,7 @@ public open class KotlinPsiChecker : Annotator, HighlightRangeExtension { TypeKindHighlightingVisitor(holder, bindingContext) ) - public fun createQuickFixes(diagnostic: Diagnostic): Collection = + fun createQuickFixes(diagnostic: Diagnostic): Collection = createQuickFixes(diagnostic.singletonOrEmptyList())[diagnostic] } } @@ -118,7 +118,7 @@ private fun createQuickFixes(similarDiagnostics: Collection): MultiM } for (diagnostic in similarDiagnostics) { - actions.putValues(diagnostic, QuickFixes.getInstance().getActions(diagnostic.getFactory())) + actions.putValues(diagnostic, QuickFixes.getInstance().getActions(diagnostic.factory)) } actions.values().forEach { NoDeclarationDescriptorsChecker.check(it.javaClass) } @@ -177,9 +177,9 @@ private class ElementAnnotator(private val element: PsiElement, if (validDiagnostics.isEmpty()) return val diagnostic = diagnostics.first() - val factory = diagnostic.getFactory() + val factory = diagnostic.factory - assert(diagnostics.all { it.getPsiElement() == element && it.factory == factory }) + assert(diagnostics.all { it.psiElement == element && it.factory == factory }) val ranges = diagnostic.textRanges @@ -191,7 +191,7 @@ private class ElementAnnotator(private val element: PsiElement, val reference = referenceExpression.mainReference if (reference is MultiRangeReference) { AnnotationPresentationInfo( - ranges = reference.getRanges().map { it.shiftRight(referenceExpression.getTextOffset()) }, + ranges = reference.ranges.map { it.shiftRight(referenceExpression.textOffset) }, highlightType = ProblemHighlightType.LIKE_UNKNOWN_SYMBOL) } else { @@ -202,7 +202,7 @@ private class ElementAnnotator(private val element: PsiElement, Errors.ILLEGAL_ESCAPE -> AnnotationPresentationInfo(ranges, textAttributes = KotlinHighlightingColors.INVALID_STRING_ESCAPE) Errors.REDECLARATION -> AnnotationPresentationInfo( - ranges = listOf(diagnostic.getTextRanges().first()), nonDefaultMessage = "") + ranges = listOf(diagnostic.textRanges.first()), nonDefaultMessage = "") else -> { AnnotationPresentationInfo( @@ -243,12 +243,12 @@ private class ElementAnnotator(private val element: PsiElement, fixes.forEach { annotation.registerFix(it) } - if (diagnostic.getSeverity() == Severity.WARNING) { - annotation.setProblemGroup(KotlinSuppressableWarningProblemGroup(diagnostic.getFactory())) + if (diagnostic.severity == Severity.WARNING) { + annotation.problemGroup = KotlinSuppressableWarningProblemGroup(diagnostic.factory) if (fixes.isEmpty()) { // if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions - annotation.registerFix(EmptyIntentionAction(diagnostic.getFactory().getName())) + annotation.registerFix(EmptyIntentionAction(diagnostic.factory.name)) } } } @@ -262,7 +262,7 @@ private class AnnotationPresentationInfo( val highlightType: ProblemHighlightType? = null, val textAttributes: TextAttributesKey? = null) { - public fun create(diagnostic: Diagnostic, range: TextRange, holder: AnnotationHolder): Annotation { + fun create(diagnostic: Diagnostic, range: TextRange, holder: AnnotationHolder): Annotation { val defaultMessage = nonDefaultMessage?: getDefaultMessage(diagnostic) val annotation = when (diagnostic.severity) { @@ -286,8 +286,8 @@ private class AnnotationPresentationInfo( private fun getMessage(diagnostic: Diagnostic): String { var message = IdeErrorMessages.render(diagnostic) - if (KotlinInternalMode.enabled || ApplicationManager.getApplication().isUnitTestMode()) { - val factoryName = diagnostic.getFactory().getName() + if (KotlinInternalMode.enabled || ApplicationManager.getApplication().isUnitTestMode) { + val factoryName = diagnostic.factory.name if (message.startsWith("")) { message = "[$factoryName] ${message.substring("".length)}" } @@ -303,8 +303,8 @@ private class AnnotationPresentationInfo( private fun getDefaultMessage(diagnostic: Diagnostic): String { val message = DefaultErrorMessages.render(diagnostic) - if (KotlinInternalMode.enabled || ApplicationManager.getApplication().isUnitTestMode()) { - return "[${diagnostic.getFactory().getName()}] $message" + if (KotlinInternalMode.enabled || ApplicationManager.getApplication().isUnitTestMode) { + return "[${diagnostic.factory.name}] $message" } return message } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt index c20443dc116..b40351c33c7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt @@ -32,10 +32,10 @@ class KotlinSuppressableWarningProblemGroup( ) : SuppressableProblemGroup { init { - assert (diagnosticFactory.getSeverity() == Severity.WARNING) + assert (diagnosticFactory.severity == Severity.WARNING) } - override fun getProblemName() = diagnosticFactory.getName() + override fun getProblemName() = diagnosticFactory.name override fun getSuppressActions(element: PsiElement?): Array { if (element == null) @@ -99,10 +99,10 @@ private object DeclarationKindDetector : KtVisitor() override fun visitNamedFunction(d: KtNamedFunction, data: Unit?) = detect(d, "fun") - override fun visitProperty(d: KtProperty, data: Unit?) = detect(d, d.getValOrVarKeyword().getText()!!) + override fun visitProperty(d: KtProperty, data: Unit?) = detect(d, d.valOrVarKeyword.text!!) - override fun visitDestructuringDeclaration(d: KtDestructuringDeclaration, data: Unit?) = detect(d, d.getValOrVarKeyword()?.getText() ?: "val", - name = d.getEntries().map { it.getName()!! }.joinToString(", ", "(", ")")) + override fun visitDestructuringDeclaration(d: KtDestructuringDeclaration, data: Unit?) = detect(d, d.valOrVarKeyword?.text ?: "val", + name = d.entries.map { it.name!! }.joinToString(", ", "(", ")")) override fun visitTypeParameter(d: KtTypeParameter, data: Unit?) = detect(d, "type parameter", newLineNeeded = false) @@ -111,11 +111,11 @@ private object DeclarationKindDetector : KtVisitor() override fun visitParameter(d: KtParameter, data: Unit?) = detect(d, "parameter", newLineNeeded = false) override fun visitObjectDeclaration(d: KtObjectDeclaration, data: Unit?): AnnotationHostKind? { - if (d.isCompanion()) return detect(d, "companion object", name = "${d.getName()} of ${d.getStrictParentOfType()?.getName()}") - if (d.getParent() is KtObjectLiteralExpression) return null + if (d.isCompanion()) return detect(d, "companion object", name = "${d.name} of ${d.getStrictParentOfType()?.name}") + if (d.parent is KtObjectLiteralExpression) return null return detect(d, "object") } - private fun detect(declaration: KtDeclaration, kind: String, name: String = declaration.getName() ?: "", newLineNeeded: Boolean = true) + private fun detect(declaration: KtDeclaration, kind: String, name: String = declaration.name ?: "", newLineNeeded: Boolean = true) = AnnotationHostKind(kind, name, newLineNeeded) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/NameHighlighter.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/NameHighlighter.kt index 9971817ff7b..8a652600388 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/NameHighlighter.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/NameHighlighter.kt @@ -23,20 +23,20 @@ import com.intellij.psi.PsiElement import org.jetbrains.annotations.TestOnly object NameHighlighter { - public var namesHighlightingEnabled = true + var namesHighlightingEnabled = true @TestOnly set @JvmStatic fun highlightName(holder: AnnotationHolder, psiElement: PsiElement, attributesKey: TextAttributesKey) { if (namesHighlightingEnabled) { - holder.createInfoAnnotation(psiElement, null).setTextAttributes(attributesKey) + holder.createInfoAnnotation(psiElement, null).textAttributes = attributesKey } } @JvmStatic fun highlightName(holder: AnnotationHolder, textRange: TextRange, attributesKey: TextAttributesKey) { if (namesHighlightingEnabled) { - holder.createInfoAnnotation(textRange, null).setTextAttributes(attributesKey) + holder.createInfoAnnotation(textRange, null).textAttributes = attributesKey } } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/renderersUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/renderersUtil.kt index 1e957c8fc00..9cf29694453 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/renderersUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/renderersUtil.kt @@ -32,11 +32,11 @@ import org.jetbrains.kotlin.types.ErrorUtils private val RED_TEMPLATE = "%s" private val STRONG_TEMPLATE = "%s" -public fun renderStrong(o: Any): String = STRONG_TEMPLATE.format(o) +fun renderStrong(o: Any): String = STRONG_TEMPLATE.format(o) -public fun renderError(o: Any): String = RED_TEMPLATE.format(o) +fun renderError(o: Any): String = RED_TEMPLATE.format(o) -public fun renderStrong(o: Any, error: Boolean): String = (if (error) RED_TEMPLATE else STRONG_TEMPLATE).format(o) +fun renderStrong(o: Any, error: Boolean): String = (if (error) RED_TEMPLATE else STRONG_TEMPLATE).format(o) private val HTML_FOR_UNINFERRED_TYPE_PARAMS: DescriptorRenderer = DescriptorRenderer.withOptions { uninferredTypeParameterAsName = true @@ -54,7 +54,7 @@ fun renderResolvedCall(resolvedCall: ResolvedCall): fun renderParameter(parameter: ValueParameterDescriptor): String { val varargElementType = parameter.varargElementType - val parameterType = varargElementType ?: parameter.getType() + val parameterType = varargElementType ?: parameter.type val renderedParameter = (if (varargElementType != null) "vararg " else "") + htmlRenderer.renderType(parameterType) + @@ -66,50 +66,50 @@ fun renderResolvedCall(resolvedCall: ResolvedCall): } fun appendTypeParametersSubstitution() { - val parametersToArgumentsMap = resolvedCall.getTypeArguments() + val parametersToArgumentsMap = resolvedCall.typeArguments fun TypeParameterDescriptor.isInferred(): Boolean { val typeArgument = parametersToArgumentsMap[this] if (typeArgument == null) return false return !ErrorUtils.isUninferredParameter(typeArgument) } - val typeParameters = resolvedCall.getCandidateDescriptor().getTypeParameters() + val typeParameters = resolvedCall.candidateDescriptor.typeParameters val (inferredTypeParameters, notInferredTypeParameters) = typeParameters.partition { parameter -> parameter.isInferred() } append("
    $indentwhere ") if (!notInferredTypeParameters.isEmpty()) { - append(notInferredTypeParameters.map { typeParameter -> renderError(typeParameter.getName()) }.joinToString()) + append(notInferredTypeParameters.map { typeParameter -> renderError(typeParameter.name) }.joinToString()) append(" cannot be inferred") if (!inferredTypeParameters.isEmpty()) { append("; ") } } - val typeParameterToTypeArgumentMap = resolvedCall.getTypeArguments() + val typeParameterToTypeArgumentMap = resolvedCall.typeArguments if (!inferredTypeParameters.isEmpty()) { append(inferredTypeParameters.map { typeParameter -> - "${typeParameter.getName()} = ${htmlRenderer.renderType(typeParameterToTypeArgumentMap[typeParameter]!!)}" + "${typeParameter.name} = ${htmlRenderer.renderType(typeParameterToTypeArgumentMap[typeParameter]!!)}" }.joinToString()) } } - val resultingDescriptor = resolvedCall.getResultingDescriptor() - val receiverParameter = resultingDescriptor.getExtensionReceiverParameter() + val resultingDescriptor = resolvedCall.resultingDescriptor + val receiverParameter = resultingDescriptor.extensionReceiverParameter if (receiverParameter != null) { - append(htmlRenderer.renderType(receiverParameter.getType())).append(".") + append(htmlRenderer.renderType(receiverParameter.type)).append(".") } - append(resultingDescriptor.getName()).append("(") - append(resultingDescriptor.getValueParameters().map { parameter -> renderParameter(parameter) }.joinToString()) + append(resultingDescriptor.name).append("(") + append(resultingDescriptor.valueParameters.map { parameter -> renderParameter(parameter) }.joinToString()) append(if (resolvedCall.hasUnmappedArguments()) renderError(")") else ")") - if (!resolvedCall.getCandidateDescriptor().getTypeParameters().isEmpty()) { + if (!resolvedCall.candidateDescriptor.typeParameters.isEmpty()) { appendTypeParametersSubstitution() append(" for
    $indent") - append(htmlRenderer.render(resolvedCall.getCandidateDescriptor())) + append(htmlRenderer.render(resolvedCall.candidateDescriptor)) } else { append(" defined in ") - val containingDeclaration = resultingDescriptor.getContainingDeclaration() + val containingDeclaration = resultingDescriptor.containingDeclaration val fqName = DescriptorUtils.getFqName(containingDeclaration) append(if (fqName.isRoot) "root package" else fqName.asString()) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt index 7e6135c1fce..8a067c70632 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt @@ -26,15 +26,15 @@ import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.idea.highlighter.createSuppressWarningActions import org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheService -public abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool { - public override fun getSuppressActions(element: PsiElement?): Array? { +abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool { + override fun getSuppressActions(element: PsiElement?): Array? { if (element == null) return emptyArray() return createSuppressWarningActions(element, toSeverity(defaultLevel), suppressionKey).toTypedArray() } - public override fun isSuppressedFor(element: PsiElement): Boolean { - if (SuppressManager.getInstance()!!.isSuppressedFor(element, getID())) { + override fun isSuppressedFor(element: PsiElement): Boolean { + if (SuppressManager.getInstance()!!.isSuppressedFor(element, id)) { return true } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt index 28605ea44e1..54dc1b4fb17 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt @@ -34,8 +34,8 @@ import com.intellij.util.SmartList import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.psi.KtElement -public abstract class IntentionBasedInspection( - public val intentions: List>, +abstract class IntentionBasedInspection( + val intentions: List>, protected val problemText: String?, protected val elementType: Class ) : AbstractKotlinInspection() { @@ -43,7 +43,7 @@ public abstract class IntentionBasedInspection( constructor(intention: SelfTargetingRangeIntention, additionalChecker: (TElement) -> Boolean = { true }) : this(listOf(IntentionData(intention, additionalChecker)), null, intention.elementType) - public data class IntentionData( + data class IntentionData( val intention: SelfTargetingRangeIntention, val additionalChecker: (TElement) -> Boolean = { true } ) @@ -51,7 +51,7 @@ public abstract class IntentionBasedInspection( override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { return object : PsiElementVisitor() { override fun visitElement(element: PsiElement) { - if (!elementType.isInstance(element) || element.getTextLength() == 0) return + if (!elementType.isInstance(element) || element.textLength == 0) return @Suppress("UNCHECKED_CAST") val targetElement = element as TElement @@ -62,9 +62,9 @@ public abstract class IntentionBasedInspection( for ((intention, additionalChecker) in intentions) { synchronized(intention) { val range = intention.applicabilityRange(targetElement)?.let { range -> - val elementRange = targetElement.getTextRange() + val elementRange = targetElement.textRange assert(range in elementRange) { "Wrong applicabilityRange() result for $intention - should be within element's range" } - range.shiftRight(-elementRange.getStartOffset()) + range.shiftRight(-elementRange.startOffset) } if (range != null && additionalChecker(targetElement)) { @@ -96,13 +96,13 @@ public abstract class IntentionBasedInspection( ) : LocalQuickFixOnPsiElement(targetElement), IntentionAction { // store text into variable because intention instance is shared and may change its text later - override fun getFamilyName() = intention.getFamilyName() + override fun getFamilyName() = intention.familyName override fun getText(): String = text override fun startInWriteAction() = true - override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?) = isAvailable() + override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?) = isAvailable override fun isAvailable(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement): Boolean { assert(startElement == endElement) @@ -119,13 +119,13 @@ public abstract class IntentionBasedInspection( if (!isAvailable(project, file, startElement, endElement)) return startElement.getOrCreateEditor()?.let { editor -> - editor.getCaretModel().moveToOffset(startElement.getTextOffset()) + editor.caretModel.moveToOffset(startElement.textOffset) intention.applyTo(startElement as TElement, editor) } } private fun PsiElement.getOrCreateEditor(): Editor? { - val file = getContainingFile()?.getVirtualFile() ?: return null + val file = containingFile?.virtualFile ?: return null val document = FileDocumentManager.getInstance().getDocument(file) ?: return null val editorFactory = EditorFactory.getInstance() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt index 29c75f8a43a..e6aada613cd 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt @@ -31,11 +31,11 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.util.OperatorNameConventions -public class OperatorToFunctionIntention : SelfTargetingIntention(KtExpression::class.java, "Replace overloaded operator with function call") { +class OperatorToFunctionIntention : SelfTargetingIntention(KtExpression::class.java, "Replace overloaded operator with function call") { companion object { private fun isApplicablePrefix(element: KtPrefixExpression, caretOffset: Int): Boolean { - val opRef = element.getOperationReference() - if (!opRef.getTextRange().containsOffset(caretOffset)) return false + val opRef = element.operationReference + if (!opRef.textRange.containsOffset(caretOffset)) return false return when (opRef.getReferencedNameElementType()) { KtTokens.PLUS, KtTokens.MINUS, KtTokens.PLUSPLUS, KtTokens.MINUSMINUS, KtTokens.EXCL -> true else -> false @@ -43,9 +43,9 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( } private fun isApplicablePostfix(element: KtPostfixExpression, caretOffset: Int): Boolean { - val opRef = element.getOperationReference() - if (!opRef.getTextRange().containsOffset(caretOffset)) return false - if (element.getBaseExpression() == null) return false + val opRef = element.operationReference + if (!opRef.textRange.containsOffset(caretOffset)) return false + if (element.baseExpression == null) return false return when (opRef.getReferencedNameElementType()) { KtTokens.PLUSPLUS, KtTokens.MINUSMINUS -> true else -> false @@ -53,37 +53,37 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( } private fun isApplicableBinary(element: KtBinaryExpression, caretOffset: Int): Boolean { - val opRef = element.getOperationReference() - if (!opRef.getTextRange().containsOffset(caretOffset)) return false + val opRef = element.operationReference + if (!opRef.textRange.containsOffset(caretOffset)) return false return when (opRef.getReferencedNameElementType()) { KtTokens.PLUS, KtTokens.MINUS, KtTokens.MUL, KtTokens.DIV, KtTokens.PERC, KtTokens.RANGE, KtTokens.IN_KEYWORD, KtTokens.NOT_IN, KtTokens.PLUSEQ, KtTokens.MINUSEQ, KtTokens.MULTEQ, KtTokens.DIVEQ, KtTokens.PERCEQ, KtTokens.EQEQ, KtTokens.EXCLEQ, KtTokens.GT, KtTokens.LT, KtTokens.GTEQ, KtTokens.LTEQ -> true - KtTokens.EQ -> element.getLeft() is KtArrayAccessExpression + KtTokens.EQ -> element.left is KtArrayAccessExpression else -> false } } private fun isApplicableArrayAccess(element: KtArrayAccessExpression, caretOffset: Int): Boolean { - val lbracket = element.getLeftBracket() ?: return false - val rbracket = element.getRightBracket() ?: return false + val lbracket = element.leftBracket ?: return false + val rbracket = element.rightBracket ?: return false val access = element.readWriteAccess(useResolveForReadWrite = true) if (access == ReferenceAccess.READ_WRITE) return false // currently not supported - return lbracket.getTextRange().containsOffset(caretOffset) || rbracket.getTextRange().containsOffset(caretOffset) + return lbracket.textRange.containsOffset(caretOffset) || rbracket.textRange.containsOffset(caretOffset) } private fun isApplicableCall(element: KtCallExpression, caretOffset: Int): Boolean { - val lbrace = (element.getValueArgumentList()?.getLeftParenthesis() - ?: element.getLambdaArguments().firstOrNull()?.getLambdaExpression()?.getLeftCurlyBrace() + val lbrace = (element.valueArgumentList?.leftParenthesis + ?: element.lambdaArguments.firstOrNull()?.getLambdaExpression()?.leftCurlyBrace ?: return false) as PsiElement - if (!lbrace.getTextRange().containsOffset(caretOffset)) return false + if (!lbrace.textRange.containsOffset(caretOffset)) return false val resolvedCall = element.getResolvedCall(element.analyze()) - val descriptor = resolvedCall?.getResultingDescriptor() + val descriptor = resolvedCall?.resultingDescriptor if (descriptor is FunctionDescriptor && descriptor.getName() == OperatorNameConventions.INVOKE) { - if (element.getParent() is KtDotQualifiedExpression && - element.getCalleeExpression()?.getText() == OperatorNameConventions.INVOKE.asString()) return false - return element.getValueArgumentList() != null || element.getLambdaArguments().isNotEmpty() + if (element.parent is KtDotQualifiedExpression && + element.calleeExpression?.text == OperatorNameConventions.INVOKE.asString()) return false + return element.valueArgumentList != null || element.lambdaArguments.isNotEmpty() } return false } @@ -104,7 +104,7 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( } private fun convertPostFix(element: KtPostfixExpression): KtExpression { - val op = element.getOperationReference().getReferencedNameElementType() + val op = element.operationReference.getReferencedNameElementType() val operatorName = when (op) { KtTokens.PLUSPLUS -> OperatorNameConventions.INC KtTokens.MINUSMINUS -> OperatorNameConventions.DEC @@ -130,7 +130,7 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( val context = element.analyze(BodyResolveMode.PARTIAL) val functionCandidate = element.getResolvedCall(context) - val functionName = functionCandidate?.getCandidateDescriptor()?.getName().toString() + val functionName = functionCandidate?.candidateDescriptor?.name.toString() val elemType = context.getType(left) val pattern = when (op) { @@ -194,11 +194,11 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( //TODO: don't use creation by plain text private fun convertCall(element: KtCallExpression): KtExpression { - val callee = element.getCalleeExpression()!! - val arguments = element.getValueArgumentList() - val argumentString = arguments?.getText()?.removeSurrounding("(", ")") - val funcLitArgs = element.getLambdaArguments() - val calleeText = callee.getText() + val callee = element.calleeExpression!! + val arguments = element.valueArgumentList + val argumentString = arguments?.text?.removeSurrounding("(", ")") + val funcLitArgs = element.lambdaArguments + val calleeText = callee.text val transformation = "$calleeText.${OperatorNameConventions.INVOKE.asString()}" + (if (argumentString == null) "()" else "($argumentString)") val transformed = KtPsiFactory(element).createExpression(transformation) @@ -209,10 +209,10 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( callExpression.valueArgumentList?.delete() } } - return callee.getParent()!!.replace(transformed) as KtExpression + return callee.parent!!.replace(transformed) as KtExpression } - public fun convert(element: KtExpression): Pair { + fun convert(element: KtExpression): Pair { var elementToBeReplaced = element if (element is KtArrayAccessExpression && isAssignmentLeftSide(element)) { elementToBeReplaced = element.parent as KtExpression @@ -240,12 +240,12 @@ public class OperatorToFunctionIntention : SelfTargetingIntention( return when (result) { is KtBinaryExpression -> { if (KtPsiUtil.isAssignment(result)) - findCallName(result.getRight()!!) + findCallName(result.right!!) else - findCallName(result.getLeft()!!) + findCallName(result.left!!) } - is KtUnaryExpression -> findCallName(result.getBaseExpression()!!) + is KtUnaryExpression -> findCallName(result.baseExpression!!) else -> result.getQualifiedElementSelector() as KtSimpleNameExpression? } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt index ba11a1e7d60..16c17bcde3f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt @@ -34,8 +34,8 @@ import org.jetbrains.kotlin.psi.psiUtil.containsInside import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import java.util.* -public abstract class SelfTargetingIntention( - public val elementType: Class, +abstract class SelfTargetingIntention( + val elementType: Class, private var text: String, private val familyName: String = text ) : IntentionAction { @@ -49,12 +49,12 @@ public abstract class SelfTargetingIntention( final override fun getText() = text final override fun getFamilyName() = familyName - public abstract fun isApplicableTo(element: TElement, caretOffset: Int): Boolean + abstract fun isApplicableTo(element: TElement, caretOffset: Int): Boolean - public abstract fun applyTo(element: TElement, editor: Editor) + abstract fun applyTo(element: TElement, editor: Editor) private fun getTarget(editor: Editor, file: PsiFile): TElement? { - val offset = editor.getCaretModel().getOffset() + val offset = editor.caretModel.offset val leaf1 = file.findElementAt(offset) val leaf2 = file.findElementAt(offset - 1) val commonParent = if (leaf1 != null && leaf2 != null) PsiTreeUtil.findCommonParent(leaf1, leaf2) else null @@ -75,7 +75,7 @@ public abstract class SelfTargetingIntention( if (elementType.isInstance(element) && isApplicableTo(element as TElement, offset)) { return element } - if (!allowCaretInsideElement(element) && element.getTextRange().containsInside(offset)) break + if (!allowCaretInsideElement(element) && element.textRange.containsInside(offset)) break } return null } @@ -131,13 +131,13 @@ public abstract class SelfTargetingIntention( } } -public abstract class SelfTargetingRangeIntention( +abstract class SelfTargetingRangeIntention( elementType: Class, text: String, familyName: String = text ) : SelfTargetingIntention(elementType, text, familyName) { - public abstract fun applicabilityRange(element: TElement): TextRange? + abstract fun applicabilityRange(element: TElement): TextRange? override final fun isApplicableTo(element: TElement, caretOffset: Int): Boolean { val range = applicabilityRange(element) ?: return false @@ -145,15 +145,15 @@ public abstract class SelfTargetingRangeIntention( } } -public abstract class SelfTargetingOffsetIndependentIntention( +abstract class SelfTargetingOffsetIndependentIntention( elementType: Class, text: String, familyName: String = text ) : SelfTargetingRangeIntention(elementType, text, familyName) { - public abstract fun isApplicableTo(element: TElement): Boolean + abstract fun isApplicableTo(element: TElement): Boolean override final fun applicabilityRange(element: TElement): TextRange? { - return if (isApplicableTo(element)) element.getTextRange() else null + return if (isApplicableTo(element)) element.textRange else null } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocElementFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocElementFactory.kt index 2c8650c6cce..0a1a19bff11 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocElementFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocElementFactory.kt @@ -25,13 +25,13 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocName import org.jetbrains.kotlin.psi.psiUtil.getChildOfType class KDocElementFactory(val project: Project) { - public fun createKDocFromText(text: String): KDoc { + fun createKDocFromText(text: String): KDoc { val fileText = text + " fun foo { }" val function = KtPsiFactory(project).createDeclaration(fileText) return PsiTreeUtil.findChildOfType(function, KDoc::class.java)!! } - public fun createNameFromText(text: String): KDocName { + fun createNameFromText(text: String): KDocName { val kdoc = createKDocFromText("/** @param $text foo*/") val section = kdoc.getDefaultSection() val tag = section.findTagByName("param") diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocFinder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocFinder.kt index 4cfe871aa3a..ba293ca24ea 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocFinder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocFinder.kt @@ -28,14 +28,14 @@ import org.jetbrains.kotlin.resolve.source.PsiSourceElement object KDocFinder { fun findKDoc(declaration: DeclarationDescriptor): KDocTag? { if (declaration is DeclarationDescriptorWithSource) { - var psiDeclaration = (declaration.getSource() as? PsiSourceElement)?.psi?.getNavigationElement() + var psiDeclaration = (declaration.source as? PsiSourceElement)?.psi?.navigationElement // KDoc for primary constructor is located inside of its class KDoc if (psiDeclaration is KtPrimaryConstructor) { psiDeclaration = psiDeclaration.getContainingClassOrObject() } if (psiDeclaration is KtDeclaration) { - val kdoc = psiDeclaration.getDocComment() + val kdoc = psiDeclaration.docComment if (kdoc != null) { if (declaration is ConstructorDescriptor) { // ConstructorDescriptor resolves to the same JetDeclaration @@ -50,7 +50,7 @@ object KDocFinder { } if (declaration is PropertyDescriptor) { - val containingClassDescriptor = declaration.getContainingDeclaration() as? ClassDescriptor + val containingClassDescriptor = declaration.containingDeclaration as? ClassDescriptor if (containingClassDescriptor != null) { val classKDoc = findKDoc(containingClassDescriptor)?.getParentOfType(false) if (classKDoc != null) { @@ -64,8 +64,8 @@ object KDocFinder { } if (declaration is CallableDescriptor) { - for (baseDescriptor in declaration.getOverriddenDescriptors()) { - val baseKDoc = findKDoc(baseDescriptor.getOriginal()) + for (baseDescriptor in declaration.overriddenDescriptors) { + val baseKDoc = findKDoc(baseDescriptor.original) if (baseKDoc != null) { return baseKDoc } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocHighlightingVisitor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocHighlightingVisitor.kt index 28c8f1a2478..2e417f78ae8 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocHighlightingVisitor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocHighlightingVisitor.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocLink class KDocHighlightingVisitor(private val holder: AnnotationHolder): PsiElementVisitor() { override fun visitElement(element: PsiElement) { if (element is KDocLink) { - holder.createInfoAnnotation(element, null).setTextAttributes(KotlinHighlightingColors.KDOC_LINK) + holder.createInfoAnnotation(element, null).textAttributes = KotlinHighlightingColors.KDOC_LINK } } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt index a755d1b2524..9186ba69955 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope import org.jetbrains.kotlin.resolve.source.PsiSourceElement -public class KDocReference(element: KDocName): KtMultiReference(element) { +class KDocReference(element: KDocName): KtMultiReference(element) { override fun getTargetDescriptors(context: BindingContext): Collection { val declaration = element.getContainingDoc().getOwner() ?: return arrayListOf() val declarationDescriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] ?: return arrayListOf() @@ -64,7 +64,7 @@ public class KDocReference(element: KDocName): KtMultiReference(elemen override fun getCanonicalText(): String = element.getNameText() } -public fun resolveKDocLink(resolutionFacade: ResolutionFacade, +fun resolveKDocLink(resolutionFacade: ResolutionFacade, fromDescriptor: DeclarationDescriptor, fromSubjectOfTag: KDocTag?, qualifiedName: List): Collection { @@ -98,7 +98,7 @@ private fun resolveInLocalScope(fromDescriptor: DeclarationDescriptor, } } -public fun getParamDescriptors(fromDescriptor: DeclarationDescriptor): List { +fun getParamDescriptors(fromDescriptor: DeclarationDescriptor): List { // TODO resolve parameters of functions passed as parameters when (fromDescriptor) { is CallableDescriptor -> @@ -151,7 +151,7 @@ private fun getClassInnerScope(outerScope: LexicalScope, descriptor: ClassDescri scopeChain) } -public fun getResolutionScope(resolutionFacade: ResolutionFacade, descriptor: DeclarationDescriptor): LexicalScope { +fun getResolutionScope(resolutionFacade: ResolutionFacade, descriptor: DeclarationDescriptor): LexicalScope { return when (descriptor) { is PackageFragmentDescriptor -> LexicalScope.empty(getPackageInnerScope(descriptor).memberScopeAsImportingScope(), descriptor) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt index a82f28d4bdf..b463617ac18 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt @@ -23,7 +23,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.kdoc.psi.impl.KDocName -public class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() { +class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor = KDocUnresolvedReferenceVisitor(holder) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/AnalyzerFacadeProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/AnalyzerFacadeProvider.kt index 5ea76364adf..c1de3f55a79 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/AnalyzerFacadeProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/AnalyzerFacadeProvider.kt @@ -24,10 +24,10 @@ import org.jetbrains.kotlin.resolve.jvm.JvmAnalyzerFacade import org.jetbrains.kotlin.resolve.jvm.JvmPlatformParameters import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public object AnalyzerFacadeProvider { +object AnalyzerFacadeProvider { //NOTE: it's convenient that JS backend doesn't have platform parameters (for now) // otherwise we would be forced to add casts on the call site of setupResolverForProject - public fun getAnalyzerFacade(targetPlatform: TargetPlatform): AnalyzerFacade { + fun getAnalyzerFacade(targetPlatform: TargetPlatform): AnalyzerFacade { return when (targetPlatform) { JvmPlatform -> JvmAnalyzerFacade JsPlatform -> JsAnalyzerFacade diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt index 93155f8e665..f2d9583cdec 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.useImpl import org.jetbrains.kotlin.resolve.TargetEnvironment -public object IdeaEnvironment : TargetEnvironment("Idea") { +object IdeaEnvironment : TargetEnvironment("Idea") { override fun configure(container: StorageComponentContainer) { container.useImpl() container.useImpl() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaLocalDescriptorResolver.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaLocalDescriptorResolver.kt index de408b5ec52..e2017fb5660 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaLocalDescriptorResolver.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaLocalDescriptorResolver.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.LocalDescriptorResolver import org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException -public class IdeaLocalDescriptorResolver( +class IdeaLocalDescriptorResolver( private val resolveElementCache: ResolveElementCache ): LocalDescriptorResolver { override fun resolveLocalDeclaration(declaration: KtDeclaration): DeclarationDescriptor { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index 8c3d3f15b90..67c8c3b39bd 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyScriptDescriptor import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.utils.addToStdlib.check -public class ResolveElementCache( +class ResolveElementCache( private val resolveSession: ResolveSession, private val project: Project, private val targetPlatform: TargetPlatform, @@ -114,7 +114,7 @@ public class ResolveElementCache( override fun resolveFunctionBody(function: KtNamedFunction) = getElementAdditionalResolve(function, function, BodyResolveMode.FULL) - public fun resolvePrimaryConstructorParametersDefaultValues(ktClass: KtClass): BindingContext { + fun resolvePrimaryConstructorParametersDefaultValues(ktClass: KtClass): BindingContext { return constructorAdditionalResolve(resolveSession, ktClass, ktClass.getContainingKtFile()).bindingContext } @@ -179,7 +179,7 @@ public class ResolveElementCache( } } - public fun resolveToElement(element: KtElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext { + fun resolveToElement(element: KtElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext { var contextElement = element val elementOfAdditionalResolve = findElementOfAdditionalResolve(contextElement) @@ -198,7 +198,7 @@ public class ResolveElementCache( resolveSession.resolveToDescriptor(declaration) } - return resolveSession.getBindingContext() + return resolveSession.bindingContext } private fun findElementOfAdditionalResolve(element: KtElement): KtElement? { @@ -313,11 +313,11 @@ public class ResolveElementCache( } } - val controlFlowTrace = DelegatingBindingTrace(trace.getBindingContext(), "Element control flow resolve", resolveElement) + val controlFlowTrace = DelegatingBindingTrace(trace.bindingContext, "Element control flow resolve", resolveElement) ControlFlowInformationProvider(resolveElement, controlFlowTrace).checkDeclaration() controlFlowTrace.addOwnDataTo(trace, null, false) - return Pair(trace.getBindingContext(), statementFilterUsed) + return Pair(trace.bindingContext, statementFilterUsed) } private fun packageRefAdditionalResolve(resolveSession: ResolveSession, ktElement: KtElement): BindingTrace { @@ -327,7 +327,7 @@ public class ResolveElementCache( val header = ktElement.getParentOfType(true)!! if (Name.isValidIdentifier(ktElement.getReferencedName())) { - if (trace.getBindingContext()[BindingContext.REFERENCE_TARGET, ktElement] == null) { + if (trace.bindingContext[BindingContext.REFERENCE_TARGET, ktElement] == null) { val fqName = header.getFqName(ktElement) val packageDescriptor = resolveSession.moduleDescriptor.getPackage(fqName) trace.record(BindingContext.REFERENCE_TARGET, ktElement, packageDescriptor) @@ -372,7 +372,7 @@ public class ResolveElementCache( if (fileAnnotationList != null) { doResolveAnnotations(resolveSession.getFileAnnotations(fileAnnotationList.getContainingKtFile())) } - if (modifierList != null && modifierList.getParent() is KtFile) { + if (modifierList != null && modifierList.parent is KtFile) { doResolveAnnotations(resolveSession.getDanglingAnnotations(modifierList.getContainingKtFile())) } } @@ -388,16 +388,16 @@ public class ResolveElementCache( var descriptor = resolveSession.resolveToDescriptor(declaration) if (declaration is KtClass) { if (modifierList == declaration.getPrimaryConstructorModifierList()) { - descriptor = (descriptor as ClassDescriptor).getUnsubstitutedPrimaryConstructor() + descriptor = (descriptor as ClassDescriptor).unsubstitutedPrimaryConstructor ?: error("No constructor found: ${declaration.getText()}") } } - if (declaration is KtClassOrObject && modifierList.getParent() == declaration.getBody() && descriptor is LazyClassDescriptor) { - return descriptor.getDanglingAnnotations() + if (declaration is KtClassOrObject && modifierList.parent == declaration.getBody() && descriptor is LazyClassDescriptor) { + return descriptor.danglingAnnotations } - return descriptor.getAnnotations() + return descriptor.annotations } private fun typeParameterAdditionalResolve(analyzer: KotlinCodeAnalyzer, typeParameter: KtTypeParameter): BindingTrace { @@ -412,15 +412,15 @@ public class ResolveElementCache( val descriptor = resolveSession.resolveToDescriptor(classOrObject) as LazyClassDescriptor // Activate resolving of supertypes - ForceResolveUtil.forceResolveAllContents(descriptor.getTypeConstructor().getSupertypes()) + ForceResolveUtil.forceResolveAllContents(descriptor.typeConstructor.supertypes) val bodyResolver = createBodyResolver(resolveSession, trace, file, StatementFilter.NONE) bodyResolver.resolveSuperTypeEntryList(DataFlowInfo.EMPTY, classOrObject, descriptor, - descriptor.getUnsubstitutedPrimaryConstructor(), + descriptor.unsubstitutedPrimaryConstructor, descriptor.scopeForConstructorHeaderResolution, - descriptor.getScopeForMemberDeclarationResolution()) + descriptor.scopeForMemberDeclarationResolution) return trace } @@ -433,7 +433,7 @@ public class ResolveElementCache( ForceResolveUtil.forceResolveAllContents(descriptor) val bodyResolveContext = BodyResolveContextForLazy(TopDownAnalysisMode.LocalDeclarations, { declaration -> - assert(declaration.getParent() == property || declaration == property) { + assert(declaration.parent == property || declaration == property) { "Must be called only for property accessors or for property, but called for $declaration" } resolveSession.declarationScopeProvider.getResolutionScopeForDeclaration(declaration) @@ -443,7 +443,7 @@ public class ResolveElementCache( forceResolveAnnotationsInside(property) - for (accessor in property.getAccessors()) { + for (accessor in property.accessors) { ControlFlowInformationProvider(accessor, trace).checkDeclaration() } @@ -485,7 +485,7 @@ public class ResolveElementCache( val scope = resolveSession.declarationScopeProvider.getResolutionScopeForDeclaration(klass) val classDescriptor = resolveSession.resolveToDescriptor(klass) as ClassDescriptor - val constructorDescriptor = classDescriptor.getUnsubstitutedPrimaryConstructor() + val constructorDescriptor = classDescriptor.unsubstitutedPrimaryConstructor ?: error("Can't get primary constructor for descriptor '$classDescriptor' in from class '${klass.getElementTextWithContext()}'") val bodyResolver = createBodyResolver(resolveSession, trace, file, StatementFilter.NONE) @@ -521,10 +521,10 @@ public class ResolveElementCache( file: KtFile, statementFilter: StatementFilter ): BodyResolver { - val globalContext = SimpleGlobalContext(resolveSession.storageManager, resolveSession.getExceptionTracker()) + val globalContext = SimpleGlobalContext(resolveSession.storageManager, resolveSession.exceptionTracker) val module = resolveSession.moduleDescriptor return createContainerForBodyResolve( - globalContext.withProject(file.getProject()).withModule(module), + globalContext.withProject(file.project).withModule(module), trace, targetPlatform, statementFilter @@ -534,7 +534,7 @@ public class ResolveElementCache( // All additional resolve should be done to separate trace private fun createDelegatingTrace(resolveElement: KtElement): BindingTrace { return resolveSession.storageManager.createSafeTrace( - DelegatingBindingTrace(resolveSession.getBindingContext(), "trace to resolve element", resolveElement)) + DelegatingBindingTrace(resolveSession.bindingContext, "trace to resolve element", resolveElement)) } private class BodyResolveContextForLazy( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionsFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionsFactory.kt index 50d16e7e558..e7baf3f8ffc 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionsFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionsFactory.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.psi.KtCodeFragment import org.jetbrains.kotlin.utils.singletonOrEmptyList -public abstract class KotlinIntentionActionsFactory { +abstract class KotlinIntentionActionsFactory { protected open fun isApplicableForCodeFragment(): Boolean = false protected abstract fun doCreateActions(diagnostic: Diagnostic): List @@ -29,17 +29,17 @@ public abstract class KotlinIntentionActionsFactory { protected open fun doCreateActionsForAllProblems( sameTypeDiagnostics: Collection): List = emptyList() - public fun createActions(diagnostic: Diagnostic): List = + fun createActions(diagnostic: Diagnostic): List = createActions(diagnostic.singletonOrEmptyList(), false) - public fun createActionsForAllProblems(sameTypeDiagnostics: Collection): List = + fun createActionsForAllProblems(sameTypeDiagnostics: Collection): List = createActions(sameTypeDiagnostics, true) private fun createActions(sameTypeDiagnostics: Collection, createForAll: Boolean): List { if (sameTypeDiagnostics.isEmpty()) return emptyList() val first = sameTypeDiagnostics.first() - if (first.psiElement.getContainingFile() is KtCodeFragment && !isApplicableForCodeFragment()) { + if (first.psiElement.containingFile is KtCodeFragment && !isApplicableForCodeFragment()) { return emptyList() } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt index bf7bf40dcff..f40cc55c578 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/KotlinSuppressIntentionAction.kt @@ -44,7 +44,7 @@ class KotlinSuppressIntentionAction private constructor( override fun getFamilyName() = KotlinBundle.message("suppress.warnings.family") override fun getText() = KotlinBundle.message("suppress.warning.for", suppressKey, kind.kind, kind.name) - override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) = element.isValid() + override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) = element.isValid override fun invoke(project: Project, editor: Editor?, element: PsiElement) { val id = "\"$suppressKey\"" @@ -88,7 +88,7 @@ class KotlinSuppressIntentionAction private constructor( } private fun suppressAtModifierListOwner(suppressAt: KtModifierListOwner, id: String) { - val modifierList = suppressAt.getModifierList() + val modifierList = suppressAt.modifierList val psiFactory = KtPsiFactory(suppressAt) if (modifierList == null) { // create a modifier list from scratch @@ -102,7 +102,7 @@ class KotlinSuppressIntentionAction private constructor( if (entry == null) { // no [suppress] annotation val newAnnotation = psiFactory.createAnnotationEntry(suppressAnnotationText(id)) - val addedAnnotation = modifierList.addBefore(newAnnotation, modifierList.getFirstChild()) + val addedAnnotation = modifierList.addBefore(newAnnotation, modifierList.firstChild) val whiteSpace = psiFactory.createWhiteSpace(kind) modifierList.addAfter(whiteSpace, addedAnnotation) } @@ -136,8 +136,8 @@ class KotlinSuppressIntentionAction private constructor( val copy = suppressAt.copy()!! val afterReplace = suppressAt.replace(annotatedExpression) as KtAnnotatedExpression - val toReplace = afterReplace.findElementAt(afterReplace.getTextLength() - 2)!! - assert (toReplace.getText() == placeholderText) + val toReplace = afterReplace.findElementAt(afterReplace.textLength - 2)!! + assert (toReplace.text == placeholderText) val result = toReplace.replace(copy)!! caretBox.positionCaretInCopy(result) @@ -145,19 +145,19 @@ class KotlinSuppressIntentionAction private constructor( private fun addArgumentToSuppressAnnotation(entry: KtAnnotationEntry, id: String) { // add new arguments to an existing entry - val args = entry.getValueArgumentList() + val args = entry.valueArgumentList val psiFactory = KtPsiFactory(entry) val newArgList = psiFactory.createCallArguments("($id)") if (args == null) { // new argument list - entry.addAfter(newArgList, entry.getLastChild()) + entry.addAfter(newArgList, entry.lastChild) } - else if (args.getArguments().isEmpty()) { + else if (args.arguments.isEmpty()) { // replace '()' with a new argument list args.replace(newArgList) } else { - args.addArgument(newArgList.getArguments()[0]) + args.addArgument(newArgList.arguments[0]) } } @@ -165,7 +165,7 @@ class KotlinSuppressIntentionAction private constructor( private fun findSuppressAnnotation(annotated: KtAnnotated): KtAnnotationEntry? { val context = annotated.analyze() - return findSuppressAnnotation(context, annotated.getAnnotationEntries()) + return findSuppressAnnotation(context, annotated.annotationEntries) } private fun findSuppressAnnotation(annotationList: KtFileAnnotationList): KtAnnotationEntry? { @@ -184,7 +184,7 @@ class KotlinSuppressIntentionAction private constructor( } } -public class AnnotationHostKind(val kind: String, val name: String, val newLineNeeded: Boolean) +class AnnotationHostKind(val kind: String, val name: String, val newLineNeeded: Boolean) private fun KtPsiFactory.createWhiteSpace(kind: AnnotationHostKind): PsiElement { return if (kind.newLineNeeded) createNewLine() else createWhiteSpace() @@ -194,10 +194,10 @@ private class CaretBox( val expression: E, private val editor: Editor? ) { - private val offsetInExpression: Int = (editor?.getCaretModel()?.getOffset() ?: 0) - expression.getTextRange()!!.getStartOffset() + private val offsetInExpression: Int = (editor?.caretModel?.offset ?: 0) - expression.textRange!!.startOffset fun positionCaretInCopy(copy: PsiElement) { if (editor == null) return - editor.getCaretModel().moveToOffset(copy.getTextOffset() + offsetInExpression) + editor.caretModel.moveToOffset(copy.textOffset + offsetInExpression) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt index 46b572db3c0..40ca2e360c3 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt @@ -24,7 +24,7 @@ import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.extensions.Extensions import org.jetbrains.kotlin.diagnostics.DiagnosticFactory -public class QuickFixes { +class QuickFixes { private val factories: Multimap, KotlinIntentionActionsFactory> = HashMultimap.create, KotlinIntentionActionsFactory>() private val actions: Multimap, IntentionAction> = HashMultimap.create, IntentionAction>() @@ -32,32 +32,32 @@ public class QuickFixes { Extensions.getExtensions(QuickFixContributor.EP_NAME).forEach { it.registerQuickFixes(this) } } - public fun register(diagnosticFactory: DiagnosticFactory<*>, vararg factory: KotlinIntentionActionsFactory) { + fun register(diagnosticFactory: DiagnosticFactory<*>, vararg factory: KotlinIntentionActionsFactory) { factories.putAll(diagnosticFactory, factory.toList()) } - public fun register(diagnosticFactory: DiagnosticFactory<*>, vararg action: IntentionAction) { + fun register(diagnosticFactory: DiagnosticFactory<*>, vararg action: IntentionAction) { actions.putAll(diagnosticFactory, action.toList()) } - public fun getActionFactories(diagnosticFactory: DiagnosticFactory<*>): Collection { + fun getActionFactories(diagnosticFactory: DiagnosticFactory<*>): Collection { return factories.get(diagnosticFactory) } - public fun getActions(diagnosticFactory: DiagnosticFactory<*>): Collection { + fun getActions(diagnosticFactory: DiagnosticFactory<*>): Collection { return actions.get(diagnosticFactory) } - public fun getDiagnostics(factory: KotlinIntentionActionsFactory): Collection> { + fun getDiagnostics(factory: KotlinIntentionActionsFactory): Collection> { return factories.keySet().filter { factory in factories.get(it) } } companion object { - public fun getInstance(): QuickFixes = ServiceManager.getService(QuickFixes::class.java) + fun getInstance(): QuickFixes = ServiceManager.getService(QuickFixes::class.java) } } -public interface QuickFixContributor { +interface QuickFixContributor { companion object { val EP_NAME: ExtensionPointName = ExtensionPointName.create("org.jetbrains.kotlin.quickFixContributor") } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/generateUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/generateUtil.kt index 3b45ef1f11e..9d04a24eb56 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/generateUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/generateUtil.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.utils.ifEmpty -public fun moveCaretIntoGeneratedElement(editor: Editor, element: PsiElement) { +fun moveCaretIntoGeneratedElement(editor: Editor, element: PsiElement) { val project = element.project val pointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(element) @@ -47,22 +47,22 @@ private fun moveCaretIntoGeneratedElementDocumentUnblocked(editor: Editor, eleme // Inspired by GenerateMembersUtils.positionCaret() if (element is KtDeclarationWithBody && element.hasBody()) { - val expression = element.getBodyExpression() + val expression = element.bodyExpression if (expression is KtBlockExpression) { - val lBrace = expression.getLBrace() - val rBrace = expression.getRBrace() + val lBrace = expression.lBrace + val rBrace = expression.rBrace if (lBrace != null && rBrace != null) { val firstInBlock = lBrace.siblings(forward = true, withItself = false).first { it !is PsiWhiteSpace } val lastInBlock = rBrace.siblings(forward = false, withItself = false).first { it !is PsiWhiteSpace } - val start = firstInBlock.getTextRange()!!.getStartOffset() - val end = lastInBlock.getTextRange()!!.getEndOffset() + val start = firstInBlock.textRange!!.startOffset + val end = lastInBlock.textRange!!.endOffset editor.moveCaret(Math.min(start, end)) if (start < end) { - editor.getSelectionModel().setSelection(start, end) + editor.selectionModel.setSelection(start, end) } return true @@ -71,24 +71,24 @@ private fun moveCaretIntoGeneratedElementDocumentUnblocked(editor: Editor, eleme } if (element is KtWithExpressionInitializer && element.hasInitializer()) { - val expression = element.getInitializer() + val expression = element.initializer if (expression == null) throw AssertionError() - val initializerRange = expression.getTextRange() + val initializerRange = expression.textRange - val offset = initializerRange?.getStartOffset() ?: element.getTextOffset() + val offset = initializerRange?.startOffset ?: element.getTextOffset() editor.moveCaret(offset) if (initializerRange != null) { - editor.getSelectionModel().setSelection(initializerRange.getStartOffset(), initializerRange.getEndOffset()) + editor.selectionModel.setSelection(initializerRange.startOffset, initializerRange.endOffset) } return true } if (element is KtProperty) { - for (accessor in element.getAccessors()) { + for (accessor in element.accessors) { if (moveCaretIntoGeneratedElementDocumentUnblocked(editor, accessor)) { return true } @@ -98,9 +98,9 @@ private fun moveCaretIntoGeneratedElementDocumentUnblocked(editor: Editor, eleme return false } -public fun Editor.moveCaret(offset: Int, scrollType: ScrollType = ScrollType.RELATIVE) { - getCaretModel().moveToOffset(offset) - getScrollingModel().scrollToCaret(scrollType) +fun Editor.moveCaret(offset: Int, scrollType: ScrollType = ScrollType.RELATIVE) { + caretModel.moveToOffset(offset) + scrollingModel.scrollToCaret(scrollType) } private fun findInsertAfterAnchor(editor: Editor?, body: KtClassBody): PsiElement? { @@ -145,7 +145,7 @@ private fun removeAfterOffset(offset: Int, whiteSpace: PsiWhiteSpace): PsiElemen return whiteSpace } -public fun insertMembersAfter( +fun insertMembersAfter( editor: Editor?, classOrObject: KtClassOrObject, members: Collection, @@ -201,6 +201,6 @@ public fun insertMembersAfter( } } -public fun insertMember(editor: Editor, classOrObject: KtClassOrObject, declaration: T): T { +fun insertMember(editor: Editor, classOrObject: KtClassOrObject, declaration: T): T { return insertMembersAfter(editor, classOrObject, listOf(declaration)).single() } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/refactoring/fqName/fqNameUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/refactoring/fqName/fqNameUtil.kt index 0e09f9f2d47..e0e496a0fc4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/refactoring/fqName/fqNameUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/refactoring/fqName/fqNameUtil.kt @@ -28,30 +28,30 @@ import org.jetbrains.kotlin.resolve.ImportPath /** * Returns FqName for given declaration (either Java or Kotlin) */ -public fun PsiElement.getKotlinFqName(): FqName? { +fun PsiElement.getKotlinFqName(): FqName? { val element = namedUnwrappedElement return when (element) { - is PsiPackage -> FqName(element.getQualifiedName()) - is PsiClass -> element.getQualifiedName()?.let { FqName(it) } + is PsiPackage -> FqName(element.qualifiedName) + is PsiClass -> element.qualifiedName?.let { FqName(it) } is PsiMember -> element.getName()?.let { name -> - val prefix = element.getContainingClass()?.getQualifiedName() + val prefix = element.containingClass?.qualifiedName FqName(if (prefix != null) "$prefix.$name" else name) } - is KtNamedDeclaration -> element.getFqName() + is KtNamedDeclaration -> element.fqName else -> null } } -public fun FqName.isImported(importPath: ImportPath, skipAliasedImports: Boolean = true): Boolean { +fun FqName.isImported(importPath: ImportPath, skipAliasedImports: Boolean = true): Boolean { return when { skipAliasedImports && importPath.hasAlias() -> false - importPath.isAllUnder() && !isRoot() -> importPath.fqnPart() == this.parent() + importPath.isAllUnder && !isRoot -> importPath.fqnPart() == this.parent() else -> importPath.fqnPart() == this } } -public fun ImportPath.isImported(alreadyImported: ImportPath): Boolean { - return if (isAllUnder() || hasAlias()) this == alreadyImported else fqnPart().isImported(alreadyImported) +fun ImportPath.isImported(alreadyImported: ImportPath): Boolean { + return if (isAllUnder || hasAlias()) this == alreadyImported else fqnPart().isImported(alreadyImported) } -public fun ImportPath.isImported(imports: Iterable): Boolean = imports.any { isImported(it) } +fun ImportPath.isImported(imports: Iterable): Boolean = imports.any { isImported(it) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KotlinReferenceContributor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KotlinReferenceContributor.kt index 79c3151fd91..ccae65e5175 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KotlinReferenceContributor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KotlinReferenceContributor.kt @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocName import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -public class KotlinReferenceContributor() : PsiReferenceContributor() { - public override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { +class KotlinReferenceContributor() : PsiReferenceContributor() { + override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { with(registrar) { registerProvider(KtSimpleNameExpression::class.java) { KtSimpleNameReference(it) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt index 65a9fd7911f..ce3d7a41909 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtDestructuringDeclarationReference.kt @@ -27,21 +27,21 @@ import org.jetbrains.kotlin.resolve.BindingContext class KtDestructuringDeclarationReference(element: KtDestructuringDeclaration) : KtMultiReference(element) { override fun getTargetDescriptors(context: BindingContext): Collection { - return expression.getEntries().mapNotNull { entry -> - context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry)?.getCandidateDescriptor() + return expression.entries.mapNotNull { entry -> + context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry)?.candidateDescriptor } } override fun getRangeInElement(): TextRange? { - val start = expression.getLPar() - val end = expression.getRPar() + val start = expression.lPar + val end = expression.rPar if (start == null || end == null) return TextRange.EMPTY_RANGE - return TextRange(start.getStartOffsetInParent(), end.getStartOffsetInParent()) + return TextRange(start.startOffsetInParent, end.startOffsetInParent) } override fun canRename(): Boolean { val bindingContext = expression.analyze() //TODO: should it use full body resolve? - return resolveToDescriptors(bindingContext).all { it is CallableMemberDescriptor && it.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED} + return resolveToDescriptors(bindingContext).all { it is CallableMemberDescriptor && it.kind == CallableMemberDescriptor.Kind.SYNTHESIZED} } override fun handleElementRename(newElementName: String?): PsiElement? { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt index 679c43c2ca4..11f8dc42fba 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtForLoopInReference.kt @@ -22,23 +22,23 @@ import org.jetbrains.kotlin.psi.KtForExpression import org.jetbrains.kotlin.resolve.BindingContext import java.util.* -public class KtForLoopInReference(element: KtForExpression) : KtMultiReference(element) { +class KtForLoopInReference(element: KtForExpression) : KtMultiReference(element) { override fun getRangeInElement(): TextRange { - val inKeywordNode = expression.getInKeywordNode() + val inKeywordNode = expression.inKeywordNode if (inKeywordNode == null) return TextRange.EMPTY_RANGE - val offset = inKeywordNode.getPsi()!!.getStartOffsetInParent() - return TextRange(offset, offset + inKeywordNode.getTextLength()) + val offset = inKeywordNode.psi!!.startOffsetInParent + return TextRange(offset, offset + inKeywordNode.textLength) } override fun getTargetDescriptors(context: BindingContext): Collection { - val loopRange = expression.getLoopRange() + val loopRange = expression.loopRange if (loopRange == null) { return Collections.emptyList() } - return LOOP_RANGE_KEYS.mapNotNull { key -> context.get(key, loopRange)?.getCandidateDescriptor() } + return LOOP_RANGE_KEYS.mapNotNull { key -> context.get(key, loopRange)?.candidateDescriptor } } companion object { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt index 8a318208b7d..a10d2121d82 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtPropertyDelegationMethodsReference.kt @@ -25,12 +25,12 @@ import org.jetbrains.kotlin.resolve.BindingContext import java.util.Collections import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -public class KtPropertyDelegationMethodsReference(element: KtPropertyDelegate) : KtMultiReference(element) { +class KtPropertyDelegationMethodsReference(element: KtPropertyDelegate) : KtMultiReference(element) { override fun getRangeInElement(): TextRange { - val byKeywordNode = expression.getByKeywordNode() - val offset = byKeywordNode.getPsi()!!.getStartOffsetInParent() - return TextRange(offset, offset + byKeywordNode.getTextLength()) + val byKeywordNode = expression.byKeywordNode + val offset = byKeywordNode.psi!!.startOffsetInParent + return TextRange(offset, offset + byKeywordNode.textLength) } override fun getTargetDescriptors(context: BindingContext): Collection { @@ -42,9 +42,9 @@ public class KtPropertyDelegationMethodsReference(element: KtPropertyDelegate) : if (descriptor !is PropertyDescriptor) { return Collections.emptyList() } - return (descriptor.getAccessors().mapNotNull { + return (descriptor.accessors.mapNotNull { accessor -> - context.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, accessor)?.getCandidateDescriptor() - } + listOfNotNull(context.get(BindingContext.DELEGATED_PROPERTY_PD_RESOLVED_CALL, descriptor)?.getCandidateDescriptor())) + context.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, accessor)?.candidateDescriptor + } + listOfNotNull(context.get(BindingContext.DELEGATED_PROPERTY_PD_RESOLVED_CALL, descriptor)?.candidateDescriptor)) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtReference.kt index c91e0351e68..a278167e67a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtReference.kt @@ -30,17 +30,17 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* -public interface KtReference : PsiPolyVariantReference { +interface KtReference : PsiPolyVariantReference { fun resolveToDescriptors(bindingContext: BindingContext): Collection override fun getElement(): KtElement } -public abstract class AbstractKtReference(element: T) +abstract class AbstractKtReference(element: T) : PsiPolyVariantReferenceBase(element), KtReference { - public val expression: T - get() = getElement() + val expression: T + get() = element override fun multiResolve(incompleteCode: Boolean): Array { return PsiElementResolveResult.createResults(resolveToPsiElements()) @@ -60,7 +60,7 @@ public abstract class AbstractKtReference(element: T) override fun getCanonicalText(): String = "" - public open fun canRename(): Boolean = false + open fun canRename(): Boolean = false override fun handleElementRename(newElementName: String?): PsiElement? = throw IncorrectOperationException() override fun bindToElement(element: PsiElement): PsiElement = throw IncorrectOperationException() @@ -94,12 +94,12 @@ public abstract class AbstractKtReference(element: T) private fun resolveToPsiElements(targetDescriptor: DeclarationDescriptor): Collection { if (targetDescriptor is PackageViewDescriptor) { - val psiFacade = JavaPsiFacade.getInstance(expression.getProject()) + val psiFacade = JavaPsiFacade.getInstance(expression.project) val fqName = targetDescriptor.fqName.asString() return psiFacade.findPackage(fqName).singletonOrEmptyList() } else { - return DescriptorToSourceUtilsIde.getAllDeclarations(expression.getProject(), targetDescriptor) + return DescriptorToSourceUtilsIde.getAllDeclarations(expression.project, targetDescriptor) } } @@ -117,11 +117,11 @@ public abstract class AbstractKtReference(element: T) return context[BindingContext.AMBIGUOUS_LABEL_TARGET, reference] } - override fun toString() = javaClass.getSimpleName() + ": " + expression.getText() + override fun toString() = javaClass.simpleName + ": " + expression.text } -public abstract class KtSimpleReference(expression: T) : AbstractKtReference(expression) { +abstract class KtSimpleReference(expression: T) : AbstractKtReference(expression) { override fun getTargetDescriptors(context: BindingContext) = expression.getReferenceTargets(context) } -public abstract class KtMultiReference(expression: T) : AbstractKtReference(expression) +abstract class KtMultiReference(expression: T) : AbstractKtReference(expression) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt index 889689b11de..e7aa1e0653b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt @@ -84,13 +84,13 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere } override fun getRangeInElement(): TextRange { - val element = getElement().getReferencedNameElement() + val element = element.getReferencedNameElement() val startOffset = getElement().startOffset - return element.getTextRange().shiftRight(-startOffset) + return element.textRange.shiftRight(-startOffset) } override fun canRename(): Boolean { - if (expression.getParentOfTypeAndBranch(strict = true){ getOperationReference() } != null) return false + if (expression.getParentOfTypeAndBranch(strict = true){ operationReference } != null) return false val elementType = expression.getReferencedNameElementType() if (elementType == KtTokens.PLUSPLUS || elementType == KtTokens.MINUSMINUS) return false @@ -103,7 +103,7 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere if (newElementName == null) return expression; // Do not rename if the reference corresponds to synthesized component function - val expressionText = expression.getText() + val expressionText = expression.text if (expressionText != null && Name.isValidIdentifier(expressionText)) { if (isComponentLike(Name.identifier(expressionText)) && resolve() is KtParameter) { return expression @@ -111,16 +111,16 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere } val psiFactory = KtPsiFactory(expression) - val element = Extensions.getArea(expression.getProject()).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).extensions + val element = Extensions.getArea(expression.project).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).extensions .asSequence() .map { it.handleElementRename(this, psiFactory, newElementName) } .firstOrNull { it != null } ?: psiFactory.createNameIdentifier(newElementName) val nameElement = expression.getReferencedNameElement() - val elementType = nameElement.getNode().getElementType() + val elementType = nameElement.node.elementType if (elementType is KtToken && OperatorConventions.getNameForOperationSymbol(elementType) != null) { - val opExpression = expression.getParent() as? KtOperationExpression + val opExpression = expression.parent as? KtOperationExpression if (opExpression != null) { val (newExpression, newNameElement) = OperatorToFunctionIntention.convert(opExpression) newNameElement.replace(element) @@ -132,7 +132,7 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere return expression } - public enum class ShorteningMode { + enum class ShorteningMode { NO_SHORTENING, DELAYED_SHORTENING, FORCED_SHORTENING @@ -178,13 +178,13 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere * Note that FqName may not be empty */ private fun KtNameReferenceExpression.changeQualifiedName(fqName: FqName): KtElement { - assert(!fqName.isRoot()) { "Can't set empty FqName for element $this" } + assert(!fqName.isRoot) { "Can't set empty FqName for element $this" } val shortName = fqName.shortName().render() val psiFactory = KtPsiFactory(this) - val fqNameBase = (getParent() as? KtCallExpression)?.let { parent -> + val fqNameBase = (parent as? KtCallExpression)?.let { parent -> val callCopy = parent.copy() as KtCallExpression - callCopy.getCalleeExpression()!!.replace(psiFactory.createSimpleName(shortName)).getParent()!!.getText() + callCopy.calleeExpression!!.replace(psiFactory.createSimpleName(shortName)).parent!!.text } ?: shortName val text = if (!fqName.isOneSegmentFQN()) "${fqName.parent().render()}.$fqNameBase" else fqNameBase @@ -192,12 +192,12 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere val elementToReplace = getQualifiedElement() return when (elementToReplace) { is KtUserType -> { - val typeText = "$text${elementToReplace.getTypeArgumentList()?.getText() ?: ""}" + val typeText = "$text${elementToReplace.typeArgumentList?.text ?: ""}" elementToReplace.replace(psiFactory.createType(typeText).typeElement!!) } else -> elementToReplace.replace(psiFactory.createExpression(text)) } as KtElement } - override fun getCanonicalText(): String = expression.getText() + override fun getCanonicalText(): String = expression.text } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index 5a802922557..53df839507c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -47,7 +47,7 @@ sealed class SyntheticPropertyAccessorReference(expression: KtNameReferenceExpre return result } - override fun getRangeInElement() = TextRange(0, expression.getTextLength()) + override fun getRangeInElement() = TextRange(0, expression.textLength) override fun canRename() = true @@ -65,11 +65,11 @@ sealed class SyntheticPropertyAccessorReference(expression: KtNameReferenceExpre } if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method - val nameIdentifier = KtPsiFactory(expression).createNameIdentifier(newName.getIdentifier()) + val nameIdentifier = KtPsiFactory(expression).createNameIdentifier(newName.identifier) expression.getReferencedNameElement().replace(nameIdentifier) return expression } - public class Getter(expression: KtNameReferenceExpression) : SyntheticPropertyAccessorReference(expression, true) - public class Setter(expression: KtNameReferenceExpression) : SyntheticPropertyAccessorReference(expression, false) + class Getter(expression: KtNameReferenceExpression) : SyntheticPropertyAccessorReference(expression, true) + class Setter(expression: KtNameReferenceExpression) : SyntheticPropertyAccessorReference(expression, false) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt index adc0d4536f4..3abbe032cab 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt @@ -44,10 +44,10 @@ import java.util.* // Navigation element of the resolved reference // For property accessor return enclosing property -public val PsiReference.unwrappedTargets: Set +val PsiReference.unwrappedTargets: Set get() { fun PsiElement.adjust(): PsiElement? { - val target = unwrapped?.getOriginalElement() + val target = unwrapped?.originalElement return when { target is KtPropertyAccessor -> target.getNonStrictParentOfType() else -> target @@ -55,22 +55,22 @@ public val PsiReference.unwrappedTargets: Set } return when (this) { - is PsiPolyVariantReference -> multiResolve(false).mapNotNullTo(HashSet()) { it.getElement()?.adjust() } + is PsiPolyVariantReference -> multiResolve(false).mapNotNullTo(HashSet()) { it.element?.adjust() } else -> emptyOrSingletonList(resolve()?.adjust()).toSet() } } // -public fun PsiReference.canBeReferenceTo(candidateTarget: PsiElement): Boolean { +fun PsiReference.canBeReferenceTo(candidateTarget: PsiElement): Boolean { // optimization - return getElement().getContainingFile() == candidateTarget.getContainingFile() - || ProjectRootsUtil.isInProjectOrLibSource(getElement()) + return element.containingFile == candidateTarget.containingFile + || ProjectRootsUtil.isInProjectOrLibSource(element) } -public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean { +fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean { if (!canBeReferenceTo(candidateTarget)) return false - val unwrappedCandidate = candidateTarget.unwrapped?.getOriginalElement() ?: return false + val unwrappedCandidate = candidateTarget.unwrapped?.originalElement ?: return false // Optimizations when (this) { @@ -95,7 +95,7 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean { } // TODO: Workaround for Kotlin constructor search in Java code. To be removed after refactoring of the search API else if (this is PsiJavaCodeReferenceElement && unwrappedCandidate is KtConstructor<*>) { - var parent = getElement().getParent() + var parent = getElement().parent if (parent is PsiAnonymousClass) { parent = parent.getParent() } @@ -104,10 +104,10 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean { if (this is PsiJavaCodeReferenceElement && candidateTarget is KtObjectDeclaration && unwrappedTargets.size == 1) { val referredClass = unwrappedTargets.first() if (referredClass is KtClass && candidateTarget in referredClass.getCompanionObjects()) { - if (getParent() is PsiImportStaticStatement) return true + if (parent is PsiImportStaticStatement) return true - return getParent().getReference()?.unwrappedTargets?.any { - (it is KtProperty || it is KtNamedFunction) && it.getParent()?.getParent() == candidateTarget + return parent.reference?.unwrappedTargets?.any { + (it is KtProperty || it is KtNamedFunction) && it.parent?.parent == candidateTarget } ?: false } } @@ -116,8 +116,8 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean { private fun PsiElement.isConstructorOf(unwrappedCandidate: PsiElement) = // call to Java constructor - (this is PsiMethod && isConstructor() && getContainingClass() == unwrappedCandidate) || - // call to Kotlin constructor + (this is PsiMethod && isConstructor && containingClass == unwrappedCandidate) || + // call to Kotlin constructor (this is KtConstructor<*> && getContainingClassOrObject() == unwrappedCandidate) fun AbstractKtReference.renameImplicitConventionalCall(newName: String?): KtExpression { @@ -129,30 +129,30 @@ fun AbstractKtReference.renameImplicitConventionalCall(newName } val KtSimpleNameExpression.mainReference: KtSimpleNameReference - get() = getReferences().firstIsInstance() + get() = references.firstIsInstance() val KtReferenceExpression.mainReference: KtReference - get() = if (this is KtSimpleNameExpression) mainReference else getReferences().firstIsInstance() + get() = if (this is KtSimpleNameExpression) mainReference else references.firstIsInstance() val KDocName.mainReference: KDocReference - get() = getReferences().firstIsInstance() + get() = references.firstIsInstance() val KtElement.mainReference: KtReference? get() { return when { this is KtReferenceExpression -> mainReference this is KDocName -> mainReference - else -> getReferences().firstIsInstanceOrNull() + else -> references.firstIsInstanceOrNull() } } // ----------- Read/write access ----------------------------------------------------------------------------------------------------------------------- -public enum class ReferenceAccess(val isRead: Boolean, val isWrite: Boolean) { +enum class ReferenceAccess(val isRead: Boolean, val isWrite: Boolean) { READ(true, false), WRITE(false, true), READ_WRITE(true, true) } -public fun KtExpression.readWriteAccess(useResolveForReadWrite: Boolean): ReferenceAccess { +fun KtExpression.readWriteAccess(useResolveForReadWrite: Boolean): ReferenceAccess { var expression = getQualifiedExpressionForSelectorOrThis() loop@ while (true) { val parent = expression.parent @@ -187,7 +187,7 @@ public fun KtExpression.readWriteAccess(useResolveForReadWrite: Boolean): Refere ReferenceAccess.READ } -public fun KtReference.canBeResolvedViaImport(target: DeclarationDescriptor): Boolean { +fun KtReference.canBeResolvedViaImport(target: DeclarationDescriptor): Boolean { if (!target.canBeReferencedViaImport()) return false if (target.isExtension) return true // assume that any type of reference can use imports when resolved to extension val referenceExpression = this.element as? KtNameReferenceExpression ?: return false diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/KotlinIndexPatternBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/KotlinIndexPatternBuilder.kt index 81841ea4ac4..97f960a80ad 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/KotlinIndexPatternBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/KotlinIndexPatternBuilder.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.lexer.KotlinLexer import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtFile -public class KotlinIndexPatternBuilder: IndexPatternBuilder { +class KotlinIndexPatternBuilder: IndexPatternBuilder { private val TODO_COMMENT_TOKENS = TokenSet.orSet(KtTokens.COMMENTS, TokenSet.create(KDocTokens.KDOC)) override fun getCommentTokenSet(file: PsiFile): TokenSet? { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/classInheritorsSearch.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/classInheritorsSearch.kt index 638f29d1e1b..478e1b873cc 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/classInheritorsSearch.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/classInheritorsSearch.kt @@ -26,7 +26,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.search.searches.ClassInheritorsSearch import com.intellij.util.EmptyQuery -public fun HierarchySearchRequest<*>.searchInheritors(): Query { +fun HierarchySearchRequest<*>.searchInheritors(): Query { val psiClass: PsiClass? = when (originalElement) { is KtClassOrObject -> LightClassUtil.getPsiClass(originalElement) is PsiClass -> originalElement diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt index fbf3d0b10ce..4d8f582cac7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/declarationSearchUtil.kt @@ -34,9 +34,9 @@ interface DeclarationSearchRequest { val searchScope: SearchScope } -public interface SearchRequestWithElement : DeclarationSearchRequest { +interface SearchRequestWithElement : DeclarationSearchRequest { val originalElement: T - override val project: Project get() = originalElement.getProject() + override val project: Project get() = originalElement.project } abstract class DeclarationsSearch>: QueryFactory() { @@ -56,7 +56,7 @@ abstract class DeclarationsSearch> fun search(request: R): Query = if (isApplicable(request)) createUniqueResultsQuery(request) else EmptyQuery.getEmptyQuery() } -public class HierarchySearchRequest ( +class HierarchySearchRequest ( override val originalElement: T, override val searchScope: SearchScope, val searchDeeply: Boolean = true @@ -110,7 +110,7 @@ abstract class HierarchySearch( protected abstract fun doSearchDirect(request: HierarchySearchRequest, consumer: Processor) - protected override fun doSearch(request: HierarchySearchRequest, consumer: Processor) { + override fun doSearch(request: HierarchySearchRequest, consumer: Processor) { if (request.searchDeeply) { doSearchAll(request, consumer) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt index 1f23e56f904..2644e88a114 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/declarationsSearch/overridersSearch.kt @@ -38,7 +38,7 @@ fun PsiElement.isOverridableElement(): Boolean = when (this) { else -> false } -public fun HierarchySearchRequest<*>.searchOverriders(): Query { +fun HierarchySearchRequest<*>.searchOverriders(): Query { val psiMethods = runReadAction { originalElement.toLightMethods() } if (psiMethods.isEmpty()) return EmptyQuery.getEmptyQuery() @@ -47,17 +47,17 @@ public fun HierarchySearchRequest<*>.searchOverriders(): Query { .reduce { query1, query2 -> MergeQuery(query1, query2)} } -public object KotlinPsiMethodOverridersSearch : HierarchySearch(PsiMethodOverridingHierarchyTraverser) { +object KotlinPsiMethodOverridersSearch : HierarchySearch(PsiMethodOverridingHierarchyTraverser) { fun searchDirectOverriders(psiMethod: PsiMethod): Iterable { fun PsiMethod.isAcceptable(inheritor: PsiClass, baseMethod: PsiMethod, baseClass: PsiClass): Boolean = when { hasModifierProperty(PsiModifier.STATIC) -> false baseMethod.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) -> - JavaPsiFacade.getInstance(getProject()).arePackagesTheSame(baseClass, inheritor) + JavaPsiFacade.getInstance(project).arePackagesTheSame(baseClass, inheritor) else -> true } - val psiClass = psiMethod.getContainingClass() + val psiClass = psiMethod.containingClass if (psiClass == null) return Collections.emptyList() val classToMethod = HashMap() @@ -65,7 +65,7 @@ public object KotlinPsiMethodOverridersSearch : HierarchySearch(PsiMe override fun nextElements(current: PsiClass): Iterable = DirectClassInheritorsSearch.search( current, - current.getProject().allScope(), + current.project.allScope(), /* checkInheritance = */ true, /* includeAnonymous = */ true ) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReadWriteAccessDetector.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReadWriteAccessDetector.kt index 3c53993dd68..2e31c9fc5f6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReadWriteAccessDetector.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReadWriteAccessDetector.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType -public class KotlinReadWriteAccessDetector : ReadWriteAccessDetector() { +class KotlinReadWriteAccessDetector : ReadWriteAccessDetector() { override fun isReadWriteAccessible(element: PsiElement) = element is KtVariableDeclaration || element is KtParameter override fun isDeclarationWriteAccess(element: PsiElement) = isReadWriteAccessible(element) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt index a5d96ce662f..da02b8df637 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt @@ -47,7 +47,7 @@ data class KotlinReferencesSearchOptions(val acceptCallableOverrides: Boolean = } } -public class KotlinReferencesSearchParameters(elementToSearch: PsiElement, +class KotlinReferencesSearchParameters(elementToSearch: PsiElement, scope: SearchScope = runReadAction { elementToSearch.project.allScope() }, ignoreAccessScope: Boolean = false, optimizer: SearchRequestCollector? = null, @@ -55,10 +55,10 @@ public class KotlinReferencesSearchParameters(elementToSearch: PsiElement, : ReferencesSearch.SearchParameters(elementToSearch, scope, ignoreAccessScope, optimizer) { } -public class KotlinReferencesSearcher : QueryExecutorBase() { +class KotlinReferencesSearcher : QueryExecutorBase() { override fun processQuery(queryParameters: ReferencesSearch.SearchParameters, consumer: Processor) { - val element = queryParameters.getElementToSearch() + val element = queryParameters.elementToSearch val unwrappedElement = element.namedUnwrappedElement ?: return @@ -171,8 +171,8 @@ public class KotlinReferencesSearcher : QueryExecutorBase processKtClassOrObject(element, queryParameters) is KtNamedFunction, is KtSecondaryConstructor -> { val function = element as KtFunction - val name = runReadAction { function.getName() } + val name = runReadAction { function.name } if (name != null) { val methods = runReadAction { LightClassUtil.getLightClassMethods(function) } for (method in methods) { @@ -304,22 +304,22 @@ public class KotlinReferencesSearcher : QueryExecutorBase GlobalSearchScope.getScopeRestrictedByFileTypes(this, KotlinFileType.INSTANCE) is LocalSearchScope -> { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt index 5ffbb378215..1625e749132 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike import org.jetbrains.kotlin.types.expressions.OperatorConventions.* import org.jetbrains.kotlin.util.OperatorNameConventions -public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet = ImmutableSet +val ALL_SEARCHABLE_OPERATIONS: ImmutableSet = ImmutableSet .builder() .addAll(UNARY_OPERATION_NAMES.keys) .addAll(BINARY_OPERATION_NAMES.keys) @@ -38,15 +38,15 @@ public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet = ImmutableSet .add(KtTokens.BY_KEYWORD) .build() -public val INDEXING_OPERATION_NAMES = setOf(OperatorNameConventions.GET, OperatorNameConventions.SET) +val INDEXING_OPERATION_NAMES = setOf(OperatorNameConventions.GET, OperatorNameConventions.SET) -public val DELEGATE_ACCESSOR_NAMES = setOf(Name.identifier("getValue"), Name.identifier("setValue")) +val DELEGATE_ACCESSOR_NAMES = setOf(Name.identifier("getValue"), Name.identifier("setValue")) -public val IN_OPERATIONS_TO_SEARCH = setOf(KtTokens.IN_KEYWORD) +val IN_OPERATIONS_TO_SEARCH = setOf(KtTokens.IN_KEYWORD) -public val COMPARISON_OPERATIONS_TO_SEARCH = setOf(KtTokens.LT, KtTokens.GT) +val COMPARISON_OPERATIONS_TO_SEARCH = setOf(KtTokens.LT, KtTokens.GT) -public fun Name.getOperationSymbolsToSearch(): Set { +fun Name.getOperationSymbolsToSearch(): Set { when (this) { OperatorNameConventions.COMPARE_TO -> return COMPARISON_OPERATIONS_TO_SEARCH OperatorNameConventions.EQUALS -> return EQUALS_OPERATIONS diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt index afe00b90fb0..eabd3c3dc67 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt @@ -36,8 +36,8 @@ fun PsiNamedElement.getAccessorNames(readable: Boolean = true, writable: Boolean val setter = setter val result = ArrayList() - if (readable && getter != null) result.add(getter.getName()) - if (writable && setter != null) result.add(setter.getName()) + if (readable && getter != null) result.add(getter.name) + if (writable && setter != null) result.add(setter.name) return result } @@ -55,25 +55,25 @@ fun PsiNamedElement.getAccessorNames(readable: Boolean = true, writable: Boolean return Collections.emptyList() } -public fun PsiNamedElement.getClassNameForCompanionObject(): String? { +fun PsiNamedElement.getClassNameForCompanionObject(): String? { return if (this is KtObjectDeclaration && this.isCompanion()) { - getNonStrictParentOfType()?.getName() + getNonStrictParentOfType()?.name } else { null } } -public fun PsiNamedElement.getSpecialNamesToSearch(): List { - val name = getName() +fun PsiNamedElement.getSpecialNamesToSearch(): List { + val name = name return when { name == null || !Name.isValidIdentifier(name) -> Collections.emptyList() this is KtParameter -> { val componentFunctionName = this.dataClassComponentFunction()?.name if (componentFunctionName == null) return Collections.emptyList() - return listOf(componentFunctionName.asString(), KtTokens.LPAR.getValue()) + return listOf(componentFunctionName.asString(), KtTokens.LPAR.value) } - else -> Name.identifier(name).getOperationSymbolsToSearch().map { (it as KtSingleValueToken).getValue() } + else -> Name.identifier(name).getOperationSymbolsToSearch().map { (it as KtSingleValueToken).value } } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt index f04c862b57f..231c510f98a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt @@ -47,7 +47,7 @@ val KtDeclaration.constructor: ConstructorDescriptor? get() { val context = this.analyze() return when (this) { - is KtClassOrObject -> context[BindingContext.CLASS, this]?.getUnsubstitutedPrimaryConstructor() + is KtClassOrObject -> context[BindingContext.CLASS, this]?.unsubstitutedPrimaryConstructor is KtFunction -> context[BindingContext.CONSTRUCTOR, this] else -> null } @@ -70,12 +70,12 @@ fun PsiReference.checkUsageVsOriginalDescriptor( } fun PsiReference.isImportUsage(): Boolean = - getElement()!!.getNonStrictParentOfType() != null + element!!.getNonStrictParentOfType() != null -fun PsiReference.isConstructorUsage(ktClassOrObject: KtClassOrObject): Boolean = with (getElement()!!) { +fun PsiReference.isConstructorUsage(ktClassOrObject: KtClassOrObject): Boolean = with (element!!) { fun checkJavaUsage(): Boolean { val call = getNonStrictParentOfType() - return call == getParent() && call?.resolveConstructor()?.getContainingClass()?.getNavigationElement() == ktClassOrObject + return call == parent && call?.resolveConstructor()?.containingClass?.navigationElement == ktClassOrObject } fun checkKotlinUsage(): Boolean { @@ -84,7 +84,7 @@ fun PsiReference.isConstructorUsage(ktClassOrObject: KtClassOrObject): Boolean = val descriptor = getConstructorCallDescriptor() if (descriptor !is ConstructorDescriptor) return false - val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor.getContainingDeclaration()) + val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor.containingDeclaration) return declaration == ktClassOrObject || (declaration is KtConstructor<*> && declaration.getContainingClassOrObject() == ktClassOrObject) } @@ -95,12 +95,12 @@ private fun KtElement.getConstructorCallDescriptor(): DeclarationDescriptor? { val bindingContext = this.analyze() val constructorCalleeExpression = getNonStrictParentOfType() if (constructorCalleeExpression != null) { - return bindingContext.get(BindingContext.REFERENCE_TARGET, constructorCalleeExpression.getConstructorReferenceExpression()) + return bindingContext.get(BindingContext.REFERENCE_TARGET, constructorCalleeExpression.constructorReferenceExpression) } val callExpression = getNonStrictParentOfType() if (callExpression != null) { - val callee = callExpression.getCalleeExpression() + val callee = callExpression.calleeExpression if (callee is KtReferenceExpression) { return bindingContext.get(BindingContext.REFERENCE_TARGET, callee) } @@ -109,7 +109,7 @@ private fun KtElement.getConstructorCallDescriptor(): DeclarationDescriptor? { return null } -public fun PsiElement.processDelegationCallConstructorUsages(scope: SearchScope, process: (KtCallElement) -> Boolean): Boolean { +fun PsiElement.processDelegationCallConstructorUsages(scope: SearchScope, process: (KtCallElement) -> Boolean): Boolean { if (!processDelegationCallKotlinConstructorUsages(scope, process)) return false return processDelegationCallJavaConstructorUsages(scope, process) } @@ -135,8 +135,8 @@ private fun PsiElement.processDelegationCallJavaConstructorUsages(scope: SearchS if (this is KtLightElement<*, *>) return true // TODO: Temporary hack to avoid NPE while KotlinNoOriginLightMethod is around if (this is KtLightMethod && this.getOrigin() == null) return true - if (!(this is PsiMethod && isConstructor())) return true - val klass = getContainingClass() ?: return true + if (!(this is PsiMethod && isConstructor)) return true + val klass = containingClass ?: return true val descriptor = getJavaMethodDescriptor() as? ConstructorDescriptor ?: return true return processInheritorsDelegatingCallToSpecifiedConstructor(klass, scope, descriptor, process) } @@ -188,8 +188,8 @@ fun PsiReference.isExtensionOfDeclarationClassUsage(declaration: KtNamedDeclarat usageDescriptor !is FunctionDescriptor -> false else -> { val receiverDescriptor = - usageDescriptor.getExtensionReceiverParameter()?.getType()?.getConstructor()?.getDeclarationDescriptor() - val containingDescriptor = targetDescriptor.getContainingDeclaration() + usageDescriptor.extensionReceiverParameter?.type?.constructor?.declarationDescriptor + val containingDescriptor = targetDescriptor.containingDeclaration containingDescriptor == receiverDescriptor || (containingDescriptor is ClassDescriptor @@ -206,7 +206,7 @@ fun PsiReference.isUsageInContainingDeclaration(declaration: KtNamedDeclaration) val descriptor = declaration.descriptor ?: return false return checkUsageVsOriginalDescriptor(descriptor) { usageDescriptor, targetDescriptor -> usageDescriptor != targetDescriptor - && usageDescriptor.getContainingDeclaration() == targetDescriptor.getContainingDeclaration() + && usageDescriptor.containingDeclaration == targetDescriptor.containingDeclaration } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt index 39440ff731e..0bb2c2eacc4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt @@ -27,11 +27,11 @@ import com.intellij.psi.NavigatablePsiElement import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.idea.caches.resolve.analyze -public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider() { +class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider() { override fun provideNodes(node: TreeElement): Collection { if (node !is KotlinStructureViewElement) return listOf() - val element = node.getElement() + val element = node.element if (element !is KtClassOrObject) return listOf() val project = element.project diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KtClsStructureViewBuilderProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KtClsStructureViewBuilderProvider.kt index 4c180e10b22..b6b2c16f634 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KtClsStructureViewBuilderProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KtClsStructureViewBuilderProvider.kt @@ -25,7 +25,7 @@ import com.intellij.psi.PsiManager import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile //TODO: workaround for bug in JavaClsStructureViewBuilderProvider, remove when IDEA api is updated -public class KtClsStructureViewBuilderProvider : StructureViewBuilderProvider { +class KtClsStructureViewBuilderProvider : StructureViewBuilderProvider { override fun getStructureViewBuilder(fileType: FileType, file: VirtualFile, project: Project): StructureViewBuilder? { val psiFile = PsiManager.getInstance(project).findFile(file) as? KtClsFile ?: return null return KotlinStructureViewFactory().getStructureViewBuilder(psiFile) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt index 1568e413e59..0cc1a5747de 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt @@ -23,25 +23,25 @@ import org.jetbrains.kotlin.util.aliasImportMap fun indexTopLevelExtension(stub: KotlinCallableStubBase, sink: IndexSink) { if (stub.isExtension()) { - val declaration = stub.getPsi() - declaration.getReceiverTypeReference()!!.typeElement?.index(declaration, sink) + val declaration = stub.psi + declaration.receiverTypeReference!!.typeElement?.index(declaration, sink) } } private fun KtTypeElement.index(declaration: TDeclaration, sink: IndexSink) { fun occurrence(typeName: String) { - val name = declaration.getName() ?: return - sink.occurrence(KotlinTopLevelExtensionsByReceiverTypeIndex.INSTANCE.getKey(), + val name = declaration.name ?: return + sink.occurrence(KotlinTopLevelExtensionsByReceiverTypeIndex.INSTANCE.key, KotlinTopLevelExtensionsByReceiverTypeIndex.buildKey(typeName, name)) } when (this) { is KtUserType -> { - var referenceName = getReferencedName() ?: return + var referenceName = referencedName ?: return - val typeParameter = declaration.getTypeParameters().firstOrNull { it.getName() == referenceName } + val typeParameter = declaration.typeParameters.firstOrNull { it.name == referenceName } if (typeParameter != null) { - val bound = typeParameter.getExtendsBound() + val bound = typeParameter.extendsBound if (bound != null) { bound.typeElement?.index(declaration, sink) } @@ -56,10 +56,10 @@ private fun KtTypeElement.index(declarati aliasImportMap()[referenceName].forEach { occurrence(it) } } - is KtNullableType -> getInnerType()?.index(declaration, sink) + is KtNullableType -> innerType?.index(declaration, sink) is KtFunctionType -> { - val arity = getParameters().size + (if (getReceiverTypeReference() != null) 1 else 0) + val arity = parameters.size + (if (receiverTypeReference != null) 1 else 0) occurrence("Function$arity") } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeClassByPackageIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeClassByPackageIndex.kt index 9b3a48355c1..108a2cdfff4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeClassByPackageIndex.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeClassByPackageIndex.kt @@ -22,7 +22,7 @@ import com.intellij.psi.stubs.StringStubIndexExtension import com.intellij.psi.stubs.StubIndexKey import org.jetbrains.kotlin.psi.KtFile -public class KotlinFileFacadeClassByPackageIndex private constructor() : StringStubIndexExtension() { +class KotlinFileFacadeClassByPackageIndex private constructor() : StringStubIndexExtension() { override fun getKey(): StubIndexKey = KEY override fun get(key: String, project: Project, scope: GlobalSearchScope) = @@ -31,10 +31,8 @@ public class KotlinFileFacadeClassByPackageIndex private constructor() : StringS companion object { private val KEY = KotlinIndexUtil.createIndexKey(KotlinFileFacadeClassByPackageIndex::class.java) - @JvmField - public val INSTANCE: KotlinFileFacadeClassByPackageIndex = KotlinFileFacadeClassByPackageIndex() + @JvmField val INSTANCE: KotlinFileFacadeClassByPackageIndex = KotlinFileFacadeClassByPackageIndex() - @JvmStatic - public fun getInstance(): KotlinFileFacadeClassByPackageIndex = INSTANCE + @JvmStatic fun getInstance(): KotlinFileFacadeClassByPackageIndex = INSTANCE } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeFqNameIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeFqNameIndex.kt index 9575901ed47..112636a4e3e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeFqNameIndex.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeFqNameIndex.kt @@ -22,7 +22,7 @@ import com.intellij.psi.stubs.StringStubIndexExtension import com.intellij.psi.stubs.StubIndexKey import org.jetbrains.kotlin.psi.KtFile -public class KotlinFileFacadeFqNameIndex private constructor() : StringStubIndexExtension() { +class KotlinFileFacadeFqNameIndex private constructor() : StringStubIndexExtension() { override fun getKey(): StubIndexKey = KEY override fun get(key: String, project: Project, scope: GlobalSearchScope) = @@ -31,10 +31,8 @@ public class KotlinFileFacadeFqNameIndex private constructor() : StringStubIndex companion object { private val KEY = KotlinIndexUtil.createIndexKey(KotlinFileFacadeFqNameIndex::class.java) - @JvmField - public val INSTANCE: KotlinFileFacadeFqNameIndex = KotlinFileFacadeFqNameIndex() + @JvmField val INSTANCE: KotlinFileFacadeFqNameIndex = KotlinFileFacadeFqNameIndex() - @JvmStatic - public fun getInstance(): KotlinFileFacadeFqNameIndex = INSTANCE + @JvmStatic fun getInstance(): KotlinFileFacadeFqNameIndex = INSTANCE } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeShortNameIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeShortNameIndex.kt index 9cca9f8d4eb..37b931f74c6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeShortNameIndex.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileFacadeShortNameIndex.kt @@ -22,7 +22,7 @@ import com.intellij.psi.stubs.StringStubIndexExtension import com.intellij.psi.stubs.StubIndexKey import org.jetbrains.kotlin.psi.KtFile -public class KotlinFileFacadeShortNameIndex private constructor() : StringStubIndexExtension() { +class KotlinFileFacadeShortNameIndex private constructor() : StringStubIndexExtension() { override fun getKey(): StubIndexKey = KEY override fun get(key: String, project: Project, scope: GlobalSearchScope) = @@ -31,10 +31,8 @@ public class KotlinFileFacadeShortNameIndex private constructor() : StringStubIn companion object { private val KEY = KotlinIndexUtil.createIndexKey(KotlinFileFacadeShortNameIndex::class.java) - @JvmField - public val INSTANCE: KotlinFileFacadeShortNameIndex = KotlinFileFacadeShortNameIndex() + @JvmField val INSTANCE: KotlinFileFacadeShortNameIndex = KotlinFileFacadeShortNameIndex() - @JvmStatic - public fun getInstance(): KotlinFileFacadeShortNameIndex = INSTANCE + @JvmStatic fun getInstance(): KotlinFileFacadeShortNameIndex = INSTANCE } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFilePartClassIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFilePartClassIndex.kt index 17df0d26b7f..1532f9af2d5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFilePartClassIndex.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFilePartClassIndex.kt @@ -23,7 +23,7 @@ import com.intellij.psi.stubs.StubIndexKey import org.jetbrains.kotlin.psi.KtFile -public class KotlinFilePartClassIndex private constructor() : StringStubIndexExtension() { +class KotlinFilePartClassIndex private constructor() : StringStubIndexExtension() { override fun getKey(): StubIndexKey = KEY override fun get(key: String, project: Project, scope: GlobalSearchScope) = @@ -32,10 +32,8 @@ public class KotlinFilePartClassIndex private constructor() : StringStubIndexExt companion object { private val KEY = KotlinIndexUtil.createIndexKey(KotlinFilePartClassIndex::class.java) - @JvmField - public val INSTANCE: KotlinFilePartClassIndex = KotlinFilePartClassIndex() + @JvmField val INSTANCE: KotlinFilePartClassIndex = KotlinFilePartClassIndex() - @JvmStatic - public fun getInstance(): KotlinFilePartClassIndex = INSTANCE + @JvmStatic fun getInstance(): KotlinFilePartClassIndex = INSTANCE } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileStubForIde.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileStubForIde.kt index 2cefc47b0ea..fa26e31364d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileStubForIde.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinFileStubForIde.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.stubs.KotlinFileStub import org.jetbrains.kotlin.psi.stubs.impl.KotlinFileStubImpl -public class KotlinFileStubForIde( +class KotlinFileStubForIde( jetFile: KtFile?, packageName: StringRef, isScript: Boolean, @@ -41,11 +41,11 @@ public class KotlinFileStubForIde( val partFqName: FqName? get() = partSimpleName?.relativeToPackage() - public constructor(jetFile: KtFile?, packageName: String, isScript: Boolean) + constructor(jetFile: KtFile?, packageName: String, isScript: Boolean) : this(jetFile, StringRef.fromString(packageName)!!, isScript, null, null, null) companion object { - public fun forFile(packageFqName: FqName, isScript: Boolean): KotlinFileStubImpl = + fun forFile(packageFqName: FqName, isScript: Boolean): KotlinFileStubImpl = KotlinFileStubForIde(jetFile = null, packageName = StringRef.fromString(packageFqName.asString())!!, facadeSimpleName = null, @@ -53,7 +53,7 @@ public class KotlinFileStubForIde( facadePartSimpleNames = null, isScript = isScript) - public fun forFileFacadeStub(facadeFqName: FqName, isScript: Boolean): KotlinFileStubImpl = + fun forFileFacadeStub(facadeFqName: FqName, isScript: Boolean): KotlinFileStubImpl = KotlinFileStubForIde(jetFile = null, packageName = facadeFqName.parent().stringRef(), facadeSimpleName = facadeFqName.shortName().stringRef(), @@ -61,7 +61,7 @@ public class KotlinFileStubForIde( facadePartSimpleNames = null, isScript = isScript) - public fun forMultifileClassStub(facadeFqName: FqName, partNames: List?, isScript: Boolean): KotlinFileStubImpl = + fun forMultifileClassStub(facadeFqName: FqName, partNames: List?, isScript: Boolean): KotlinFileStubImpl = KotlinFileStubForIde(jetFile = null, packageName = facadeFqName.parent().stringRef(), facadeSimpleName = facadeFqName.shortName().stringRef(), diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinMultifileClassPartIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinMultifileClassPartIndex.kt index 9c5da5f4b08..d334194c1eb 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinMultifileClassPartIndex.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinMultifileClassPartIndex.kt @@ -23,7 +23,7 @@ import com.intellij.psi.stubs.StubIndexKey import org.jetbrains.kotlin.psi.KtFile -public class KotlinMultifileClassPartIndex private constructor() : StringStubIndexExtension() { +class KotlinMultifileClassPartIndex private constructor() : StringStubIndexExtension() { override fun getKey(): StubIndexKey = KEY override fun get(key: String, project: Project, scope: GlobalSearchScope) = @@ -32,10 +32,8 @@ public class KotlinMultifileClassPartIndex private constructor() : StringStubInd companion object { private val KEY = KotlinIndexUtil.createIndexKey(KotlinMultifileClassPartIndex::class.java) - @JvmField - public val INSTANCE: KotlinMultifileClassPartIndex = KotlinMultifileClassPartIndex() + @JvmField val INSTANCE: KotlinMultifileClassPartIndex = KotlinMultifileClassPartIndex() - @JvmStatic - public fun getInstance(): KotlinMultifileClassPartIndex = INSTANCE + @JvmStatic fun getInstance(): KotlinMultifileClassPartIndex = INSTANCE } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinTopLevelExtensionsByReceiverTypeIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinTopLevelExtensionsByReceiverTypeIndex.kt index 2a65659f561..c2abc099941 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinTopLevelExtensionsByReceiverTypeIndex.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinTopLevelExtensionsByReceiverTypeIndex.kt @@ -21,7 +21,7 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StringStubIndexExtension import org.jetbrains.kotlin.psi.KtCallableDeclaration -public class KotlinTopLevelExtensionsByReceiverTypeIndex private constructor() : StringStubIndexExtension() { +class KotlinTopLevelExtensionsByReceiverTypeIndex private constructor() : StringStubIndexExtension() { override fun getKey() = KEY @@ -32,12 +32,12 @@ public class KotlinTopLevelExtensionsByReceiverTypeIndex private constructor() : private val KEY = KotlinIndexUtil.createIndexKey(KotlinTopLevelExtensionsByReceiverTypeIndex::class.java) private val SEPARATOR = '\n' - public val INSTANCE: KotlinTopLevelExtensionsByReceiverTypeIndex = KotlinTopLevelExtensionsByReceiverTypeIndex() + val INSTANCE: KotlinTopLevelExtensionsByReceiverTypeIndex = KotlinTopLevelExtensionsByReceiverTypeIndex() - public fun buildKey(receiverTypeName: String, callableName: String): String = receiverTypeName + SEPARATOR + callableName + fun buildKey(receiverTypeName: String, callableName: String): String = receiverTypeName + SEPARATOR + callableName - public fun receiverTypeNameFromKey(key: String): String = key.substringBefore(SEPARATOR, "") + fun receiverTypeNameFromKey(key: String): String = key.substringBefore(SEPARATOR, "") - public fun callableNameFromKey(key: String): String = key.substringAfter(SEPARATOR, "") + fun callableNameFromKey(key: String): String = key.substringAfter(SEPARATOR, "") } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt index 599c58ce700..a0775e82b0d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt @@ -23,9 +23,8 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtFile -public object PackageIndexUtil { - @JvmStatic - public fun getSubPackageFqNames( +object PackageIndexUtil { + @JvmStatic fun getSubPackageFqNames( packageFqName: FqName, scope: GlobalSearchScope, project: Project, @@ -34,8 +33,7 @@ public object PackageIndexUtil { return SubpackagesIndexService.getInstance(project).getSubpackages(packageFqName, scope, nameFilter) } - @JvmStatic - public fun findFilesWithExactPackage( + @JvmStatic fun findFilesWithExactPackage( packageFqName: FqName, searchScope: GlobalSearchScope, project: Project @@ -43,8 +41,7 @@ public object PackageIndexUtil { return KotlinExactPackagesIndex.getInstance().get(packageFqName.asString(), project, searchScope) } - @JvmStatic - public fun packageExists( + @JvmStatic fun packageExists( packageFqName: FqName, searchScope: GlobalSearchScope, project: Project @@ -58,15 +55,14 @@ public object PackageIndexUtil { subpackagesIndex.hasSubpackages(packageFqName, searchScope) } - @JvmStatic - public fun containsFilesWithExactPackage( + @JvmStatic fun containsFilesWithExactPackage( packageFqName: FqName, searchScope: GlobalSearchScope, project: Project ): Boolean { var result = false StubIndex.getInstance().processElements( - KotlinExactPackagesIndex.getInstance().getKey(), packageFqName.asString(), project, searchScope, KtFile::class.java + KotlinExactPackagesIndex.getInstance().key, packageFqName.asString(), project, searchScope, KtFile::class.java ) { result = true false diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/StaticFacadeIndexUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/StaticFacadeIndexUtil.kt index 3aaf3dd0144..7d1fca56475 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/StaticFacadeIndexUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/StaticFacadeIndexUtil.kt @@ -23,11 +23,10 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtFile -public object StaticFacadeIndexUtil { +object StaticFacadeIndexUtil { // TODO change as we introduce multi-file facades (this will require a separate index) - @JvmStatic - public fun findFilesForFilePart( + @JvmStatic fun findFilesForFilePart( partFqName: FqName, searchScope: GlobalSearchScope, project: Project @@ -35,7 +34,7 @@ public object StaticFacadeIndexUtil { PackagePartClassUtils.getFilesWithCallables( KotlinFileFacadeFqNameIndex.INSTANCE.get(partFqName.asString(), project, searchScope)) - @JvmStatic public fun getMultifileClassForPart( + @JvmStatic fun getMultifileClassForPart( partFqName: FqName, searchScope: GlobalSearchScope, project: Project diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt index 6b3fe37d587..046520dd947 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import java.util.* -public class SubpackagesIndexService(private val project: Project) { +class SubpackagesIndexService(private val project: Project) { private val cachedValue = CachedValuesManager.getManager(project).createCachedValue( { @@ -38,7 +38,7 @@ public class SubpackagesIndexService(private val project: Project) { false ) - public inner class SubpackagesIndex(allPackageFqNames: Collection) { + inner class SubpackagesIndex(allPackageFqNames: Collection) { // a map from any existing package (in kotlin) to a set of subpackages (not necessarily direct) containing files private val allPackageFqNames = hashSetOf() private val fqNameByPrefix = MultiMap.createSet() @@ -49,7 +49,7 @@ public class SubpackagesIndexService(private val project: Project) { this.allPackageFqNames.add(fqName) var prefix = fqName - while (!prefix.isRoot()) { + while (!prefix.isRoot) { prefix = prefix.parent() fqNameByPrefix.putValue(prefix, fqName) } @@ -83,8 +83,8 @@ public class SubpackagesIndexService(private val project: Project) { } companion object { - public fun getInstance(project: Project): SubpackagesIndex { - return ServiceManager.getService(project, SubpackagesIndexService::class.java)!!.cachedValue.getValue()!! + fun getInstance(project: Project): SubpackagesIndex { + return ServiceManager.getService(project, SubpackagesIndexService::class.java)!!.cachedValue.value!! } } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactory.kt index 562547d2ea8..d3526fde730 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactory.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo import org.jetbrains.kotlin.resolve.lazy.declarations.* import org.jetbrains.kotlin.storage.StorageManager -public class PluginDeclarationProviderFactory( +class PluginDeclarationProviderFactory( private val project: Project, private val indexedFilesScope: GlobalSearchScope, private val storageManager: StorageManager, diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactoryService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactoryService.kt index 32bf9e97b55..1a1885f695d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactoryService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/PluginDeclarationProviderFactoryService.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService import org.jetbrains.kotlin.storage.StorageManager -public class PluginDeclarationProviderFactoryService : DeclarationProviderFactoryService() { +class PluginDeclarationProviderFactoryService : DeclarationProviderFactoryService() { override fun create( project: Project, diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt index f4064beeaa6..022b1e80f25 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt @@ -31,7 +31,7 @@ import com.intellij.psi.stubs.StringStubIndexExtension import org.jetbrains.kotlin.idea.stubindex.* import org.jetbrains.kotlin.resolve.lazy.data.KtScriptInfo -public class StubBasedPackageMemberDeclarationProvider( +class StubBasedPackageMemberDeclarationProvider( private val fqName: FqName, private val project: Project, private val searchScope: GlobalSearchScope @@ -41,7 +41,7 @@ public class StubBasedPackageMemberDeclarationProvider( val result = ArrayList() fun addFromIndex(index: StringStubIndexExtension) { - index.get(fqName.asString(), project, searchScope).filterTo(result) { nameFilter(it.getNameAsSafeName()) } + index.get(fqName.asString(), project, searchScope).filterTo(result) { nameFilter(it.nameAsSafeName) } } if (kindFilter.acceptsKinds(DescriptorKindFilter.CLASSIFIERS_MASK)) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt index dffa2cc3def..a7e73eeaa08 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt @@ -21,23 +21,23 @@ import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project -public fun runReadAction(action: () -> T): T { +fun runReadAction(action: () -> T): T { return ApplicationManager.getApplication().runReadAction(action) } -public fun runWriteAction(action: () -> T): T { +fun runWriteAction(action: () -> T): T { return ApplicationManager.getApplication().runWriteAction(action) } -public fun Project.executeWriteCommand(name: String, command: () -> Unit) { +fun Project.executeWriteCommand(name: String, command: () -> Unit) { CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null) } -public fun Project.executeWriteCommand(name: String, groupId: Any? = null, command: () -> T): T { +fun Project.executeWriteCommand(name: String, groupId: Any? = null, command: () -> T): T { return executeCommand(name, groupId) { runWriteAction(command) } } -public fun Project.executeCommand(name: String, groupId: Any? = null, command: () -> T): T { +fun Project.executeCommand(name: String, groupId: Any? = null, command: () -> T): T { var result: T = null as T CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId) @Suppress("USELESS_CAST") diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt index b606030dec1..4a9edf7e18e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt @@ -27,21 +27,21 @@ import org.jetbrains.kotlin.psi.psiUtil.* import java.util.* import kotlin.properties.Delegates -public class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks: Boolean = false/*TODO?*/) { - public constructor(originalElement: PsiElement, saveLineBreaks: Boolean = false/*TODO?*/) : this(PsiChildRange.singleElement(originalElement), saveLineBreaks) +class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks: Boolean = false/*TODO?*/) { + constructor(originalElement: PsiElement, saveLineBreaks: Boolean = false/*TODO?*/) : this(PsiChildRange.singleElement(originalElement), saveLineBreaks) private val SAVED_TREE_KEY = Key("SAVED_TREE") private val psiFactory = KtPsiFactory(originalElements.first!!) private abstract class TreeElement { - public companion object { - public fun create(element: PsiElement): TreeElement? { + companion object { + fun create(element: PsiElement): TreeElement? { val tokenType = element.tokenType val treeElement = when { element is PsiWhiteSpace -> if (element.textContains('\n')) LineBreakTreeElement() else null element is PsiComment -> CommentTreeElement.create(element) tokenType != null -> TokenTreeElement(tokenType) - else -> if (element.getTextLength() > 0) StandardTreeElement() else null // don't save empty elements + else -> if (element.textLength > 0) StandardTreeElement() else null // don't save empty elements } // treeElement?.debugText = element.getText() return treeElement @@ -129,11 +129,11 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB val spaceBefore: String, val spaceAfter: String ) : TreeElement() { - public companion object { + companion object { fun create(comment: PsiComment): CommentTreeElement { - val spaceBefore = (comment.prevLeaf(skipEmptyElements = true) as? PsiWhiteSpace)?.getText() ?: "" - val spaceAfter = (comment.nextLeaf(skipEmptyElements = true) as? PsiWhiteSpace)?.getText() ?: "" - return CommentTreeElement(comment.getText(), spaceBefore, spaceAfter) + val spaceBefore = (comment.prevLeaf(skipEmptyElements = true) as? PsiWhiteSpace)?.text ?: "" + val spaceAfter = (comment.nextLeaf(skipEmptyElements = true) as? PsiWhiteSpace)?.text ?: "" + return CommentTreeElement(comment.text, spaceBefore, spaceAfter) } } } @@ -184,7 +184,7 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB get() = getCopyableUserData(SAVED_TREE_KEY) set(value) = putCopyableUserData(SAVED_TREE_KEY, value) - public fun deleteCommentsInside(element: PsiElement) { + fun deleteCommentsInside(element: PsiElement) { element.accept(object : PsiRecursiveElementVisitor() { override fun visitComment(comment: PsiComment) { val treeElement = comment.savedTreeElement @@ -195,19 +195,19 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB }) } - public fun elementCreatedByText(createdElement: PsiElement, original: PsiElement, rangeInOriginal: TextRange) { - assert(createdElement.getTextLength() == rangeInOriginal.getLength()) - assert(createdElement.getText() == original.getText().substring(rangeInOriginal.getStartOffset(), rangeInOriginal.getEndOffset())) + fun elementCreatedByText(createdElement: PsiElement, original: PsiElement, rangeInOriginal: TextRange) { + assert(createdElement.textLength == rangeInOriginal.length) + assert(createdElement.text == original.text.substring(rangeInOriginal.startOffset, rangeInOriginal.endOffset)) createdElement.accept(object : PsiRecursiveElementVisitor() { override fun visitElement(element: PsiElement) { if (element is PsiWhiteSpace) return - val token = original.findElementAt(element.getStartOffsetIn(createdElement) + rangeInOriginal.getStartOffset()) + val token = original.findElementAt(element.getStartOffsetIn(createdElement) + rangeInOriginal.startOffset) if (token != null) { - val elementLength = element.getTextLength() + val elementLength = element.textLength for (originalElement in token.parentsWithSelf) { - val length = originalElement.getTextLength() + val length = originalElement.textLength if (length < elementLength) continue if (length == elementLength) { element.savedTreeElement = originalElement.savedTreeElement @@ -230,11 +230,11 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB putNewElementIntoMap(newPsiElement, treeElement) } - public fun restore(resultElement: PsiElement, forceAdjustIndent: Boolean = false) { + fun restore(resultElement: PsiElement, forceAdjustIndent: Boolean = false) { restore(PsiChildRange.singleElement(resultElement), forceAdjustIndent) } - public fun restore(resultElements: PsiChildRange, forceAdjustIndent: Boolean = false) { + fun restore(resultElements: PsiChildRange, forceAdjustIndent: Boolean = false) { assert(!resultElements.isEmpty) if (commentsToRestore.isNotEmpty() || lineBreaksToRestore.isNotEmpty()) { @@ -296,7 +296,7 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB val restored: PsiComment if (anchor != null) { val anchorElement = findFinalAnchorElement(anchor, comment) - val parent = anchorElement.getParent() + val parent = anchorElement.parent if (anchor.before) { restored = parent.addAfter(comment, anchorElement) as PsiComment if (commentTreeElement.spaceBefore.isNotEmpty()) { @@ -311,7 +311,7 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB } } else { - restored = putAbandonedCommentsAfter.getParent().addAfter(comment, putAbandonedCommentsAfter) as PsiComment + restored = putAbandonedCommentsAfter.parent.addAfter(comment, putAbandonedCommentsAfter) as PsiComment putAbandonedCommentsAfter = restored } @@ -365,15 +365,15 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB private fun PsiElement.restoreLineBreakAfter() { val addAfter = shiftNewLineAnchor(this).anchorToAddCommentOrSpace(before = false) - var whitespace = addAfter.getNextSibling() as? PsiWhiteSpace + var whitespace = addAfter.nextSibling as? PsiWhiteSpace //TODO: restore blank lines - if (whitespace != null && whitespace.getText().contains('\n')) return // line break is already there + if (whitespace != null && whitespace.text.contains('\n')) return // line break is already there if (whitespace == null) { - addAfter.getParent().addAfter(psiFactory.createNewLine(), addAfter) + addAfter.parent.addAfter(psiFactory.createNewLine(), addAfter) } else { - whitespace.replace(psiFactory.createWhiteSpace("\n" + whitespace.getText())) + whitespace.replace(psiFactory.createWhiteSpace("\n" + whitespace.text)) } needAdjustIndentAfterRestore = true @@ -399,7 +399,7 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB private fun PsiElement.anchorToAddCommentOrSpace(before: Boolean): PsiElement { return parentsWithSelf - .dropWhile { it.getParent() !is PsiFile && (if (before) it.getPrevSibling() else it.getNextSibling()) == null } + .dropWhile { it.parent !is PsiFile && (if (before) it.prevSibling else it.nextSibling) == null } .first() } @@ -447,11 +447,11 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB return if (next?.tokenType == KtTokens.COMMA) next!! else putAfter } - private val nonSpaceAndNonEmptyFilter = { element: PsiElement -> element !is PsiWhiteSpace && element.getTextLength() > 0 } + private val nonSpaceAndNonEmptyFilter = { element: PsiElement -> element !is PsiWhiteSpace && element.textLength > 0 } companion object { //TODO: making it private causes error on runtime (KT-7874?) val PsiElement.tokenType: KtToken? - get() = getNode().getElementType() as? KtToken + get() = node.elementType as? KtToken } } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ImportInsertHelper.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ImportInsertHelper.kt index 0da6d45100e..88e8f222097 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ImportInsertHelper.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ImportInsertHelper.kt @@ -34,8 +34,7 @@ abstract class ImportInsertHelper { abstract fun importDescriptor(file: KtFile, descriptor: DeclarationDescriptor, forceAllUnderImport: Boolean = false): ImportDescriptorResult companion object { - @JvmStatic - public fun getInstance(project: Project): ImportInsertHelper + @JvmStatic fun getInstance(project: Project): ImportInsertHelper = ServiceManager.getService(project, ImportInsertHelper::class.java) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt index dea22ff9d1a..c61ce882ebc 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt @@ -29,12 +29,11 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction private val classFileLike = setOf(JavaClassFileType.INSTANCE, KotlinBuiltInClassFileType, KotlinBuiltInPackageFileType) -public object ProjectRootsUtil { - @JvmStatic - public fun isInContent(project: Project, file: VirtualFile, includeProjectSource: Boolean, - includeLibrarySource: Boolean, includeLibraryClasses: Boolean, - fileIndex: ProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(project), - isJsProject: Boolean? = null): Boolean { +object ProjectRootsUtil { + @JvmStatic fun isInContent(project: Project, file: VirtualFile, includeProjectSource: Boolean, + includeLibrarySource: Boolean, includeLibraryClasses: Boolean, + fileIndex: ProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(project), + isJsProject: Boolean? = null): Boolean { if (includeProjectSource && fileIndex.isInSourceContent(file)) { return true } @@ -51,8 +50,7 @@ public object ProjectRootsUtil { || (includeLibrarySource && !isClassFile && fileIndex.isInLibrarySource(file)) } - @JvmStatic - public fun isInContent( + @JvmStatic fun isInContent( element: PsiElement, includeProjectSource: Boolean, includeLibrarySource: Boolean, @@ -60,52 +58,44 @@ public object ProjectRootsUtil { ): Boolean { return runReadAction { val virtualFile = when (element) { - is PsiDirectory -> element.getVirtualFile() - else -> element.getContainingFile()?.getVirtualFile() + is PsiDirectory -> element.virtualFile + else -> element.containingFile?.virtualFile } ?: return@runReadAction false - val project = element.getProject() + val project = element.project return@runReadAction isInContent(project, virtualFile, includeProjectSource, includeLibrarySource, includeLibraryClasses) } } - @JvmStatic - public fun isInProjectSource(element: PsiElement): Boolean { + @JvmStatic fun isInProjectSource(element: PsiElement): Boolean { return isInContent(element, includeProjectSource = true, includeLibrarySource = false, includeLibraryClasses = false) } - @JvmStatic - public fun isProjectSourceFile(project: Project, file: VirtualFile): Boolean { + @JvmStatic fun isProjectSourceFile(project: Project, file: VirtualFile): Boolean { return isInContent(project, file, includeProjectSource = true, includeLibrarySource = false, includeLibraryClasses = false) } - @JvmStatic - public fun isInProjectOrLibSource(element: PsiElement): Boolean { + @JvmStatic fun isInProjectOrLibSource(element: PsiElement): Boolean { return isInContent(element, includeProjectSource = true, includeLibrarySource = true, includeLibraryClasses = false) } - @JvmStatic - public fun isInProjectOrLibraryContent(element: PsiElement): Boolean { + @JvmStatic fun isInProjectOrLibraryContent(element: PsiElement): Boolean { return isInContent(element, includeProjectSource = true, includeLibrarySource = true, includeLibraryClasses = true) } - @JvmStatic - public fun isInProjectOrLibraryClassFile(element: PsiElement): Boolean { + @JvmStatic fun isInProjectOrLibraryClassFile(element: PsiElement): Boolean { return isInContent(element, includeProjectSource = true, includeLibrarySource = false, includeLibraryClasses = true) } - @JvmStatic - public fun isLibraryClassFile(project: Project, file: VirtualFile): Boolean { + @JvmStatic fun isLibraryClassFile(project: Project, file: VirtualFile): Boolean { return isInContent(project, file, includeProjectSource = false, includeLibrarySource = false, includeLibraryClasses = true) } - @JvmStatic - public fun isLibrarySourceFile(project: Project, file: VirtualFile): Boolean { + @JvmStatic fun isLibrarySourceFile(project: Project, file: VirtualFile): Boolean { return isInContent(project, file, includeProjectSource = false, includeLibrarySource = true, includeLibraryClasses = false) } - @JvmStatic - public fun isLibraryFile(project: Project, file: VirtualFile): Boolean { + @JvmStatic fun isLibraryFile(project: Project, file: VirtualFile): Boolean { return isInContent(project, file, includeProjectSource = false, includeLibrarySource = true, includeLibraryClasses = true) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/PsiPrecedences.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/PsiPrecedences.kt index 049bf6ea289..6b5b043671a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/PsiPrecedences.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/PsiPrecedences.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.parsing.KotlinExpressionParsing.Precedence.PREFIX import org.jetbrains.kotlin.psi.* import java.util.* -public object PsiPrecedences { +object PsiPrecedences { private val LOG = Logger.getInstance(PsiPrecedences::class.java) @@ -32,25 +32,25 @@ public object PsiPrecedences { init { val builder = HashMap() for ((i, record) in KotlinExpressionParsing.Precedence.values().withIndex()) { - for (elementType in record.getOperations().getTypes()) { + for (elementType in record.operations.types) { builder[elementType] = i } } precedence = builder } - public val PRECEDENCE_OF_ATOMIC_EXPRESSION: Int = -1 - public val PRECEDENCE_OF_PREFIX_EXPRESSION: Int = PREFIX.ordinal - public val PRECEDENCE_OF_POSTFIX_EXPRESSION: Int = POSTFIX.ordinal + val PRECEDENCE_OF_ATOMIC_EXPRESSION: Int = -1 + val PRECEDENCE_OF_PREFIX_EXPRESSION: Int = PREFIX.ordinal + val PRECEDENCE_OF_POSTFIX_EXPRESSION: Int = POSTFIX.ordinal - public fun getPrecedence(expression: KtExpression): Int { + fun getPrecedence(expression: KtExpression): Int { return when (expression) { is KtAnnotatedExpression, is KtLabeledExpression, is KtPrefixExpression -> PRECEDENCE_OF_PREFIX_EXPRESSION is KtPostfixExpression -> PRECEDENCE_OF_POSTFIX_EXPRESSION is KtOperationExpression -> { - val operation = expression.getOperationReference().getReferencedNameElementType() + val operation = expression.operationReference.getReferencedNameElementType() val precedenceNumber = precedence[operation] if (precedenceNumber == null) { LOG.error("No precedence for operation: " + operation) @@ -62,7 +62,7 @@ public object PsiPrecedences { } } - public fun isTighter(subject: Int, tighterThan: Int): Boolean { + fun isTighter(subject: Int, tighterThan: Int): Boolean { return subject < tighterThan } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt index 3434aa6078b..d6ef3c69caa 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt @@ -44,8 +44,8 @@ import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier import org.jetbrains.kotlin.resolve.scopes.utils.findPackage import java.util.* -public class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT }) { - public data class Options( +class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT }) { + data class Options( val removeThisLabels: Boolean = false, val removeThis: Boolean = false ) { @@ -65,41 +65,40 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D private fun mayImport(descriptor: DeclarationDescriptor, file: KtFile): Boolean { return descriptor.canBeReferencedViaImport() - && ImportInsertHelper.getInstance(file.getProject()).mayImportOnShortenReferences(descriptor) + && ImportInsertHelper.getInstance(file.project).mayImportOnShortenReferences(descriptor) } } - @JvmOverloads - public fun process(element: KtElement, elementFilter: (PsiElement) -> FilterResult = { FilterResult.PROCESS }): KtElement { + @JvmOverloads fun process(element: KtElement, elementFilter: (PsiElement) -> FilterResult = { FilterResult.PROCESS }): KtElement { return process(listOf(element), elementFilter).single() } - public fun process(file: KtFile, startOffset: Int, endOffset: Int) { - val documentManager = PsiDocumentManager.getInstance(file.getProject()) + fun process(file: KtFile, startOffset: Int, endOffset: Int) { + val documentManager = PsiDocumentManager.getInstance(file.project) val document = file.viewProvider.document!! if (!documentManager.isCommitted(document)) { throw IllegalStateException("Document should be committed to shorten references in range") } val rangeMarker = document.createRangeMarker(startOffset, endOffset) - rangeMarker.setGreedyToLeft(true) - rangeMarker.setGreedyToRight(true) + rangeMarker.isGreedyToLeft = true + rangeMarker.isGreedyToRight = true try { process(listOf(file), { element -> - if (rangeMarker.isValid()) { - val range = TextRange(rangeMarker.getStartOffset(), rangeMarker.getEndOffset()) + if (rangeMarker.isValid) { + val range = TextRange(rangeMarker.startOffset, rangeMarker.endOffset) - val elementRange = element.getTextRange()!! + val elementRange = element.textRange!! when { range.contains(elementRange) -> FilterResult.PROCESS range.intersects(elementRange) -> { // for qualified call expression allow to shorten only the part without parenthesis val calleeExpression = ((element as? KtDotQualifiedExpression) - ?.getSelectorExpression() as? KtCallExpression) - ?.getCalleeExpression() + ?.selectorExpression as? KtCallExpression) + ?.calleeExpression if (calleeExpression != null) { - val rangeWithoutParenthesis = TextRange(elementRange.getStartOffset(), calleeExpression.getTextRange()!!.getEndOffset()) + val rangeWithoutParenthesis = TextRange(elementRange.startOffset, calleeExpression.textRange!!.endOffset) if (range.contains(rangeWithoutParenthesis)) FilterResult.PROCESS else FilterResult.GO_INSIDE } else { @@ -120,14 +119,13 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D } } - public enum class FilterResult { + enum class FilterResult { SKIP, GO_INSIDE, PROCESS } - @JvmOverloads - public fun process(elements: Iterable, elementFilter: (PsiElement) -> FilterResult = { FilterResult.PROCESS }): Collection { + @JvmOverloads fun process(elements: Iterable, elementFilter: (PsiElement) -> FilterResult = { FilterResult.PROCESS }): Collection { return elements.groupBy { element -> element.getContainingKtFile() } .flatMap { shortenReferencesInFile(it.key, it.value, elementFilter) } } @@ -140,7 +138,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D //TODO: that's not correct since we have options! val elementsToUse = dropNestedElements(elements) - val helper = ImportInsertHelper.getInstance(file.getProject()) + val helper = ImportInsertHelper.getInstance(file.project) val failedToImportDescriptors = LinkedHashSet() @@ -234,9 +232,9 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D } } - public fun shortenElements(elementSetToUpdate: MutableSet) { + fun shortenElements(elementSetToUpdate: MutableSet) { for (element in elementsToShorten) { - if (!element.isValid()) continue + if (!element.isValid) continue val newElement = shortenElement(element) if (element in elementSetToUpdate && newElement != element) { elementSetToUpdate.remove(element) @@ -245,7 +243,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D } } - public fun getDescriptorsToImport(): Set = descriptorsToImport + fun getDescriptorsToImport(): Set = descriptorsToImport } private class ShortenTypesVisitor( @@ -257,19 +255,19 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D val filterResult = elementFilter(userType) if (filterResult == FilterResult.SKIP) return - userType.getTypeArgumentList()?.accept(this) + userType.typeArgumentList?.accept(this) if (filterResult == FilterResult.PROCESS) { processType(userType) } else { - userType.getQualifier()?.accept(this) + userType.qualifier?.accept(this) } } private fun processType(type: KtUserType) { - if (type.getQualifier() == null) return - val referenceExpression = type.getReferenceExpression() ?: return + if (type.qualifier == null) return + val referenceExpression = type.referenceExpression ?: return val bindingContext = analyze(referenceExpression) val target = referenceExpression.targets(bindingContext).singleOrNull() ?: return @@ -285,7 +283,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D processQualifiedElement(type, target, canShortenNow) } - override fun qualifier(element: KtUserType) = element.getQualifier()!! + override fun qualifier(element: KtUserType) = element.qualifier!! override fun shortenElement(element: KtUserType): KtElement { element.deleteQualifier() @@ -302,18 +300,18 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D val filterResult = elementFilter(expression) if (filterResult == FilterResult.SKIP) return - expression.getSelectorExpression()?.acceptChildren(this) + expression.selectorExpression?.acceptChildren(this) if (filterResult == FilterResult.PROCESS) { if (process(expression)) return } - expression.getReceiverExpression().accept(this) + expression.receiverExpression.accept(this) } abstract fun process(qualifiedExpression: KtDotQualifiedExpression): Boolean - override fun qualifier(element: KtDotQualifiedExpression) = element.getReceiverExpression() + override fun qualifier(element: KtDotQualifiedExpression) = element.receiverExpression } private class ShortenQualifiedExpressionsVisitor( @@ -325,7 +323,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D override fun process(qualifiedExpression: KtDotQualifiedExpression): Boolean { val bindingContext = analyze(qualifiedExpression) - val receiver = qualifiedExpression.getReceiverExpression() + val receiver = qualifiedExpression.receiverExpression when (receiver) { is KtThisExpression -> { if (!options.removeThis) return false @@ -339,7 +337,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D qualifiedExpression, KtImportDirective::class.java, KtPackageDirective::class.java) != null) return true - val selector = qualifiedExpression.getSelectorExpression() ?: return false + val selector = qualifiedExpression.selectorExpression ?: return false val callee = selector.getCalleeExpressionIfAny() as? KtReferenceExpression ?: return false val targets = callee.targets(bindingContext) if (targets.isEmpty()) return false @@ -354,14 +352,14 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D if (!targetsMatch) return false val originalCall = selector.getResolvedCall(bindingContext) ?: return false val newCall = selectorCopy.getResolvedCall(newContext) ?: return false - val receiverKind = originalCall.getExplicitReceiverKind() + val receiverKind = originalCall.explicitReceiverKind val newReceiver = when (receiverKind) { - ExplicitReceiverKind.BOTH_RECEIVERS, ExplicitReceiverKind.EXTENSION_RECEIVER -> newCall.getExtensionReceiver() - ExplicitReceiverKind.DISPATCH_RECEIVER -> newCall.getDispatchReceiver() + ExplicitReceiverKind.BOTH_RECEIVERS, ExplicitReceiverKind.EXTENSION_RECEIVER -> newCall.extensionReceiver + ExplicitReceiverKind.DISPATCH_RECEIVER -> newCall.dispatchReceiver else -> return false } as? ImplicitReceiver ?: return false - val thisTarget = receiver.getInstanceReference().targets(bindingContext).singleOrNull() + val thisTarget = receiver.instanceReference.targets(bindingContext).singleOrNull() if (newReceiver.declarationDescriptor.asString() != thisTarget?.asString()) return false } @@ -385,7 +383,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D } override fun shortenElement(element: KtDotQualifiedExpression): KtElement { - return element.replace(element.getSelectorExpression()!!) as KtElement + return element.replace(element.selectorExpression!!) as KtElement } } @@ -401,10 +399,10 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D val bindingContext = analyze(thisExpression) - val targetBefore = thisExpression.getInstanceReference().targets(bindingContext).singleOrNull() ?: return + val targetBefore = thisExpression.instanceReference.targets(bindingContext).singleOrNull() ?: return val scope = thisExpression.getResolutionScope(bindingContext, resolutionFacade) val newContext = simpleThis.analyzeInContext(scope, thisExpression) - val targetAfter = simpleThis.getInstanceReference().targets(newContext).singleOrNull() + val targetAfter = simpleThis.instanceReference.targets(newContext).singleOrNull() if (targetBefore == targetAfter) { addElementToShorten(thisExpression) } @@ -437,7 +435,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D override fun process(qualifiedExpression: KtDotQualifiedExpression): Boolean { val bindingContext = analyze(qualifiedExpression) - val receiver = qualifiedExpression.getReceiverExpression() + val receiver = qualifiedExpression.receiverExpression if (PsiTreeUtil.getParentOfType( qualifiedExpression, @@ -446,12 +444,12 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D val receiverTarget = receiver.singleTarget(bindingContext) ?: return false if (receiverTarget !is ClassDescriptor) return false - val selectorExpression = qualifiedExpression.getSelectorExpression() ?: return false + val selectorExpression = qualifiedExpression.selectorExpression ?: return false val selectorTarget = selectorExpression.singleTarget(bindingContext) ?: return false - if (receiverTarget.getCompanionObjectDescriptor() != selectorTarget) return false + if (receiverTarget.companionObjectDescriptor != selectorTarget) return false - val selectorsSelector = (qualifiedExpression.getParent() as? KtDotQualifiedExpression)?.getSelectorExpression() + val selectorsSelector = (qualifiedExpression.parent as? KtDotQualifiedExpression)?.selectorExpression if (selectorsSelector == null) { addElementToShorten(qualifiedExpression) return true diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt index d029ee4dcba..97c1e192e4b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt @@ -20,18 +20,18 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project -public fun Project.runReadActionInSmartMode(action: () -> T): T { +fun Project.runReadActionInSmartMode(action: () -> T): T { if (ApplicationManager.getApplication().isReadAccessAllowed) return action() return DumbService.getInstance(this).runReadActionInSmartMode(action) } -public fun Project.runWithAlternativeResolveEnabled(action: () -> T): T { +fun Project.runWithAlternativeResolveEnabled(action: () -> T): T { var result: T = null as T DumbService.getInstance(this).withAlternativeResolveEnabled { result = action() } @Suppress("USELESS_CAST") return result as T } -public fun Project.runWhenSmart(action: () -> Unit) { +fun Project.runWhenSmart(action: () -> Unit) { DumbService.getInstance(this).runWhenSmart(action) } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/IDEVirtualFileFinder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/IDEVirtualFileFinder.kt index 26191579f9e..b4d16837d5e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/IDEVirtualFileFinder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/IDEVirtualFileFinder.kt @@ -26,10 +26,10 @@ import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClassFinder import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName -public class IDEVirtualFileFinder(private val scope: GlobalSearchScope) : VirtualFileKotlinClassFinder(), VirtualFileFinder { +class IDEVirtualFileFinder(private val scope: GlobalSearchScope) : VirtualFileKotlinClassFinder(), VirtualFileFinder { init { - if (scope != GlobalSearchScope.EMPTY_SCOPE && scope.getProject() == null) { + if (scope != GlobalSearchScope.EMPTY_SCOPE && scope.project == null) { LOG.warn("Scope with null project " + scope) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinder.kt index 7b7476a770a..136f1793736 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinder.kt @@ -21,10 +21,9 @@ import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder -public interface JsVirtualFileFinder : VirtualFileFinder { - public object SERVICE { - @JvmStatic - public fun getInstance(project: Project): JsVirtualFileFinder = +interface JsVirtualFileFinder : VirtualFileFinder { + object SERVICE { + @JvmStatic fun getInstance(project: Project): JsVirtualFileFinder = ServiceManager.getService(project, JsVirtualFileFinderFactory::class.java).create(GlobalSearchScope.allScope(project)) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinderFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinderFactory.kt index ee591affc5e..a11a5c969a6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinderFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/JsVirtualFileFinderFactory.kt @@ -21,12 +21,11 @@ import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory -public interface JsVirtualFileFinderFactory : VirtualFileFinderFactory { +interface JsVirtualFileFinderFactory : VirtualFileFinderFactory { override fun create(scope: GlobalSearchScope): JsVirtualFileFinder - public object SERVICE { - @JvmStatic - public fun getInstance(project: Project): JsVirtualFileFinderFactory = + object SERVICE { + @JvmStatic fun getInstance(project: Project): JsVirtualFileFinderFactory = ServiceManager.getService(project, JsVirtualFileFinderFactory::class.java) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/factories.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/factories.kt index 7f8fa8e61ae..3ad162c4a3f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/factories.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/factories.kt @@ -20,10 +20,10 @@ import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory -public class JvmIDEVirtualFileFinderFactory : JvmVirtualFileFinderFactory { +class JvmIDEVirtualFileFinderFactory : JvmVirtualFileFinderFactory { override fun create(scope: GlobalSearchScope): JvmVirtualFileFinder = JvmIDEVirtualFileFinder(scope) } -public class JsIDEVirtualFileFinderFactory : JsVirtualFileFinderFactory { +class JsIDEVirtualFileFinderFactory : JsVirtualFileFinderFactory { override fun create(scope: GlobalSearchScope): JsVirtualFileFinder = JsIDEVirtualFileFinder(scope) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileFinders.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileFinders.kt index 98d3aa905a5..a487704015d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileFinders.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileFinders.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.name.FqName private fun checkScopeForFinder(scope: GlobalSearchScope, logger: Logger) { - if (scope != GlobalSearchScope.EMPTY_SCOPE && scope.getProject() == null) { + if (scope != GlobalSearchScope.EMPTY_SCOPE && scope.project == null) { logger.warn("Scope with null project " + scope) } } @@ -43,7 +43,7 @@ private fun findVirtualFileWithHeader(classId: ClassId, key: ID, s return files.iterator().next() } -public class JsIDEVirtualFileFinder(private val scope: GlobalSearchScope) : JsVirtualFileFinder { +class JsIDEVirtualFileFinder(private val scope: GlobalSearchScope) : JsVirtualFileFinder { init { checkScopeForFinder(scope, LOG) } @@ -55,7 +55,7 @@ public class JsIDEVirtualFileFinder(private val scope: GlobalSearchScope) : JsVi } } -public class JvmIDEVirtualFileFinder(private val scope: GlobalSearchScope) : VirtualFileKotlinClassFinder(), JvmVirtualFileFinder { +class JvmIDEVirtualFileFinder(private val scope: GlobalSearchScope) : VirtualFileKotlinClassFinder(), JvmVirtualFileFinder { init { checkScopeForFinder(scope, LOG) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileIndexes.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileIndexes.kt index 1fa3a4b4b20..33ed9a9f931 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileIndexes.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/fileIndexes.kt @@ -29,7 +29,7 @@ import java.io.DataOutput import java.util.* abstract class KotlinFileIndexBase(private val classOfIndex: Class) : ScalarIndexExtension() { - public val KEY: ID = ID.create(classOfIndex.canonicalName) + val KEY: ID = ID.create(classOfIndex.canonicalName) private val KEY_DESCRIPTOR : KeyDescriptor = object : KeyDescriptor { override fun save(output: DataOutput, value: FqName) = output.writeUTF(value.asString()) @@ -67,7 +67,7 @@ abstract class KotlinFileIndexBase(private val classOfIndex: Class) : Scal } } -public object KotlinClassFileIndex : KotlinFileIndexBase(KotlinClassFileIndex::class.java) { +object KotlinClassFileIndex : KotlinFileIndexBase(KotlinClassFileIndex::class.java) { override fun getIndexer() = INDEXER @@ -83,7 +83,7 @@ public object KotlinClassFileIndex : KotlinFileIndexBase(K } } -public object KotlinJavaScriptMetaFileIndex : KotlinFileIndexBase(KotlinJavaScriptMetaFileIndex::class.java) { +object KotlinJavaScriptMetaFileIndex : KotlinFileIndexBase(KotlinJavaScriptMetaFileIndex::class.java) { override fun getIndexer() = INDEXER diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/moduleMappingIndexes.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/moduleMappingIndexes.kt index d390558d650..1a3fdc711d6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/moduleMappingIndexes.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/vfilefinder/moduleMappingIndexes.kt @@ -25,11 +25,11 @@ import org.jetbrains.kotlin.load.kotlin.PackageParts import java.io.DataInput import java.io.DataOutput -public object KotlinModuleMappingIndex : FileBasedIndexExtension() { +object KotlinModuleMappingIndex : FileBasedIndexExtension() { - private val classOfIndex = KotlinModuleMappingIndex::class.java.getCanonicalName() + private val classOfIndex = KotlinModuleMappingIndex::class.java.canonicalName - public val KEY: ID = ID.create(classOfIndex) + val KEY: ID = ID.create(classOfIndex) private val KEY_DESCRIPTOR = object : KeyDescriptor { override fun save(output: DataOutput, value: String) = output.writeUTF(value) @@ -79,7 +79,7 @@ public object KotlinModuleMappingIndex : FileBasedIndexExtension { return object : DataIndexer { override fun map(inputData: FileContent): Map { - val content = inputData.getContent() + val content = inputData.content try { val moduleMapping = ModuleMapping.create(content) return moduleMapping.packageFqName2Parts diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/plugin/references/SimpleNameReferenceExtension.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/plugin/references/SimpleNameReferenceExtension.kt index 943d054457a..e5bde18c4dc 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/plugin/references/SimpleNameReferenceExtension.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/plugin/references/SimpleNameReferenceExtension.kt @@ -21,9 +21,9 @@ import org.jetbrains.kotlin.idea.references.KtSimpleNameReference import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtPsiFactory -public interface SimpleNameReferenceExtension { +interface SimpleNameReferenceExtension { companion object { - public val EP_NAME: ExtensionPointName = + val EP_NAME: ExtensionPointName = ExtensionPointName.create("org.jetbrains.kotlin.simpleNameReferenceExtension") } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt index 975557b51c0..886802b684b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt @@ -74,9 +74,9 @@ class AllClassesCompletion(private val parameters: CompletionParameters, if (psiClass.isSyntheticKotlinClass()) return@processJavaClasses // filter out synthetic classes produced by Kotlin compiler val kind = when { - psiClass.isAnnotationType() -> ClassKind.ANNOTATION_CLASS - psiClass.isInterface() -> ClassKind.INTERFACE - psiClass.isEnum() -> ClassKind.ENUM_CLASS + psiClass.isAnnotationType -> ClassKind.ANNOTATION_CLASS + psiClass.isInterface -> ClassKind.INTERFACE + psiClass.isEnum -> ClassKind.ENUM_CLASS else -> ClassKind.CLASS } if (kindFilter(kind)) { @@ -87,7 +87,7 @@ class AllClassesCompletion(private val parameters: CompletionParameters, } private fun PsiClass.isSyntheticKotlinClass(): Boolean { - if (!getName()!!.contains('$')) return false // optimization to not analyze annotations of all classes - return getModifierList()?.findAnnotation(kotlin.jvm.internal.KotlinSyntheticClass::class.java.getName()) != null + if (!name!!.contains('$')) return false // optimization to not analyze annotations of all classes + return modifierList?.findAnnotation(kotlin.jvm.internal.KotlinSyntheticClass::class.java.name) != null } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt index 3a130cd40ba..b844438e78b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt @@ -40,7 +40,7 @@ class BasicLookupElementFactory( private val project: Project, val insertHandlerProvider: InsertHandlerProvider ) { - public fun createLookupElement( + fun createLookupElement( descriptor: DeclarationDescriptor, qualifyNestedClasses: Boolean = false, includeClassTypeArguments: Boolean = true, @@ -54,25 +54,25 @@ class BasicLookupElementFactory( return createLookupElement(_descriptor, declaration, qualifyNestedClasses, includeClassTypeArguments, parametersAndTypeGrayed) } - public fun createLookupElementForJavaClass(psiClass: PsiClass, qualifyNestedClasses: Boolean = false, includeClassTypeArguments: Boolean = true): LookupElement { + fun createLookupElementForJavaClass(psiClass: PsiClass, qualifyNestedClasses: Boolean = false, includeClassTypeArguments: Boolean = true): LookupElement { val lookupObject = object : DeclarationLookupObjectImpl(null, psiClass) { override fun getIcon(flags: Int) = psiClass.getIcon(flags) } - var element = LookupElementBuilder.create(lookupObject, psiClass.getName()!!) + var element = LookupElementBuilder.create(lookupObject, psiClass.name!!) .withInsertHandler(KotlinClassifierInsertHandler) - val typeParams = psiClass.getTypeParameters() + val typeParams = psiClass.typeParameters if (includeClassTypeArguments && typeParams.isNotEmpty()) { - element = element.appendTailText(typeParams.map { it.getName() }.joinToString(", ", "<", ">"), true) + element = element.appendTailText(typeParams.map { it.name }.joinToString(", ", "<", ">"), true) } - val qualifiedName = psiClass.getQualifiedName()!! + val qualifiedName = psiClass.qualifiedName!! var containerName = qualifiedName.substringBeforeLast('.', FqName.ROOT.toString()) if (qualifyNestedClasses) { val nestLevel = psiClass.parents.takeWhile { it is PsiClass }.count() if (nestLevel > 0) { - var itemText = psiClass.getName() + var itemText = psiClass.name for (i in 1..nestLevel) { val outerClassName = containerName.substringAfterLast('.') element = element.withLookupString(outerClassName) @@ -92,12 +92,12 @@ class BasicLookupElementFactory( return element.withIconFromLookupObject() } - public fun createLookupElementForPackage(name: FqName): LookupElement { + fun createLookupElementForPackage(name: FqName): LookupElement { var element = LookupElementBuilder.create(PackageLookupObject(name), name.shortName().asString()) element = element.withInsertHandler(BaseDeclarationInsertHandler()) - if (!name.parent().isRoot()) { + if (!name.parent().isRoot) { element = element.appendTailText(" (${name.asString()})", true) } @@ -131,14 +131,14 @@ class BasicLookupElementFactory( val nameAndIconDescriptor: DeclarationDescriptor val iconDeclaration: PsiElement? if (descriptor is ConstructorDescriptor) { - nameAndIconDescriptor = descriptor.getContainingDeclaration() + nameAndIconDescriptor = descriptor.containingDeclaration iconDeclaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, nameAndIconDescriptor) } else { nameAndIconDescriptor = descriptor iconDeclaration = declaration } - val name = nameAndIconDescriptor.getName().asString() + val name = nameAndIconDescriptor.name.asString() val lookupObject = object : DeclarationLookupObjectImpl(descriptor, declaration) { override fun getIcon(flags: Int) = KotlinDescriptorIconProvider.getIcon(nameAndIconDescriptor, iconDeclaration, flags) @@ -150,7 +150,7 @@ class BasicLookupElementFactory( when (descriptor) { is FunctionDescriptor -> { - val returnType = descriptor.getReturnType() + val returnType = descriptor.returnType element = element.withTypeText(if (returnType != null) DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(returnType) else "", parametersAndTypeGrayed) val insertsLambda = (insertHandler as? KotlinFunctionInsertHandler.Normal)?.lambdaInfo != null @@ -162,16 +162,16 @@ class BasicLookupElementFactory( } is VariableDescriptor -> { - element = element.withTypeText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(descriptor.getType()), parametersAndTypeGrayed) + element = element.withTypeText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(descriptor.type), parametersAndTypeGrayed) } is ClassDescriptor -> { val typeParams = descriptor.declaredTypeParameters if (includeClassTypeArguments && typeParams.isNotEmpty()) { - element = element.appendTailText(typeParams.map { it.getName().asString() }.joinToString(", ", "<", ">"), true) + element = element.appendTailText(typeParams.map { it.name.asString() }.joinToString(", ", "<", ">"), true) } - var container = descriptor.getContainingDeclaration() + var container = descriptor.containingDeclaration if (qualifyNestedClasses) { element = element.withPresentableText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderClassifierName(descriptor)) @@ -181,7 +181,7 @@ class BasicLookupElementFactory( if (!containerName.isSpecial) { element = element.withLookupString(containerName.asString()) } - container = container.getContainingDeclaration() + container = container.containingDeclaration } } @@ -220,12 +220,12 @@ class BasicLookupElementFactory( return element.withIconFromLookupObject() } - public fun appendContainerAndReceiverInformation(descriptor: CallableDescriptor, appendTailText: (String) -> Unit) { + fun appendContainerAndReceiverInformation(descriptor: CallableDescriptor, appendTailText: (String) -> Unit) { val extensionReceiver = descriptor.original.extensionReceiverParameter when { descriptor is SyntheticJavaPropertyDescriptor -> { - var from = descriptor.getMethod.getName().asString() + "()" - descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" } + var from = descriptor.getMethod.name.asString() + "()" + descriptor.setMethod?.let { from += "/" + it.name.asString() + "()" } appendTailText(" (from $from)") } @@ -237,7 +237,7 @@ class BasicLookupElementFactory( val receiverPresentation = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(extensionReceiver.type) appendTailText(" for $receiverPresentation") - val container = descriptor.getContainingDeclaration() + val container = descriptor.containingDeclaration val containerPresentation = if (container is ClassDescriptor) DescriptorUtils.getFqNameFromTopLevelClass(container).toString() else if (container is PackageFragmentDescriptor) @@ -250,7 +250,7 @@ class BasicLookupElementFactory( } else -> { - val container = descriptor.getContainingDeclaration() + val container = descriptor.containingDeclaration if (container is PackageFragmentDescriptor) { // we show container only for global functions and properties //TODO: it would be probably better to show it also for static declarations which are not from the current class (imported) @@ -265,7 +265,7 @@ class BasicLookupElementFactory( return object : LookupElementDecorator(this) { override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(this@withIconFromLookupObject, presentation.isReal())) + presentation.icon = DefaultLookupItemRenderer.getRawIcon(this@withIconFromLookupObject, presentation.isReal) } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index f9a819dd8fd..0bde5d13648 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -72,22 +72,22 @@ abstract class CompletionSession( protected val parameters: CompletionParameters, resultSet: CompletionResultSet ) { - protected val position = parameters.getPosition() - protected val file = position.getContainingFile() as KtFile + protected val position = parameters.position + protected val file = position.containingFile as KtFile protected val resolutionFacade = file.getResolutionFacade() protected val moduleDescriptor = resolutionFacade.moduleDescriptor - protected val project = position.getProject() + protected val project = position.project protected val isJvmModule = !ProjectStructureUtil.isJsKotlinModule(parameters.originalFile as KtFile) protected val nameExpression: KtSimpleNameExpression? protected val expression: KtExpression? init { - val reference = (position.getParent() as? KtSimpleNameExpression)?.mainReference + val reference = (position.parent as? KtSimpleNameExpression)?.mainReference if (reference != null) { if (reference.expression is KtLabelReferenceExpression) { this.nameExpression = null - this.expression = reference.expression.getParent().getParent() as? KtExpressionWithLabel + this.expression = reference.expression.parent.parent as? KtExpressionWithLabel } else { this.nameExpression = reference.expression @@ -107,8 +107,8 @@ abstract class CompletionSession( private val kotlinIdentifierPartPattern = StandardPatterns.character().javaIdentifierPart().andNot(singleCharPattern('$')) protected val prefix = CompletionUtil.findIdentifierPrefix( - parameters.getPosition().getContainingFile(), - parameters.getOffset(), + parameters.position.containingFile, + parameters.offset, kotlinIdentifierPartPattern or singleCharPattern('@'), kotlinIdentifierStartPattern) @@ -151,7 +151,7 @@ abstract class CompletionSession( // we need to exclude the original file from scope because our resolve session is built with this file replaced by synthetic one protected val searchScope: GlobalSearchScope = object : DelegatingGlobalSearchScope(originalSearchScope) { - override fun contains(file: VirtualFile) = super.contains(file) && file != parameters.getOriginalFile().getVirtualFile() + override fun contains(file: VirtualFile) = super.contains(file) && file != parameters.originalFile.virtualFile } protected fun indicesHelper(mayIncludeInaccessible: Boolean): KotlinIndicesHelper { @@ -208,12 +208,12 @@ abstract class CompletionSession( } private fun isTypeParameterVisible(typeParameter: TypeParameterDescriptor): Boolean { - val owner = typeParameter.getContainingDeclaration() + val owner = typeParameter.containingDeclaration var parent: DeclarationDescriptor? = inDescriptor while (parent != null) { if (parent == owner) return true - if (parent is ClassDescriptor && !parent.isInner()) return false - parent = parent.getContainingDeclaration() + if (parent is ClassDescriptor && !parent.isInner) return false + parent = parent.containingDeclaration } return true } @@ -222,7 +222,7 @@ abstract class CompletionSession( collector.flushToResultSet() } - public fun complete(): Boolean { + fun complete(): Boolean { val statisticsContext = calcContextForStatisticsInfo() if (statisticsContext != null) { collector.addLookupElementPostProcessor { lookupElement -> @@ -237,7 +237,7 @@ abstract class CompletionSession( return !collector.isResultEmpty } - public fun addLookupElementPostProcessor(processor: (LookupElement) -> LookupElement) { + fun addLookupElementPostProcessor(processor: (LookupElement) -> LookupElement) { collector.addLookupElementPostProcessor(processor) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index 94b35a8db1a..3589524ec8c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -102,10 +102,10 @@ fun LookupElement.keepOldArgumentListOnTab(): LookupElement { } fun rethrowWithCancelIndicator(exception: ProcessCanceledException): ProcessCanceledException { - val indicator = CompletionService.getCompletionService().getCurrentCompletion() as CompletionProgressIndicator + val indicator = CompletionService.getCompletionService().currentCompletion as CompletionProgressIndicator // Force cancel to avoid deadlock in CompletionThreading.delegateWeighing() - if (!indicator.isCanceled()) { + if (!indicator.isCanceled) { indicator.cancel() } @@ -113,12 +113,12 @@ fun rethrowWithCancelIndicator(exception: ProcessCanceledException): ProcessCanc } fun PrefixMatcher.asNameFilter() = { name: Name -> - if (name.isSpecial()) { + if (name.isSpecial) { false } else { - val identifier = name.getIdentifier() - if (getPrefix().startsWith("$")) { // we need properties from scope for backing field completion + val identifier = name.identifier + if (prefix.startsWith("$")) { // we need properties from scope for backing field completion prefixMatches("$" + identifier) } else { @@ -128,10 +128,10 @@ fun PrefixMatcher.asNameFilter() = { name: Name -> } fun LookupElementPresentation.prependTailText(text: String, grayed: Boolean) { - val tails = getTailFragments() + val tails = tailFragments clearTail() appendTailText(text, grayed) - tails.forEach { appendTailText(it.text, it.isGrayed()) } + tails.forEach { appendTailText(it.text, it.isGrayed) } } enum class CallableWeight { @@ -148,8 +148,8 @@ enum class CallableWeight { val CALLABLE_WEIGHT_KEY = Key("CALLABLE_WEIGHT_KEY") fun InsertionContext.isAfterDot(): Boolean { - var offset = getStartOffset() - val chars = getDocument().getCharsSequence() + var offset = startOffset + val chars = document.charsSequence while (offset > 0) { offset-- val c = chars[offset] @@ -162,7 +162,7 @@ fun InsertionContext.isAfterDot(): Boolean { // do not complete this items by prefix like "is" fun shouldCompleteThisItems(prefixMatcher: PrefixMatcher): Boolean { - val prefix = prefixMatcher.getPrefix() + val prefix = prefixMatcher.prefix val s = "this@" return prefix.startsWith(s) || s.startsWith(prefix) } @@ -200,7 +200,7 @@ fun returnExpressionItems(bindingContext: BindingContext, position: KtElement): } // check if the current function literal is inlined and stop processing outer declarations if it's not - val callee = call?.getCalleeExpression() as? KtReferenceExpression ?: break // not inlined + val callee = call?.calleeExpression as? KtReferenceExpression ?: break // not inlined if (!InlineUtil.isInline(bindingContext[BindingContext.REFERENCE_TARGET, callee])) break // not inlined } else { @@ -233,7 +233,7 @@ fun returnExpressionItems(bindingContext: BindingContext, position: KtElement): private fun KtDeclarationWithBody.returnType(bindingContext: BindingContext): KotlinType? { val callable = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? CallableDescriptor ?: return null - return callable.getReturnType() + return callable.returnType } private fun Name?.labelNameToTail(): String = if (this != null) "@" + render() else "" @@ -248,7 +248,7 @@ private fun createKeywordElementWithSpace( return if (addSpaceAfter) { object: LookupElementDecorator(element) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.SPACE.handleInsert(context, getDelegate()) + WithTailInsertHandler.SPACE.handleInsert(context, delegate) } } } @@ -295,7 +295,7 @@ fun breakOrContinueExpressionItems(position: KtElement, breakOrContinue: String) } fun BasicLookupElementFactory.createLookupElementForType(type: KotlinType): LookupElement? { - if (type.isError()) return null + if (type.isError) return null if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type)) { val text = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(type) @@ -303,7 +303,7 @@ fun BasicLookupElementFactory.createLookupElementForType(type: KotlinType): Look return BaseTypeLookupElement(type, baseLookupElement) } else { - val classifier = type.getConstructor().getDeclarationDescriptor() ?: return null + val classifier = type.constructor.declarationDescriptor ?: return null val baseLookupElement = createLookupElement(classifier, qualifyNestedClasses = true, includeClassTypeArguments = false) val itemText = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(type) @@ -311,7 +311,7 @@ fun BasicLookupElementFactory.createLookupElementForType(type: KotlinType): Look val typeLookupElement = object : BaseTypeLookupElement(type, baseLookupElement) { override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setItemText(itemText) + presentation.itemText = itemText } } @@ -330,13 +330,13 @@ private open class BaseTypeLookupElement(type: KotlinType, baseLookupElement: Lo override fun hashCode() = fullText.hashCode() override fun renderElement(presentation: LookupElementPresentation) { - getDelegate().renderElement(presentation) + delegate.renderElement(presentation) } override fun handleInsert(context: InsertionContext) { - context.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), fullText) - context.setTailOffset(context.getStartOffset() + fullText.length) - shortenReferences(context, context.getStartOffset(), context.getTailOffset()) + context.document.replaceString(context.startOffset, context.tailOffset, fullText) + context.tailOffset = context.startOffset + fullText.length + shortenReferences(context, context.startOffset, context.tailOffset) } } @@ -361,7 +361,7 @@ fun LookupElement.decorateAsStaticMember( else container - val qualifierPresentation = classDescriptor.getName().asString() + val qualifierPresentation = classDescriptor.name.asString() val qualifierText = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(classDescriptor) return object: LookupElementDecorator(this) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt index 40e3da194d0..dc070d3235b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ContextVariablesProvider.kt @@ -61,7 +61,7 @@ class RealContextVariablesProvider( class CollectRequiredTypesContextVariablesProvider : ContextVariablesProvider { private val _requiredTypes = HashSet() - public val requiredTypes: Set + val requiredTypes: Set get() = _requiredTypes override fun functionTypeVariables(requiredType: FuzzyType): Collection> { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DataFlowInfoUtilForCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DataFlowInfoUtilForCompletion.kt index baae0ecc73b..ac3b66582a7 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DataFlowInfoUtilForCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DataFlowInfoUtilForCompletion.kt @@ -28,9 +28,9 @@ fun renderDataFlowValue(value: DataFlowValue): String? { fun renderId(id: Any?): String? { return when (id) { - is KtExpression -> id.getText() - is ImplicitReceiver -> "this@${id.declarationDescriptor.getName()}" - is VariableDescriptor -> id.getName().asString() + is KtExpression -> id.text + is ImplicitReceiver -> "this@${id.declarationDescriptor.name}" + is VariableDescriptor -> id.name.asString() is PackageViewDescriptor -> id.fqName.asString() is com.intellij.openapi.util.Pair<*, *> -> renderId(id.first) + "." + renderId(id.second) else -> null diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt index 7ae5a4451b1..d5366f883ef 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt @@ -33,29 +33,29 @@ import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution * Stores information about resolved descriptor and position of that descriptor. * Position will be used for sorting */ -public abstract class DeclarationLookupObjectImpl( - public final override val descriptor: DeclarationDescriptor?, - public final override val psiElement: PsiElement? +abstract class DeclarationLookupObjectImpl( + final override val descriptor: DeclarationDescriptor?, + final override val psiElement: PsiElement? ): DeclarationLookupObject { init { assert(descriptor != null || psiElement != null) } override val name: Name? - get() = descriptor?.getName() ?: (psiElement as? PsiNamedElement)?.getName()?.let { Name.identifier(it) } + get() = descriptor?.name ?: (psiElement as? PsiNamedElement)?.name?.let { Name.identifier(it) } override val importableFqName: FqName? get() { return if (descriptor != null) descriptor.importableFqName else - (psiElement as? PsiClass)?.getQualifiedName()?.let { FqName(it) } + (psiElement as? PsiClass)?.qualifiedName?.let { FqName(it) } } override fun toString() = super.toString() + " " + (descriptor ?: psiElement) override fun hashCode(): Int { - return if (descriptor != null) descriptor.getOriginal().hashCode() else psiElement!!.hashCode() + return if (descriptor != null) descriptor.original.hashCode() else psiElement!!.hashCode() } override fun equals(other: Any?): Boolean { @@ -65,5 +65,5 @@ public abstract class DeclarationLookupObjectImpl( return descriptorsEqualWithSubstitution(descriptor, lookupObject.descriptor) && psiElement == lookupObject.psiElement } - override val isDeprecated = if (descriptor != null) KotlinBuiltIns.isDeprecated(descriptor) else (psiElement as? PsiDocCommentOwner)?.isDeprecated() ?: false + override val isDeprecated = if (descriptor != null) KotlinBuiltIns.isDeprecated(descriptor) else (psiElement as? PsiDocCommentOwner)?.isDeprecated ?: false } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt index d0bd00220bc..0f34b9f9378 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt @@ -34,7 +34,7 @@ class InsertHandlerProvider( ) { private val expectedInfos by lazy(LazyThreadSafetyMode.NONE) { expectedInfosCalculator() } - public fun insertHandler(descriptor: DeclarationDescriptor): InsertHandler { + fun insertHandler(descriptor: DeclarationDescriptor): InsertHandler { if (callType == null) { error("Cannot create InsertHandler when no CallType known") } @@ -50,7 +50,7 @@ class InsertHandlerProvider( 1 -> { if (callType != CallType.SUPER_MEMBERS) { // for super call we don't suggest to generate "super.foo { ... }" (seems to be non-typical use) - val parameterType = parameters.single().getType() + val parameterType = parameters.single().type if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size if (parameterCount <= 1) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt index 725b02e4ee7..496b26c73a9 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt @@ -69,7 +69,7 @@ class KDocNameCompletionSession(parameters: CompletionParameters, override val expectedInfos: Collection get() = emptyList() override fun doComplete() { - val position = parameters.getPosition().getParentOfType(false) ?: return + val position = parameters.position.getParentOfType(false) ?: return val declaration = position.getContainingDoc().getOwner() ?: return val kdocLink = position.getStrictParentOfType()!! val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]!! @@ -98,7 +98,7 @@ class KDocNameCompletionSession(parameters: CompletionParameters, fun isApplicable(descriptor: DeclarationDescriptor): Boolean { if (descriptor is CallableDescriptor) { - val extensionReceiver = descriptor.getExtensionReceiverParameter() + val extensionReceiver = descriptor.extensionReceiverParameter if (extensionReceiver != null) { val substituted = descriptor.substituteExtensionIfCallable(implicitReceivers, bindingContext, DataFlowInfo.EMPTY, CallType.DEFAULT, moduleDescriptor) @@ -123,8 +123,8 @@ object KDocTagCompletionProvider: CompletionProvider() { override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) { // findIdentifierPrefix() requires identifier part characters to be a superset of identifier start characters val prefix = CompletionUtil.findIdentifierPrefix( - parameters.getPosition().getContainingFile(), - parameters.getOffset(), + parameters.position.containingFile, + parameters.offset, StandardPatterns.character().javaIdentifierPart() or singleCharPattern('@'), StandardPatterns.character().javaIdentifierStart() or singleCharPattern('@')) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordCompletion.kt index be7aad94fcc..4c199335028 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordCompletion.kt @@ -45,7 +45,7 @@ open class KeywordLookupObject object KeywordCompletion { private val NON_ACTUAL_KEYWORDS = setOf(TYPE_ALIAS_KEYWORD) - private val ALL_KEYWORDS = (KEYWORDS.getTypes() + SOFT_KEYWORDS.getTypes()) + private val ALL_KEYWORDS = (KEYWORDS.types + SOFT_KEYWORDS.types) .filter { it !in NON_ACTUAL_KEYWORDS } .map { it as KtKeywordToken } @@ -57,18 +57,18 @@ object KeywordCompletion { ANNOTATION_KEYWORD to CLASS_KEYWORD ) - public fun complete(position: PsiElement, prefix: String, isJvmModule: Boolean, consumer: (LookupElement) -> Unit) { + fun complete(position: PsiElement, prefix: String, isJvmModule: Boolean, consumer: (LookupElement) -> Unit) { if (!GENERAL_FILTER.isAcceptable(position, position)) return val parserFilter = buildFilter(position) for (keywordToken in ALL_KEYWORDS) { - var keyword = keywordToken.getValue() + var keyword = keywordToken.value val nextKeyword = COMPOUND_KEYWORDS[keywordToken] if (nextKeyword != null) { fun PsiElement.isSpace() = this is PsiWhiteSpace && '\n' !in getText() - var next = position.nextLeaf { !(it.isSpace() || it.getText() == "$") }?.getText() + var next = position.nextLeaf { !(it.isSpace() || it.text == "$") }?.text if (next != null && next.startsWith("$")) { next = next.substring(1) } @@ -128,13 +128,13 @@ object KeywordCompletion { } override fun isAcceptable(element : Any?, context : PsiElement?) : Boolean { - val parent = (element as? PsiElement)?.getParent() - return parent != null && (getFilter()?.isAcceptable(parent, context) ?: true) + val parent = (element as? PsiElement)?.parent + return parent != null && (filter?.isAcceptable(parent, context) ?: true) } } private fun buildFilter(position: PsiElement): (KtKeywordToken) -> Boolean { - var parent = position.getParent() + var parent = position.parent var prevParent = position while (parent != null) { when (parent) { @@ -143,14 +143,14 @@ object KeywordCompletion { } is KtWithExpressionInitializer -> { - val initializer = parent.getInitializer() + val initializer = parent.initializer if (prevParent == initializer) { return buildFilterWithContext("val v = ", initializer!!, position) } } is KtParameter -> { - val default = parent.getDefaultValue() + val default = parent.defaultValue if (prevParent == default) { return buildFilterWithContext("val v = ", default!!, position) } @@ -184,8 +184,8 @@ object KeywordCompletion { contextElement: PsiElement, position: PsiElement): (KtKeywordToken) -> Boolean { val offset = position.getStartOffsetInAncestor(contextElement) - val truncatedContext = contextElement.getText()!!.substring(0, offset) - return buildFilterByText(prefixText + truncatedContext, contextElement.getProject()) + val truncatedContext = contextElement.text!!.substring(0, offset) + return buildFilterByText(prefixText + truncatedContext, contextElement.project) } private fun buildFilterWithReducedContext(prefixText: String, @@ -193,7 +193,7 @@ object KeywordCompletion { position: PsiElement): (KtKeywordToken) -> Boolean { val builder = StringBuilder() buildReducedContextBefore(builder, position, contextElement) - return buildFilterByText(prefixText + builder.toString(), position.getProject()) + return buildFilterByText(prefixText + builder.toString(), position.project) } @@ -201,11 +201,11 @@ object KeywordCompletion { val psiFactory = KtPsiFactory(project) return fun (keywordTokenType): Boolean { val postfix = if (prefixText.endsWith("@")) ":X" else " X" - val file = psiFactory.createFile(prefixText + keywordTokenType.getValue() + postfix) + val file = psiFactory.createFile(prefixText + keywordTokenType.value + postfix) val elementAt = file.findElementAt(prefixText.length)!! when { - !elementAt.getNode()!!.getElementType().matchesKeyword(keywordTokenType) -> return false + !elementAt.node!!.elementType.matchesKeyword(keywordTokenType) -> return false elementAt.getNonStrictParentOfType() != null -> return false @@ -289,13 +289,13 @@ object KeywordCompletion { // builds text within scope (or from the start of the file) before position element excluding almost all declarations private fun buildReducedContextBefore(builder: StringBuilder, position: PsiElement, scope: PsiElement?) { if (position == scope) return - val parent = position.getParent() ?: return + val parent = position.parent ?: return buildReducedContextBefore(builder, parent, scope) val prevDeclaration = position.siblings(forward = false, withItself = false).firstOrNull { it is KtDeclaration } - var child = parent.getFirstChild() + var child = parent.firstChild while (child != position) { if (child is KtDeclaration) { if (child == prevDeclaration) { @@ -303,17 +303,17 @@ object KeywordCompletion { } } else { - builder.append(child!!.getText()) + builder.append(child!!.text) } - child = child.getNextSibling() + child = child.nextSibling } } private fun StringBuilder.appendReducedText(element: PsiElement) { - var child = element.getFirstChild() + var child = element.firstChild if (child == null) { - append(element.getText()!!) + append(element.text!!) } else { while (child != null) { @@ -322,13 +322,13 @@ object KeywordCompletion { else -> appendReducedText(child) } - child = child.getNextSibling() + child = child.nextSibling } } } private fun PsiElement.getStartOffsetInAncestor(ancestor: PsiElement): Int { if (ancestor == this) return 0 - return getParent()!!.getStartOffsetInAncestor(ancestor) + getStartOffsetInParent() + return parent!!.getStartOffsetInAncestor(ancestor) + startOffsetInParent } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt index d11f753eb77..cb464153c32 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt @@ -83,7 +83,7 @@ object KeywordValues { } val nullMatcher = { info: ExpectedInfo -> - if (info.fuzzyType != null && info.fuzzyType!!.type.isMarkedNullable()) + if (info.fuzzyType != null && info.fuzzyType!!.type.isMarkedNullable) ExpectedInfoMatch.match(TypeSubstitutor.EMPTY) else ExpectedInfoMatch.noMatch diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionCharFilter.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionCharFilter.kt index a3489776126..40747763c09 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionCharFilter.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionCharFilter.kt @@ -30,33 +30,33 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFunctionLiteral import org.jetbrains.kotlin.psi.psiUtil.prevLeaf -public class KotlinCompletionCharFilter() : CharFilter() { +class KotlinCompletionCharFilter() : CharFilter() { companion object { - public val ACCEPT_OPENING_BRACE: Key = Key("KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE") + val ACCEPT_OPENING_BRACE: Key = Key("KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE") - public val SUPPRESS_ITEM_SELECTION_BY_CHARS_ON_TYPING: Key = Key("KotlinCompletionCharFilter.SUPPRESS_ITEM_SELECTION_BY_CHARS_ON_TYPING") - public val HIDE_LOOKUP_ON_COLON: Key = Key("KotlinCompletionCharFilter.HIDE_LOOKUP_ON_COLON") + val SUPPRESS_ITEM_SELECTION_BY_CHARS_ON_TYPING: Key = Key("KotlinCompletionCharFilter.SUPPRESS_ITEM_SELECTION_BY_CHARS_ON_TYPING") + val HIDE_LOOKUP_ON_COLON: Key = Key("KotlinCompletionCharFilter.HIDE_LOOKUP_ON_COLON") - public val JUST_TYPING_PREFIX: Key = Key("KotlinCompletionCharFilter.JUST_TYPING_PREFIX") + val JUST_TYPING_PREFIX: Key = Key("KotlinCompletionCharFilter.JUST_TYPING_PREFIX") } override fun acceptChar(c : Char, prefixLength : Int, lookup : Lookup) : Result? { - if (lookup.getPsiFile() !is KtFile) return null - if (!lookup.isCompletion()) return null + if (lookup.psiFile !is KtFile) return null + if (!lookup.isCompletion) return null // it does not work in tests, so we use other way // val isAutopopup = CompletionService.getCompletionService().getCurrentCompletion().isAutopopupCompletion() - val completionParameters = (CompletionService.getCompletionService().getCurrentCompletion() as CompletionProgressIndicator).getParameters() - val isAutopopup = completionParameters.getInvocationCount() == 0 + val completionParameters = (CompletionService.getCompletionService().currentCompletion as CompletionProgressIndicator).parameters + val isAutopopup = completionParameters.invocationCount == 0 if (Character.isJavaIdentifierPart(c) || c == '@') { return CharFilter.Result.ADD_TO_PREFIX } - val currentItem = lookup.getCurrentItem() + val currentItem = lookup.currentItem // do not accept items by special chars in some special positions such as in the very beginning of function literal where name of the first parameter can be - if (isAutopopup && !lookup.isSelectionTouched() - && (currentItem?.getUserData(SUPPRESS_ITEM_SELECTION_BY_CHARS_ON_TYPING) != null || isInFunctionLiteralStart(completionParameters.getPosition()))) { + if (isAutopopup && !lookup.isSelectionTouched + && (currentItem?.getUserData(SUPPRESS_ITEM_SELECTION_BY_CHARS_ON_TYPING) != null || isInFunctionLiteralStart(completionParameters.position))) { return Result.HIDE_LOOKUP } @@ -67,15 +67,15 @@ public class KotlinCompletionCharFilter() : CharFilter() { } } - if (!lookup.isSelectionTouched()) { + if (!lookup.isSelectionTouched) { currentItem?.putUserDataDeep(JUST_TYPING_PREFIX, lookup.itemPattern(currentItem)) } return when (c) { '.' -> { - if (prefixLength == 0 && isAutopopup && !lookup.isSelectionTouched()) { - val caret = lookup.getEditor().getCaretModel().getOffset() - if (caret > 0 && lookup.getEditor().getDocument().getCharsSequence()[caret - 1] == '.') { + if (prefixLength == 0 && isAutopopup && !lookup.isSelectionTouched) { + val caret = lookup.editor.caretModel.offset + if (caret > 0 && lookup.editor.document.charsSequence[caret - 1] == '.') { return Result.HIDE_LOOKUP } } @@ -97,11 +97,11 @@ public class KotlinCompletionCharFilter() : CharFilter() { private fun isInFunctionLiteralStart(position: PsiElement): Boolean { var prev = position.prevLeaf { it !is PsiWhiteSpace && it !is PsiComment } - if (prev?.getNode()?.getElementType() == KtTokens.LPAR) { + if (prev?.node?.elementType == KtTokens.LPAR) { prev = prev?.prevLeaf { it !is PsiWhiteSpace && it !is PsiComment } } - if (prev?.getNode()?.getElementType() != KtTokens.LBRACE) return false - val functionLiteral = prev!!.getParent() as? KtFunctionLiteral ?: return false - return functionLiteral.getLBrace() == prev + if (prev?.node?.elementType != KtTokens.LBRACE) return false + val functionLiteral = prev!!.parent as? KtFunctionLiteral ?: return false + return functionLiteral.lBrace == prev } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt index 2bb66385f25..87fb50df290 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt @@ -45,14 +45,14 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.addToStdlib.check import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -public var KtFile.doNotComplete: Boolean? by UserDataProperty(Key.create("DO_NOT_COMPLETE")) +var KtFile.doNotComplete: Boolean? by UserDataProperty(Key.create("DO_NOT_COMPLETE")) -public class KotlinCompletionContributor : CompletionContributor() { +class KotlinCompletionContributor : CompletionContributor() { private val AFTER_NUMBER_LITERAL = psiElement().afterLeafSkipping(psiElement().withText(""), psiElement().withElementType(elementType().oneOf(KtTokens.FLOAT_LITERAL, KtTokens.INTEGER_LITERAL))) private val AFTER_INTEGER_LITERAL_AND_DOT = psiElement().afterLeafSkipping(psiElement().withText("."), psiElement().withElementType(elementType().oneOf(KtTokens.INTEGER_LITERAL))) companion object { - public val DEFAULT_DUMMY_IDENTIFIER: String = CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + "$" // add '$' to ignore context after the caret + val DEFAULT_DUMMY_IDENTIFIER: String = CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + "$" // add '$' to ignore context after the caret private val STRING_TEMPLATE_AFTER_DOT_REAL_START_OFFSET = OffsetKey.create("STRING_TEMPLATE_AFTER_DOT_REAL_START_OFFSET") } @@ -68,13 +68,13 @@ public class KotlinCompletionContributor : CompletionContributor() { } override fun beforeCompletion(context: CompletionInitializationContext) { - val psiFile = context.getFile() + val psiFile = context.file if (psiFile !is KtFile) return // this code will make replacement offset "modified" and prevents altering it by the code in CompletionProgressIndicator context.replacementOffset = context.replacementOffset - val offset = context.getStartOffset() + val offset = context.startOffset val tokenBefore = psiFile.findElementAt(Math.max(0, offset - 1)) if (offset > 0 && tokenBefore!!.node.elementType == KtTokens.REGULAR_STRING_PART && tokenBefore.text.startsWith(".")) { @@ -92,7 +92,7 @@ public class KotlinCompletionContributor : CompletionContributor() { } context.dummyIdentifier = when { - context.getCompletionType() == CompletionType.SMART -> DEFAULT_DUMMY_IDENTIFIER + context.completionType == CompletionType.SMART -> DEFAULT_DUMMY_IDENTIFIER PackageDirectiveCompletion.ACTIVATION_PATTERN.accepts(tokenBefore) -> PackageDirectiveCompletion.DUMMY_IDENTIFIER @@ -109,30 +109,30 @@ public class KotlinCompletionContributor : CompletionContributor() { ?: DEFAULT_DUMMY_IDENTIFIER } - if (context.getCompletionType() == CompletionType.SMART && !isAtEndOfLine(offset, context.getEditor().getDocument()) /* do not use parent expression if we are at the end of line - it's probably parsed incorrectly */) { + if (context.completionType == CompletionType.SMART && !isAtEndOfLine(offset, context.editor.document) /* do not use parent expression if we are at the end of line - it's probably parsed incorrectly */) { val tokenAt = psiFile.findElementAt(Math.max(0, offset)) if (tokenAt != null) { - var parent = tokenAt.getParent() + var parent = tokenAt.parent if (parent is KtExpression && parent !is KtBlockExpression) { // search expression to be replaced - go up while we are the first child of parent expression var expression: KtExpression = parent - parent = expression.getParent() + parent = expression.parent while (parent is KtExpression && parent.getFirstChild() == expression) { expression = parent - parent = expression.getParent() + parent = expression.parent } val suggestedReplacementOffset = replacementOffsetByExpression(expression) - if (suggestedReplacementOffset > context.getReplacementOffset()) { - context.setReplacementOffset(suggestedReplacementOffset) + if (suggestedReplacementOffset > context.replacementOffset) { + context.replacementOffset = suggestedReplacementOffset } - context.getOffsetMap().addOffset(SmartCompletion.OLD_ARGUMENTS_REPLACEMENT_OFFSET, expression.endOffset) + context.offsetMap.addOffset(SmartCompletion.OLD_ARGUMENTS_REPLACEMENT_OFFSET, expression.endOffset) - val argumentList = (expression.getParent() as? KtValueArgument)?.getParent() as? KtValueArgumentList + val argumentList = (expression.parent as? KtValueArgument)?.parent as? KtValueArgumentList if (argumentList != null) { - context.getOffsetMap().addOffset(SmartCompletion.MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET, - argumentList.getRightParenthesis()?.getTextRange()?.getStartOffset() ?: argumentList.endOffset) + context.offsetMap.addOffset(SmartCompletion.MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET, + argumentList.rightParenthesis?.textRange?.startOffset ?: argumentList.endOffset) } } } @@ -142,25 +142,25 @@ public class KotlinCompletionContributor : CompletionContributor() { private fun replacementOffsetByExpression(expression: KtExpression): Int { when (expression) { is KtCallExpression -> { - val calleeExpression = expression.getCalleeExpression() + val calleeExpression = expression.calleeExpression if (calleeExpression != null) { - return calleeExpression.getTextRange()!!.getEndOffset() + return calleeExpression.textRange!!.endOffset } } is KtQualifiedExpression -> { - val selector = expression.getSelectorExpression() + val selector = expression.selectorExpression if (selector != null) { return replacementOffsetByExpression(selector) } } } - return expression.getTextRange()!!.getEndOffset() + return expression.textRange!!.endOffset } private fun isInClassHeader(tokenBefore: PsiElement?): Boolean { val classOrObject = tokenBefore?.parents?.firstIsInstanceOrNull() ?: return false - val name = classOrObject.getNameIdentifier() ?: return false + val name = classOrObject.nameIdentifier ?: return false val body = classOrObject.getBody() ?: return false val offset = tokenBefore!!.startOffset return name.endOffset <= offset && offset <= body.startOffset @@ -204,11 +204,11 @@ public class KotlinCompletionContributor : CompletionContributor() { var gtCount = 0 val builder = StringBuilder() while (true) { - val tokenType = token.getNode()!!.getElementType() + val tokenType = token.node!!.elementType if (tokenType in declarationKeywords) { val balance = ltCount - gtCount if (balance < 0) return null - builder.append(token.getText()!!.reversed()) + builder.append(token.text!!.reversed()) builder.reverse() var tail = "X" + ">".repeat(balance) + ".f" @@ -218,16 +218,16 @@ public class KotlinCompletionContributor : CompletionContributor() { builder.append(tail) val text = builder.toString() - val file = KtPsiFactory(tokenBefore.getProject()).createFile(text) - val declaration = file.getDeclarations().singleOrNull() ?: return null - if (declaration.getTextLength() != text.length) return null + val file = KtPsiFactory(tokenBefore.project).createFile(text) + val declaration = file.declarations.singleOrNull() ?: return null + if (declaration.textLength != text.length) return null val containsErrorElement = !PsiTreeUtil.processElements(file, PsiElementProcessor{ it !is PsiErrorElement }) return if (containsErrorElement) null else tail + "$" } if (tokenType !in declarationTokens) return null if (tokenType == KtTokens.LT) ltCount++ if (tokenType == KtTokens.GT) gtCount++ - builder.append(token.getText()!!.reversed()) + builder.append(token.text!!.reversed()) token = PsiTreeUtil.prevLeaf(token) ?: return null } } @@ -270,7 +270,7 @@ public class KotlinCompletionContributor : CompletionContributor() { return } - if (shouldSuppressCompletion(parameters, result.getPrefixMatcher())) { + if (shouldSuppressCompletion(parameters, result.prefixMatcher)) { result.stopHere() return } @@ -292,12 +292,12 @@ public class KotlinCompletionContributor : CompletionContributor() { result.restartCompletionWhenNothingMatches() val configuration = CompletionSessionConfiguration(parameters) - if (parameters.getCompletionType() == CompletionType.BASIC) { + if (parameters.completionType == CompletionType.BASIC) { val session = BasicCompletionSession(configuration, parameters, toFromOriginalFileMapper, result) addPostProcessor(session) - if (parameters.isAutoPopup() && session.shouldDisableAutoPopup()) { + if (parameters.isAutoPopup && session.shouldDisableAutoPopup()) { result.stopHere() return } @@ -356,14 +356,14 @@ public class KotlinCompletionContributor : CompletionContributor() { } private fun shouldSuppressCompletion(parameters: CompletionParameters, prefixMatcher: PrefixMatcher): Boolean { - val position = parameters.getPosition() - val invocationCount = parameters.getInvocationCount() + val position = parameters.position + val invocationCount = parameters.invocationCount // no completion inside number literals if (AFTER_NUMBER_LITERAL.accepts(position)) return true // no completion auto-popup after integer and dot - if (invocationCount == 0 && prefixMatcher.getPrefix().isEmpty() && AFTER_INTEGER_LITERAL_AND_DOT.accepts(position)) return true + if (invocationCount == 0 && prefixMatcher.prefix.isEmpty() && AFTER_INTEGER_LITERAL_AND_DOT.accepts(position)) return true // no auto-popup on typing after "val", "var" and "fun" because it's likely the name of the declaration which is being typed by user if (invocationCount == 0) { @@ -380,11 +380,11 @@ public class KotlinCompletionContributor : CompletionContributor() { } private fun isInExtensionReceiverOf(position: PsiElement): KtCallableDeclaration? { - val nameRef = position.getParent() as? KtNameReferenceExpression ?: return null - val userType = nameRef.getParent() as? KtUserType ?: return null - val typeRef = userType.getParent() as? KtTypeReference ?: return null + val nameRef = position.parent as? KtNameReferenceExpression ?: return null + val userType = nameRef.parent as? KtUserType ?: return null + val typeRef = userType.parent as? KtTypeReference ?: return null if (userType != typeRef.typeElement) return null - val parent = typeRef.getParent() + val parent = typeRef.parent return when (parent) { is KtNamedFunction -> parent.check { typeRef == it.receiverTypeReference } is KtProperty -> parent.check { typeRef == it.receiverTypeReference } @@ -394,7 +394,7 @@ public class KotlinCompletionContributor : CompletionContributor() { private fun isAtEndOfLine(offset: Int, document: Document): Boolean { var i = offset - val chars = document.getCharsSequence() + val chars = document.charsSequence while (i < chars.length) { val c = chars[i] if (c == '\n') return true @@ -415,10 +415,10 @@ public class KotlinCompletionContributor : CompletionContributor() { val (nameToken, balance) = pair assert(balance > 0) - val nameRef = nameToken.getParent() as? KtNameReferenceExpression ?: return null + val nameRef = nameToken.parent as? KtNameReferenceExpression ?: return null val bindingContext = nameRef.getResolutionFacade().analyze(nameRef, BodyResolveMode.PARTIAL) val targets = nameRef.getReferenceTargets(bindingContext) - if (targets.isNotEmpty() && targets.all { it is FunctionDescriptor || it is ClassDescriptor && it.getKind() == ClassKind.CLASS }) { + if (targets.isNotEmpty() && targets.all { it is FunctionDescriptor || it is ClassDescriptor && it.kind == ClassKind.CLASS }) { return CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + ">".repeat(balance) + "$" } else { @@ -447,12 +447,12 @@ public class KotlinCompletionContributor : CompletionContributor() { private fun findCallNameTokenIfInTypeArgs(leaf: PsiElement): PsiElement? { var current = leaf while (true) { - val tokenType = current.getNode()!!.getElementType() + val tokenType = current.node!!.elementType if (tokenType !in callTypeArgsTokens) return null if (tokenType == KtTokens.LT) { val nameToken = current.prevLeaf(skipEmptyElements = true) ?: return null - if (nameToken.getNode()!!.getElementType() != KtTokens.IDENTIFIER) return null + if (nameToken.node!!.elementType != KtTokens.IDENTIFIER) return null return nameToken } @@ -472,7 +472,7 @@ public class KotlinCompletionContributor : CompletionContributor() { // and the following block will not be attached as a body to the constructor. Therefore // we need to use a regular identifier. val argumentList = tokenBefore?.getNonStrictParentOfType() ?: return null - if (argumentList.getParent() is KtConstructorDelegationCall) return CompletionUtil.DUMMY_IDENTIFIER_TRIMMED + if (argumentList.parent is KtConstructorDelegationCall) return CompletionUtil.DUMMY_IDENTIFIER_TRIMMED return null } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt index 079030bd870..39180a898b5 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt @@ -29,11 +29,11 @@ import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject import org.jetbrains.kotlin.idea.imports.importableFqName import org.jetbrains.kotlin.name.FqName -public class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider { +class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider { override fun fillActions(element: LookupElement, lookup: Lookup, consumer: Consumer) { - val lookupObject = element.getObject() as? DeclarationLookupObject ?: return + val lookupObject = element.`object` as? DeclarationLookupObject ?: return - val project = lookup.getPsiFile().getProject() + val project = lookup.psiFile.project lookupObject.importableFqName?.let { addExcludes(consumer, project, it.asString()) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LeafElementFilter.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LeafElementFilter.kt index c29dbcdcc2a..1ae25dd1ba1 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LeafElementFilter.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LeafElementFilter.kt @@ -22,10 +22,10 @@ import com.intellij.psi.filters.ElementFilter import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.tree.IElementType -public class LeafElementFilter(private val elementType: IElementType) : ElementFilter { +class LeafElementFilter(private val elementType: IElementType) : ElementFilter { override fun isAcceptable(element: Any?, context: PsiElement?) - = element is LeafPsiElement && element.getElementType() == elementType + = element is LeafPsiElement && element.elementType == elementType override fun isClassAcceptable(hintClass: Class<*>) = LEAF_CLASS_FILTER.isClassAcceptable(hintClass) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 6a09e172e10..7e3da644d11 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -240,12 +240,12 @@ class LookupElementFactory( override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) if (style == Style.BOLD) { - presentation.setItemTextBold(true) + presentation.isItemTextBold = true } else { - presentation.setItemTextForeground(LookupCellRenderer.getGrayedForeground(false)) + presentation.itemTextForeground = LookupCellRenderer.getGrayedForeground(false) // gray all tail fragments too: - val fragments = presentation.getTailFragments() + val fragments = presentation.tailFragments presentation.clearTail() for (fragment in fragments) { presentation.appendTailText(fragment.text, true) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt index ad5f4c47fde..0725999a2f6 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt @@ -42,7 +42,7 @@ class LookupElementsCollector( private val postProcessors = ArrayList<(LookupElement) -> LookupElement>() - public fun flushToResultSet() { + fun flushToResultSet() { if (!elements.isEmpty()) { resultSet.addAllElements(elements) elements.clear() @@ -50,14 +50,14 @@ class LookupElementsCollector( } } - public var isResultEmpty: Boolean = true + var isResultEmpty: Boolean = true private set - public fun addLookupElementPostProcessor(processor: (LookupElement) -> LookupElement) { + fun addLookupElementPostProcessor(processor: (LookupElement) -> LookupElement) { postProcessors.add(processor) } - public fun addDescriptorElements(descriptors: Iterable, + fun addDescriptorElements(descriptors: Iterable, lookupElementFactory: LookupElementFactory, notImported: Boolean = false, withReceiverCast: Boolean = false @@ -67,7 +67,7 @@ class LookupElementsCollector( } } - public fun addDescriptorElements( + fun addDescriptorElements( descriptor: DeclarationDescriptor, lookupElementFactory: LookupElementFactory, notImported: Boolean = false, @@ -82,7 +82,7 @@ class LookupElementsCollector( addElements(lookupElements, notImported) } - public fun addElement(element: LookupElement, notImported: Boolean = false) { + fun addElement(element: LookupElement, notImported: Boolean = false) { if (!prefixMatcher.prefixMatches(element)) return if (notImported) { @@ -98,13 +98,13 @@ class LookupElementsCollector( val decorated = object : LookupElementDecorator(element) { override fun handleInsert(context: InsertionContext) { - getDelegate().handleInsert(context) + delegate.handleInsert(context) if (context.shouldAddCompletionChar() && !isJustTyping(context, this)) { - when (context.getCompletionChar()) { - ',' -> WithTailInsertHandler.COMMA.postHandleInsert(context, getDelegate()) + when (context.completionChar) { + ',' -> WithTailInsertHandler.COMMA.postHandleInsert(context, delegate) - '=' -> WithTailInsertHandler.EQ.postHandleInsert(context, getDelegate()) + '=' -> WithTailInsertHandler.EQ.postHandleInsert(context, delegate) '!' -> { WithExpressionPrefixInsertHandler("!").postHandleInsert(context) @@ -133,20 +133,20 @@ class LookupElementsCollector( // used to avoid insertion of spaces before/after ',', '=' on just typing private fun isJustTyping(context: InsertionContext, element: LookupElement): Boolean { - if (!completionParameters.isAutoPopup()) return false - val insertedText = context.getDocument().getText(TextRange(context.getStartOffset(), context.getTailOffset())) + if (!completionParameters.isAutoPopup) return false + val insertedText = context.document.getText(TextRange(context.startOffset, context.tailOffset)) return insertedText == element.getUserDataDeep(KotlinCompletionCharFilter.JUST_TYPING_PREFIX) } - public fun addElements(elements: Iterable, notImported: Boolean = false) { + fun addElements(elements: Iterable, notImported: Boolean = false) { elements.forEach { addElement(it, notImported) } } - public fun advertiseSecondCompletion() { - JavaCompletionContributor.advertiseSecondCompletion(completionParameters.getOriginalFile().getProject(), resultSet) + fun advertiseSecondCompletion() { + JavaCompletionContributor.advertiseSecondCompletion(completionParameters.originalFile.project, resultSet) } - public fun restartCompletionOnPrefixChange(prefixCondition: ElementPattern) { + fun restartCompletionOnPrefixChange(prefixCondition: ElementPattern) { resultSet.restartCompletionOnPrefixChange(prefixCondition) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt index 7e2d64dee21..c4872f17cd0 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.types.KotlinType import java.util.* object NamedArgumentCompletion { - public fun isOnlyNamedArgumentExpected(nameExpression: KtSimpleNameExpression): Boolean { + fun isOnlyNamedArgumentExpected(nameExpression: KtSimpleNameExpression): Boolean { val thisArgument = nameExpression.parent as? KtValueArgument ?: return false if (thisArgument.isNamed()) return false @@ -46,7 +46,7 @@ object NamedArgumentCompletion { .any { it.isNamed() } } - public fun complete(collector: LookupElementsCollector, expectedInfos: Collection) { + fun complete(collector: LookupElementsCollector, expectedInfos: Collection) { val nameToParameterType = HashMap>() for (expectedInfo in expectedInfos) { val argumentData = expectedInfo.additionalData as? ArgumentPositionData.Positional ?: continue @@ -70,10 +70,10 @@ object NamedArgumentCompletion { private class NamedArgumentInsertHandler(private val parameterName: Name) : InsertHandler { override fun handleInsert(context: InsertionContext, item: LookupElement) { - val editor = context.getEditor() + val editor = context.editor val text = parameterName.render() - editor.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), text) - editor.getCaretModel().moveToOffset(context.getStartOffset() + text.length) + editor.document.replaceString(context.startOffset, context.tailOffset, text) + editor.caretModel.moveToOffset(context.startOffset + text.length) WithTailInsertHandler.EQ.postHandleInsert(context, item) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt index e7d94327e70..c2a59061899 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt @@ -37,16 +37,16 @@ object PackageDirectiveCompletion { val ACTIVATION_PATTERN = PlatformPatterns.psiElement().inside(KtPackageDirective::class.java) fun perform(parameters: CompletionParameters, result: CompletionResultSet): Boolean { - val position = parameters.getPosition() + val position = parameters.position if (!ACTIVATION_PATTERN.accepts(position)) return false - val file = position.getContainingFile() as KtFile + val file = position.containingFile as KtFile - val expression = file.findElementAt(parameters.getOffset())?.getParent() as? KtSimpleNameExpression ?: return false + val expression = file.findElementAt(parameters.offset)?.parent as? KtSimpleNameExpression ?: return false try { - val prefixLength = parameters.getOffset() - expression.getTextOffset() - val prefix = expression.getText()!! + val prefixLength = parameters.offset - expression.textOffset + val prefix = expression.text!! val prefixMatcher = PlainPrefixMatcher(prefix.substring(0, prefixLength)) val result = result.withPrefixMatcher(prefixMatcher) @@ -58,7 +58,7 @@ object PackageDirectiveCompletion { val lookupElementFactory = BasicLookupElementFactory(resolutionFacade.project, InsertHandlerProvider(callType = CallType.PACKAGE_DIRECTIVE, expectedInfosCalculator = { emptyList() })) for (variant in variants) { val lookupElement = lookupElementFactory.createLookupElement(variant) - if (!lookupElement.getLookupString().contains(DUMMY_IDENTIFIER)) { + if (!lookupElement.lookupString.contains(DUMMY_IDENTIFIER)) { result.addElement(lookupElement) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt index 33d161ba812..9e8c0d29e13 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt @@ -71,7 +71,7 @@ class ParameterNameAndTypeCompletion( private val suggestionsByTypesAdded = HashSet() - public fun addFromImportedClasses(position: PsiElement, bindingContext: BindingContext, visibilityFilter: (DeclarationDescriptor) -> Boolean) { + fun addFromImportedClasses(position: PsiElement, bindingContext: BindingContext, visibilityFilter: (DeclarationDescriptor) -> Boolean) { for ((classNameMatcher, userPrefix) in classNamePrefixMatchers.zip(userPrefixes)) { val resolutionScope = position.getResolutionScope(bindingContext, resolutionFacade) val classifiers = resolutionScope.collectDescriptorsFiltered(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS, classNameMatcher.asNameFilter()) @@ -86,10 +86,10 @@ class ParameterNameAndTypeCompletion( } } - public fun addFromAllClasses(parameters: CompletionParameters, indicesHelper: KotlinIndicesHelper) { + fun addFromAllClasses(parameters: CompletionParameters, indicesHelper: KotlinIndicesHelper) { for ((classNameMatcher, userPrefix) in classNamePrefixMatchers.zip(userPrefixes)) { AllClassesCompletion( - parameters, indicesHelper, classNameMatcher, resolutionFacade, { !it.isSingleton() } + parameters, indicesHelper, classNameMatcher, resolutionFacade, { !it.isSingleton } ).collect( { addSuggestionsForClassifier(it, userPrefix, notImported = true) }, { addSuggestionsForJavaClass(it, userPrefix, notImported = true) } @@ -99,18 +99,18 @@ class ParameterNameAndTypeCompletion( } } - public fun addFromParametersInFile(position: PsiElement, resolutionFacade: ResolutionFacade, visibilityFilter: (DeclarationDescriptor) -> Boolean) { + fun addFromParametersInFile(position: PsiElement, resolutionFacade: ResolutionFacade, visibilityFilter: (DeclarationDescriptor) -> Boolean) { val lookupElementToCount = LinkedHashMap() - position.getContainingFile().forEachDescendantOfType( + position.containingFile.forEachDescendantOfType( canGoInside = { it !is KtExpression || it is KtDeclaration } // we analyze parameters inside bodies to not resolve too much ) { parameter -> ProgressManager.checkCanceled() - val name = parameter.getName() + val name = parameter.name if (name != null && prefixMatcher.isStartMatch(name)) { val descriptor = resolutionFacade.analyze(parameter)[BindingContext.VALUE_PARAMETER, parameter] if (descriptor != null) { - val parameterType = descriptor.getType() + val parameterType = descriptor.type if (parameterType.isVisible(visibilityFilter)) { val lookupElement = MyLookupElement.create(name, ArbitraryType(parameterType), lookupElementFactory)!! val count = lookupElementToCount[lookupElement] ?: 0 @@ -127,11 +127,11 @@ class ParameterNameAndTypeCompletion( } private fun addSuggestionsForClassifier(classifier: DeclarationDescriptor, userPrefix: String, notImported: Boolean) { - addSuggestions(classifier.getName().asString(), userPrefix, DescriptorType(classifier as ClassifierDescriptor), notImported) + addSuggestions(classifier.name.asString(), userPrefix, DescriptorType(classifier as ClassifierDescriptor), notImported) } private fun addSuggestionsForJavaClass(psiClass: PsiClass, userPrefix: String, notImported: Boolean) { - addSuggestions(psiClass.getName()!!, userPrefix, JavaClassType(psiClass), notImported) + addSuggestions(psiClass.name!!, userPrefix, JavaClassType(psiClass), notImported) } private fun addSuggestions(className: String, userPrefix: String, type: Type, notImported: Boolean) { @@ -153,9 +153,9 @@ class ParameterNameAndTypeCompletion( } private fun KotlinType.isVisible(visibilityFilter: (DeclarationDescriptor) -> Boolean): Boolean { - if (isError()) return false - val classifier = getConstructor().getDeclarationDescriptor() ?: return false - return visibilityFilter(classifier) && getArguments().all { it.isStarProjection || it.getType().isVisible(visibilityFilter) } + if (isError) return false + val classifier = constructor.declarationDescriptor ?: return false + return visibilityFilter(classifier) && arguments.all { it.isStarProjection || it.type.isVisible(visibilityFilter) } } private abstract class Type(private val idString: String) { @@ -170,7 +170,7 @@ class ParameterNameAndTypeCompletion( = lookupElementFactory.createLookupElement(classifier, qualifyNestedClasses = true) } - private class JavaClassType(private val psiClass: PsiClass) : Type(psiClass.getQualifiedName()!!) { + private class JavaClassType(private val psiClass: PsiClass) : Type(psiClass.qualifiedName!!) { override fun createTypeLookupElement(lookupElementFactory: BasicLookupElementFactory) = lookupElementFactory.createLookupElementForJavaClass(psiClass, qualifyNestedClasses = true) } @@ -202,19 +202,19 @@ class ParameterNameAndTypeCompletion( override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setItemText(parameterName + ": " + presentation.getItemText()) + presentation.itemText = parameterName + ": " + presentation.itemText } override fun handleInsert(context: InsertionContext) { - val settings = CodeStyleSettingsManager.getInstance(context.getProject()).getCurrentSettings().getCustomSettings(KotlinCodeStyleSettings::class.java) + val settings = CodeStyleSettingsManager.getInstance(context.project).currentSettings.getCustomSettings(KotlinCodeStyleSettings::class.java) val spaceBefore = if (settings.SPACE_BEFORE_TYPE_COLON) " " else "" val spaceAfter = if (settings.SPACE_AFTER_TYPE_COLON) " " else "" val text = parameterName + spaceBefore + ":" + spaceAfter - val startOffset = context.getStartOffset() - context.getDocument().insertString(startOffset, text) + val startOffset = context.startOffset + context.document.insertString(startOffset, text) // update start offset so that it does not include the text we inserted - context.getOffsetMap().addOffset(CompletionInitializationContext.START_OFFSET, startOffset + text.length) + context.offsetMap.addOffset(CompletionInitializationContext.START_OFFSET, startOffset + text.length) super.handleInsert(context) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt index f00166921ab..7af9a8ffc69 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt @@ -34,8 +34,8 @@ class ToFromOriginalFileMapper( //TODO: lazy initialization? init { - val originalText = originalFile.getText() - val syntheticText = syntheticFile.getText() + val originalText = originalFile.text + val syntheticText = syntheticFile.text assert(originalText.subSequence(0, completionOffset) == syntheticText.subSequence(0, completionOffset)) syntheticLength = syntheticText.length @@ -47,7 +47,7 @@ class ToFromOriginalFileMapper( shift = syntheticLength - originalLength } - public fun toOriginalFile(offset: Int): Int? { + fun toOriginalFile(offset: Int): Int? { return when { offset <= completionOffset -> offset offset >= syntheticLength - tailLength -> offset - shift @@ -55,7 +55,7 @@ class ToFromOriginalFileMapper( } } - public fun toSyntheticFile(offset: Int): Int? { + fun toSyntheticFile(offset: Int): Int? { return when { offset <= completionOffset -> offset offset >= originalLength - tailLength -> offset + shift @@ -63,14 +63,14 @@ class ToFromOriginalFileMapper( } } - public fun toOriginalFile(declaration: KtDeclaration): KtDeclaration? { - if (declaration.getContainingFile() != syntheticFile) return declaration + fun toOriginalFile(declaration: KtDeclaration): KtDeclaration? { + if (declaration.containingFile != syntheticFile) return declaration val offset = toOriginalFile(declaration.startOffset) ?: return null return PsiTreeUtil.findElementOfClassAtOffset(originalFile, offset, KtDeclaration::class.java, true) } - public fun toSyntheticFile(declaration: KtDeclaration): KtDeclaration? { - if (declaration.getContainingFile() != originalFile) return declaration + fun toSyntheticFile(declaration: KtDeclaration): KtDeclaration? { + if (declaration.containingFile != originalFile) return declaration val offset = toSyntheticFile(declaration.startOffset) ?: return null return PsiTreeUtil.findElementOfClassAtOffset(syntheticFile, offset, KtDeclaration::class.java, true) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt index efe213a0ea8..657fe5ac05c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/Weighers.kt @@ -113,7 +113,7 @@ object KindWeigher : LookupElementWeigher("kotlin.kind") { } override fun weigh(element: LookupElement): Weight { - val o = element.getObject() + val o = element.`object` return when (o) { is PackageLookupObject -> Weight.packages @@ -156,7 +156,7 @@ object VariableOrFunctionWeigher : LookupElementWeigher("kotlin.variableOrFuncti object DeprecatedWeigher : LookupElementWeigher("kotlin.deprecated") { override fun weigh(element: LookupElement): Int { - val o = element.getObject() as? DeclarationLookupObject ?: return 0 + val o = element.`object` as? DeclarationLookupObject ?: return 0 return if (o.isDeprecated) 1 else 0 } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt index a0b9f867068..4133ed23295 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt @@ -28,28 +28,28 @@ import org.jetbrains.kotlin.psi.* object CastReceiverInsertHandler { fun postHandleInsert(context: InsertionContext, item: LookupElement) { - val expression = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), KtSimpleNameExpression::class.java, false) + val expression = PsiTreeUtil.findElementOfClassAtOffset(context.file, context.startOffset, KtSimpleNameExpression::class.java, false) val qualifiedExpression = PsiTreeUtil.getParentOfType(expression, KtQualifiedExpression::class.java, true) if (qualifiedExpression != null) { - val receiver = qualifiedExpression.getReceiverExpression() + val receiver = qualifiedExpression.receiverExpression - val descriptor = (item.getObject() as? DeclarationLookupObject)?.descriptor as CallableDescriptor - val project = context.getProject() + val descriptor = (item.`object` as? DeclarationLookupObject)?.descriptor as CallableDescriptor + val project = context.project - val thisObj = if (descriptor.getExtensionReceiverParameter() != null) descriptor.getExtensionReceiverParameter() else descriptor.getDispatchReceiverParameter() - val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj!!.getType().getConstructor().getDeclarationDescriptor()!!) + val thisObj = if (descriptor.extensionReceiverParameter != null) descriptor.extensionReceiverParameter else descriptor.dispatchReceiverParameter + val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj!!.type.constructor.declarationDescriptor!!) val parentCast = KtPsiFactory(project).createExpression("(expr as $fqName)") as KtParenthesizedExpression - val cast = parentCast.getExpression() as KtBinaryExpressionWithTypeRHS - cast.getLeft().replace(receiver) + val cast = parentCast.expression as KtBinaryExpressionWithTypeRHS + cast.left.replace(receiver) val psiDocumentManager = PsiDocumentManager.getInstance(project) psiDocumentManager.commitAllDocuments() - psiDocumentManager.doPostponedOperationsAndUnblockDocument(context.getDocument()) + psiDocumentManager.doPostponedOperationsAndUnblockDocument(context.document) val expr = receiver.replace(parentCast) as KtParenthesizedExpression - ShortenReferences.DEFAULT.process((expr.getExpression() as KtBinaryExpressionWithTypeRHS).getRight()!!) + ShortenReferences.DEFAULT.process((expr.expression as KtBinaryExpressionWithTypeRHS).right!!) } } } \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt index 43cf6f414c1..0690a00cfae 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt @@ -42,13 +42,13 @@ fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange, // we start template later to not interfere with insertion of tail type val commandProcessor = CommandProcessor.getInstance() - val commandName = commandProcessor.getCurrentCommandName()!! - val commandGroupId = commandProcessor.getCurrentCommandGroupId() + val commandName = commandProcessor.currentCommandName!! + val commandGroupId = commandProcessor.currentCommandGroupId - val rangeMarker = context.getDocument().createRangeMarker(placeholderRange) + val rangeMarker = context.document.createRangeMarker(placeholderRange) context.setLaterRunnable { - context.getProject().executeWriteCommand(commandName, groupId = commandGroupId) { + context.project.executeWriteCommand(commandName, groupId = commandGroupId) { try { if (rangeMarker.isValid()) { context.getDocument().deleteString(rangeMarker.getStartOffset(), rangeMarker.getEndOffset()) @@ -72,9 +72,9 @@ fun lambdaPresentation(lambdaType: KotlinType?): String { } private fun needExplicitParameterTypes(context: InsertionContext, placeholderRange: TextRange, lambdaType: KotlinType): Boolean { - PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments() - val file = context.getFile() as KtFile - val expression = PsiTreeUtil.findElementOfClassAtRange(file, placeholderRange.getStartOffset(), placeholderRange.getEndOffset(), KtExpression::class.java) + PsiDocumentManager.getInstance(context.project).commitAllDocuments() + val file = context.file as KtFile + val expression = PsiTreeUtil.findElementOfClassAtRange(file, placeholderRange.startOffset, placeholderRange.endOffset, KtExpression::class.java) ?: return false val resolutionFacade = file.getResolutionFacade() @@ -97,7 +97,7 @@ private fun buildTemplate(lambdaType: KotlinType, explicitParameterTypes: Boolea val manager = TemplateManager.getInstance(project) val template = manager.createTemplate("", "") - template.setToShortenLongNames(true) + template.isToShortenLongNames = true //template.setToReformat(true) //TODO template.addTextSegment("{ ") @@ -128,4 +128,4 @@ private class ParameterNameExpression(val nameSuggestions: Array) : Expr } fun functionParameterTypes(functionType: KotlinType): List - = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(functionType).map { it.getType() } + = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(functionType).map { it.type } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinCallableInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinCallableInsertHandler.kt index c1489170b47..e1be572bf59 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinCallableInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinCallableInsertHandler.kt @@ -28,22 +28,22 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.DescriptorUtils abstract class KotlinCallableInsertHandler : BaseDeclarationInsertHandler() { - public override fun handleInsert(context: InsertionContext, item: LookupElement) { + override fun handleInsert(context: InsertionContext, item: LookupElement) { super.handleInsert(context, item) addImport(context, item) } private fun addImport(context : InsertionContext, item : LookupElement) { - PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments() + PsiDocumentManager.getInstance(context.project).commitAllDocuments() - val file = context.getFile() - val o = item.getObject() + val file = context.file + val o = item.`object` if (file is KtFile && o is DeclarationLookupObject) { val descriptor = o.descriptor as? CallableDescriptor if (descriptor != null) { // for completion after dot, import insertion may be required only for extensions - if (context.isAfterDot() && descriptor.getExtensionReceiverParameter() == null) { + if (context.isAfterDot() && descriptor.extensionReceiverParameter == null) { return } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassifierInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassifierInsertHandler.kt index 7595b9f5fc2..4896ba18922 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassifierInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassifierInsertHandler.kt @@ -41,20 +41,20 @@ object KotlinClassifierInsertHandler : BaseDeclarationInsertHandler() { super.handleInsert(context, item) - val file = context.getFile() + val file = context.file if (file is KtFile) { if (!context.isAfterDot()) { - val psiDocumentManager = PsiDocumentManager.getInstance(context.getProject()) + val psiDocumentManager = PsiDocumentManager.getInstance(context.project) psiDocumentManager.commitAllDocuments() - val startOffset = context.getStartOffset() - val document = context.getDocument() + val startOffset = context.startOffset + val document = context.document val qualifiedName = qualifiedNameToInsert(item) // first try to resolve short name for faster handling val token = file.findElementAt(startOffset) - val nameRef = token!!.getParent() as? KtNameReferenceExpression + val nameRef = token!!.parent as? KtNameReferenceExpression if (nameRef != null) { val bindingContext = nameRef.analyze(BodyResolveMode.PARTIAL) val target = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, nameRef] @@ -72,7 +72,7 @@ object KotlinClassifierInsertHandler : BaseDeclarationInsertHandler() { "$;val v:" // if we have no reference in the current context we have a more complicated prefix to get one } val tempSuffix = ".xxx" // we add "xxx" after dot because of KT-9606 - document.replaceString(startOffset, context.getTailOffset(), tempPrefix + qualifiedName + tempSuffix) + document.replaceString(startOffset, context.tailOffset, tempPrefix + qualifiedName + tempSuffix) psiDocumentManager.commitAllDocuments() @@ -84,21 +84,21 @@ object KotlinClassifierInsertHandler : BaseDeclarationInsertHandler() { ShortenReferences.DEFAULT.process(file, classNameStart, classNameEnd) psiDocumentManager.doPostponedOperationsAndUnblockDocument(document) - if (rangeMarker.isValid() && wholeRangeMarker.isValid()) { - document.deleteString(wholeRangeMarker.getStartOffset(), rangeMarker.getStartOffset()) - document.deleteString(rangeMarker.getEndOffset(), wholeRangeMarker.getEndOffset()) + if (rangeMarker.isValid && wholeRangeMarker.isValid) { + document.deleteString(wholeRangeMarker.startOffset, rangeMarker.startOffset) + document.deleteString(rangeMarker.endOffset, wholeRangeMarker.endOffset) } } } } private fun qualifiedNameToInsert(item: LookupElement): String { - val lookupObject = item.getObject() as DeclarationLookupObject + val lookupObject = item.`object` as DeclarationLookupObject if (lookupObject.descriptor != null) { return IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(lookupObject.descriptor as ClassifierDescriptor) } else { - val qualifiedName = (lookupObject.psiElement as PsiClass).getQualifiedName()!! + val qualifiedName = (lookupObject.psiElement as PsiClass).qualifiedName!! return if (FqNameUnsafe.isValid(qualifiedName)) FqNameUnsafe(qualifiedName).render() else qualifiedName } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt index 62338058a3f..c1575809274 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt @@ -78,7 +78,7 @@ sealed class KotlinFunctionInsertHandler : KotlinCallableInsertHandler() { } private fun addArguments(context: InsertionContext, offsetElement: PsiElement, item: LookupElement) { - val completionChar = context.getCompletionChar() + val completionChar = context.completionChar if (completionChar == '(') { //TODO: more correct behavior related to braces type context.setAddCompletionChar(false) } @@ -101,9 +101,9 @@ sealed class KotlinFunctionInsertHandler : KotlinCallableInsertHandler() { if (offset1 < chars.length) { if (chars[offset1] == '<') { PsiDocumentManager.getInstance(project).commitDocument(document) - val token = context.getFile().findElementAt(offset1)!! - if (token.getNode().getElementType() == KtTokens.LT) { - val parent = token.getParent() + val token = context.file.findElementAt(offset1)!! + if (token.node.elementType == KtTokens.LT) { + val parent = token.parent if (parent is KtTypeArgumentList && parent.getText().indexOf('\n') < 0/* if type argument list is on multiple lines this is more likely wrong parsing*/) { offset = parent.endOffset insertTypeArguments = false @@ -194,7 +194,7 @@ sealed class KotlinFunctionInsertHandler : KotlinCallableInsertHandler() { } object Infix : KotlinFunctionInsertHandler() { - public override fun handleInsert(context: InsertionContext, item: LookupElement) { + override fun handleInsert(context: InsertionContext, item: LookupElement) { super.handleInsert(context, item) if (context.completionChar == ' ') { @@ -209,7 +209,7 @@ sealed class KotlinFunctionInsertHandler : KotlinCallableInsertHandler() { object OnlyName : KotlinFunctionInsertHandler() - public override fun handleInsert(context: InsertionContext, item: LookupElement) { + override fun handleInsert(context: InsertionContext, item: LookupElement) { super.handleInsert(context, item) val psiDocumentManager = PsiDocumentManager.getInstance(context.project) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinPropertyInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinPropertyInsertHandler.kt index 66e37667d40..e5d2a40cf8e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinPropertyInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinPropertyInsertHandler.kt @@ -22,22 +22,22 @@ import com.intellij.codeInsight.lookup.LookupElement import com.intellij.psi.PsiDocumentManager object KotlinPropertyInsertHandler : KotlinCallableInsertHandler() { - public override fun handleInsert(context: InsertionContext, item: LookupElement) { + override fun handleInsert(context: InsertionContext, item: LookupElement) { super.handleInsert(context, item) - if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) { + if (context.completionChar == Lookup.REPLACE_SELECT_CHAR) { deleteEmptyParenthesis(context) } } private fun deleteEmptyParenthesis(context: InsertionContext) { - val psiDocumentManager = PsiDocumentManager.getInstance(context.getProject()) + val psiDocumentManager = PsiDocumentManager.getInstance(context.project) psiDocumentManager.commitAllDocuments() - psiDocumentManager.doPostponedOperationsAndUnblockDocument(context.getDocument()) + psiDocumentManager.doPostponedOperationsAndUnblockDocument(context.document) - val offset = context.getTailOffset() - val document = context.getDocument() - val chars = document.getCharsSequence() + val offset = context.tailOffset + val document = context.document + val chars = document.charsSequence val lParenOffset = chars.indexOfSkippingSpace('(', offset) ?: return val rParenOffset = chars.indexOfSkippingSpace(')', lParenOffset + 1) ?: return diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt index 08ce4b65b94..d6205c6f67b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt @@ -38,20 +38,20 @@ class WithExpressionPrefixInsertHandler(val prefix: String) : InsertHandler() ?: return if (expression is KtSimpleNameExpression) { var parent = expression.getParent() - if (parent is KtCallExpression && expression == parent.getCalleeExpression()) { + if (parent is KtCallExpression && expression == parent.calleeExpression) { expression = parent parent = parent.getParent() } - if (parent is KtDotQualifiedExpression && expression == parent.getSelectorExpression()) { + if (parent is KtDotQualifiedExpression && expression == parent.selectorExpression) { expression = parent } } - context.getDocument().insertString(expression.getTextRange().getStartOffset(), prefix) + context.document.insertString(expression.textRange.startOffset, prefix) } } \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt index 265e3984a56..99904e18a78 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt @@ -35,22 +35,22 @@ class WithTailInsertHandler(val tailText: String, } fun postHandleInsert(context: InsertionContext, item: LookupElement) { - val completionChar = context.getCompletionChar() + val completionChar = context.completionChar if (completionChar == tailText.singleOrNull() || (spaceAfter && completionChar == ' ')) { context.setAddCompletionChar(false) } //TODO: what if completion char is different? - val document = context.getDocument() - PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(document) + val document = context.document + PsiDocumentManager.getInstance(context.project).doPostponedOperationsAndUnblockDocument(document) - var tailOffset = context.getTailOffset() + var tailOffset = context.tailOffset if (completionChar == Lookup.REPLACE_SELECT_CHAR && item.getUserData(KEEP_OLD_ARGUMENT_LIST_ON_TAB_KEY) != null) { - val offset = context.getOffsetMap().getOffset(SmartCompletion.OLD_ARGUMENTS_REPLACEMENT_OFFSET) + val offset = context.offsetMap.getOffset(SmartCompletion.OLD_ARGUMENTS_REPLACEMENT_OFFSET) if (offset != -1) tailOffset = offset } - val moveCaret = context.getEditor().getCaretModel().getOffset() == tailOffset + val moveCaret = context.editor.caretModel.offset == tailOffset //TODO: analyze parenthesis balance to decide whether to replace or not var insert = true @@ -77,10 +77,10 @@ class WithTailInsertHandler(val tailText: String, document.insertString(tailOffset, textToInsert) if (moveCaret) { - context.getEditor().getCaretModel().moveToOffset(tailOffset + textToInsert.length) + context.editor.caretModel.moveToOffset(tailOffset + textToInsert.length) if (tailText == ",") { - AutoPopupController.getInstance(context.getProject())?.autoPopupParameterInfo(context.getEditor(), null) + AutoPopupController.getInstance(context.project)?.autoPopupParameterInfo(context.editor, null) } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt index 936ced22b44..2c9e28f0174 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt @@ -60,4 +60,4 @@ fun CharSequence.skipSpacesAndLineBreaks(index: Int): Int fun CharSequence.isCharAt(offset: Int, c: Char) = offset < length && this[offset] == c -fun Document.isTextAt(offset: Int, text: String) = offset + text.length <= getTextLength() && getText(TextRange(offset, offset + text.length)) == text +fun Document.isTextAt(offset: Int, text: String) = offset + text.length <= textLength && getText(TextRange(offset, offset + text.length)) == text diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt index 376b712b8ab..8da84b6e9d6 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.types.Variance import java.util.* object ClassLiteralItems { - public fun addToCollection( + fun addToCollection( collection: MutableCollection, expectedInfos: Collection, lookupElementFactory: BasicLookupElementFactory, diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/LambdaItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/LambdaItems.kt index 3528ddaba23..4a72be30f5d 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/LambdaItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/LambdaItems.kt @@ -28,13 +28,13 @@ import org.jetbrains.kotlin.idea.core.fuzzyType import java.util.* object LambdaItems { - public fun collect(functionExpectedInfos: Collection): Collection { + fun collect(functionExpectedInfos: Collection): Collection { val list = ArrayList() addToCollection(list, functionExpectedInfos) return list } - public fun addToCollection(collection: MutableCollection, expectedInfos: Collection) { + fun addToCollection(collection: MutableCollection, expectedInfos: Collection) { val functionExpectedInfos = expectedInfos.filterFunctionExpected() if (functionExpectedInfos.isEmpty()) return @@ -59,9 +59,9 @@ object LambdaItems { val lookupString = lambdaPresentation(functionType) val lookupElement = LookupElementBuilder.create(lookupString) .withInsertHandler({ context, lookupElement -> - val offset = context.getStartOffset() + val offset = context.startOffset val placeholder = "{}" - context.getDocument().replaceString(offset, context.getTailOffset(), placeholder) + context.document.replaceString(offset, context.tailOffset, placeholder) insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType) }) .suppressAutoInsertion() diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/MultipleArgumentsItemProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/MultipleArgumentsItemProvider.kt index c4f2af10d35..ef622af8b18 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/MultipleArgumentsItemProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/MultipleArgumentsItemProvider.kt @@ -48,7 +48,7 @@ class MultipleArgumentsItemProvider( private val resolutionFacade: ResolutionFacade ) { - public fun addToCollection(collection: MutableCollection, + fun addToCollection(collection: MutableCollection, expectedInfos: Collection, context: KtExpression) { val resolutionScope = context.getResolutionScope(bindingContext, resolutionFacade) @@ -69,7 +69,7 @@ class MultipleArgumentsItemProvider( if (i > 0 && parameters.asSequence().drop(i + 1).all { it.hasDefaultValue() }) { // this is the last parameter or all others have default values val lookupElement = createParametersLookupElement(variables, tail) - if (added.add(lookupElement.getLookupString())) { // check that we don't already have item with the same text + if (added.add(lookupElement.lookupString)) { // check that we don't already have item with the same text collection.add(lookupElement) } } @@ -83,16 +83,16 @@ class MultipleArgumentsItemProvider( val compoundIcon = LayeredIcon(2) val firstIcon = KotlinDescriptorIconProvider.getIcon(variables.first(), null, 0) val lastIcon = KotlinDescriptorIconProvider.getIcon(variables.last(), null, 0) - compoundIcon.setIcon(lastIcon, 0, 2 * firstIcon.getIconWidth() / 5, 0) + compoundIcon.setIcon(lastIcon, 0, 2 * firstIcon.iconWidth / 5, 0) compoundIcon.setIcon(firstIcon, 1, 0, 0) return LookupElementBuilder - .create(variables.map { it.getName().render() }.joinToString(", ")) //TODO: use code formatting settings + .create(variables.map { it.name.render() }.joinToString(", ")) //TODO: use code formatting settings .withInsertHandler { context, lookupElement -> - if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) { - val offset = context.getOffsetMap().getOffset(SmartCompletion.MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET) + if (context.completionChar == Lookup.REPLACE_SELECT_CHAR) { + val offset = context.offsetMap.getOffset(SmartCompletion.MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET) if (offset != -1) { - context.getDocument().deleteString(context.getTailOffset(), offset) + context.document.deleteString(context.tailOffset, offset) } } @@ -103,11 +103,11 @@ class MultipleArgumentsItemProvider( } private fun variableInScope(parameter: ValueParameterDescriptor, scope: LexicalScope): VariableDescriptor? { - val name = parameter.getName() + val name = parameter.name //TODO: there can be more than one property with such name in scope and we should be able to select one (but we need API for this) val variable = scope.findVariable(name, NoLookupLocation.FROM_IDE) { !it.isExtension } ?: scope.getVariableFromImplicitReceivers(name) ?: return null - return if (smartCastCalculator.types(variable).any { KotlinTypeChecker.DEFAULT.isSubtypeOf(it, parameter.getType()) }) + return if (smartCastCalculator.types(variable).any { KotlinTypeChecker.DEFAULT.isSubtypeOf(it, parameter.type) }) variable else null diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index 115585caddf..31bc9ab562c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -77,20 +77,20 @@ class SmartCompletion( expression } - public val expectedInfos: Collection = calcExpectedInfos(expressionWithType) + val expectedInfos: Collection = calcExpectedInfos(expressionWithType) private val callableTypeExpectedInfo = expectedInfos.filterCallableExpected() - public val smartCastCalculator: SmartCastCalculator by lazy(LazyThreadSafetyMode.NONE) { + val smartCastCalculator: SmartCastCalculator by lazy(LazyThreadSafetyMode.NONE) { SmartCastCalculator(bindingContext, resolutionFacade.moduleDescriptor, expression, callTypeAndReceiver.receiver as? KtExpression, resolutionFacade) } - public val descriptorFilter: ((DeclarationDescriptor, AbstractLookupElementFactory) -> Collection)? = + val descriptorFilter: ((DeclarationDescriptor, AbstractLookupElementFactory) -> Collection)? = { descriptor: DeclarationDescriptor, factory: AbstractLookupElementFactory -> filterDescriptor(descriptor, factory).map { postProcess(it) } }.check { expectedInfos.isNotEmpty() } - public fun additionalItems(lookupElementFactory: LookupElementFactory): Pair, InheritanceItemsSearcher?> { + fun additionalItems(lookupElementFactory: LookupElementFactory): Pair, InheritanceItemsSearcher?> { val (items, inheritanceSearcher) = additionalItemsNoPostProcess(lookupElementFactory) val postProcessedItems = items.map { postProcess(it) } //TODO: could not use "let" because of KT-8754 @@ -105,14 +105,14 @@ class SmartCompletion( return postProcessedItems to postProcessedSearcher } - public val descriptorsToSkip: Set by lazy>(LazyThreadSafetyMode.NONE) { - val parent = expressionWithType.getParent() + val descriptorsToSkip: Set by lazy>(LazyThreadSafetyMode.NONE) { + val parent = expressionWithType.parent when (parent) { is KtBinaryExpression -> { - if (parent.getRight() == expressionWithType) { - val operationToken = parent.getOperationToken() + if (parent.right == expressionWithType) { + val operationToken = parent.operationToken if (operationToken == KtTokens.EQ || operationToken in COMPARISON_TOKENS) { - val left = parent.getLeft() + val left = parent.left if (left is KtReferenceExpression) { return@lazy bindingContext[BindingContext.REFERENCE_TARGET, left].singletonOrEmptySet() } @@ -122,8 +122,8 @@ class SmartCompletion( is KtWhenConditionWithExpression -> { val entry = parent.getParent() as KtWhenEntry - val whenExpression = entry.getParent() as KtWhenExpression - val subject = whenExpression.getSubjectExpression() ?: return@lazy emptySet() + val whenExpression = entry.parent as KtWhenExpression + val subject = whenExpression.subjectExpression ?: return@lazy emptySet() val descriptorsToSkip = HashSet() @@ -137,12 +137,12 @@ class SmartCompletion( val subjectType = bindingContext.getType(subject) ?: return@lazy emptySet() val classDescriptor = TypeUtils.getClassDescriptor(subjectType) if (classDescriptor != null && DescriptorUtils.isEnumClass(classDescriptor)) { - val conditions = whenExpression.getEntries() - .flatMap { it.getConditions().toList() } + val conditions = whenExpression.entries + .flatMap { it.conditions.toList() } .filterIsInstance() for (condition in conditions) { - val selectorExpr = (condition.getExpression() as? KtDotQualifiedExpression) - ?.getSelectorExpression() as? KtReferenceExpression ?: continue + val selectorExpr = (condition.expression as? KtDotQualifiedExpression) + ?.selectorExpression as? KtReferenceExpression ?: continue val target = bindingContext[BindingContext.REFERENCE_TARGET, selectorExpr] as? ClassDescriptor ?: continue if (DescriptorUtils.isEnumEntry(target)) { descriptorsToSkip.add(target) @@ -256,10 +256,10 @@ class SmartCompletion( return if (item.getUserData(KEEP_OLD_ARGUMENT_LIST_ON_TAB_KEY) == null) { object : LookupElementDecorator(item) { override fun handleInsert(context: InsertionContext) { - if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) { - val offset = context.getOffsetMap().getOffset(OLD_ARGUMENTS_REPLACEMENT_OFFSET) + if (context.completionChar == Lookup.REPLACE_SELECT_CHAR) { + val offset = context.offsetMap.getOffset(OLD_ARGUMENTS_REPLACEMENT_OFFSET) if (offset != -1) { - context.getDocument().deleteString(context.getTailOffset(), offset) + context.document.deleteString(context.tailOffset, offset) } } @@ -274,7 +274,7 @@ class SmartCompletion( private fun MutableCollection.addThisItems(place: KtExpression, expectedInfos: Collection, smartCastCalculator: SmartCastCalculator) { if (shouldCompleteThisItems(prefixMatcher)) { - val items = thisExpressionItems(bindingContext, place, prefixMatcher.getPrefix(), resolutionFacade) + val items = thisExpressionItems(bindingContext, place, prefixMatcher.prefix, resolutionFacade) for (item in items) { val types = smartCastCalculator.types(item.receiverParameter).map { FuzzyType(it, emptyList()) } val matcher = { expectedInfo: ExpectedInfo -> types.matchExpectedInfo(expectedInfo) } @@ -292,9 +292,9 @@ class SmartCompletion( val originalDeclaration = toFromOriginalFileMapper.toOriginalFile(declaration) if (originalDeclaration != null) { val originalDescriptor = originalDeclaration.resolveToDescriptor() as? CallableDescriptor - val returnType = originalDescriptor?.getReturnType() + val returnType = originalDescriptor?.returnType if (returnType != null && !returnType.isError) { - return listOf(ExpectedInfo(returnType, declaration.getName(), null)) + return listOf(ExpectedInfo(returnType, declaration.name, null)) } } } @@ -316,10 +316,10 @@ class SmartCompletion( } private fun implicitlyTypedDeclarationFromInitializer(expression: KtExpression): KtDeclaration? { - val parent = expression.getParent() + val parent = expression.parent when (parent) { - is KtVariableDeclaration -> if (expression == parent.getInitializer() && parent.getTypeReference() == null) return parent - is KtNamedFunction -> if (expression == parent.getInitializer() && parent.getTypeReference() == null) return parent + is KtVariableDeclaration -> if (expression == parent.initializer && parent.typeReference == null) return parent + is KtNamedFunction -> if (expression == parent.initializer && parent.typeReference == null) return parent } return null } @@ -371,11 +371,11 @@ class SmartCompletion( } private fun buildForAsTypePosition(lookupElementFactory: BasicLookupElementFactory): Collection? { - val binaryExpression = ((expression.getParent() as? KtUserType) - ?.getParent() as? KtTypeReference) - ?.getParent() as? KtBinaryExpressionWithTypeRHS + val binaryExpression = ((expression.parent as? KtUserType) + ?.parent as? KtTypeReference) + ?.parent as? KtBinaryExpressionWithTypeRHS ?: return null - val elementType = binaryExpression.getOperationReference().getReferencedNameElementType() + val elementType = binaryExpression.operationReference.getReferencedNameElementType() if (elementType != KtTokens.AS_KEYWORD && elementType != KtTokens.AS_SAFE) return null val expectedInfos = calcExpectedInfos(binaryExpression) @@ -391,7 +391,7 @@ class SmartCompletion( } companion object { - public val OLD_ARGUMENTS_REPLACEMENT_OFFSET: OffsetKey = OffsetKey.create("nonFunctionReplacementOffset") - public val MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET: OffsetKey = OffsetKey.create("multipleArgumentsReplacementOffset") + val OLD_ARGUMENTS_REPLACEMENT_OFFSET: OffsetKey = OffsetKey.create("nonFunctionReplacementOffset") + val MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET: OffsetKey = OffsetKey.create("multipleArgumentsReplacementOffset") } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt index 4ca2d3eae98..52727a9753b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt @@ -140,7 +140,7 @@ class SmartCompletionSession( } } - if (position.getContainingFile() is KtCodeFragment) { + if (position.containingFile is KtCodeFragment) { val variantsAndFactory = getRuntimeReceiverTypeReferenceVariants(lookupElementFactory) if (variantsAndFactory != null) { val variants = variantsAndFactory.first @@ -176,7 +176,7 @@ class SmartCompletionSession( if (nameExpression != null) { val callTypeAndReceiver = CallTypeAndReceiver.detect(nameExpression) as? CallTypeAndReceiver.INFIX ?: return val call = callTypeAndReceiver.receiver.getCall(bindingContext) - if (call != null && call.getFunctionLiteralArguments().isEmpty()) { + if (call != null && call.functionLiteralArguments.isEmpty()) { val dummyArgument = object : LambdaArgument { override fun getLambdaExpression() = throw UnsupportedOperationException() override fun getArgumentExpression() = throw UnsupportedOperationException() @@ -186,7 +186,7 @@ class SmartCompletionSession( override fun getSpreadElement(): LeafPsiElement? = null override fun isExternal() = false } - val dummyArguments = call.getValueArguments() + listOf(dummyArgument) + val dummyArguments = call.valueArguments + listOf(dummyArgument) val dummyCall = object : DelegatingCall(call) { override fun getValueArguments() = dummyArguments override fun getFunctionLiteralArguments() = listOf(dummyArgument) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt index 021ca18e34a..06f7521e3ef 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt @@ -38,7 +38,7 @@ class StaticMembers( private val lookupElementFactory: LookupElementFactory, private val resolutionFacade: ResolutionFacade ) { - public fun addToCollection(collection: MutableCollection, + fun addToCollection(collection: MutableCollection, expectedInfos: Collection, context: KtSimpleNameExpression, enumEntriesToSkip: Set) { @@ -47,7 +47,7 @@ class StaticMembers( expectedInfo -> expectedInfo.fuzzyType?.type?.let { TypeUtils.getClassDescriptor(it) } } for ((classDescriptor, expectedInfosForClass) in expectedInfosByClass) { - if (classDescriptor != null && !classDescriptor.getName().isSpecial()) { + if (classDescriptor != null && !classDescriptor.name.isSpecial) { addToCollection(collection, classDescriptor, expectedInfosForClass, context, enumEntriesToSkip) } } @@ -78,17 +78,17 @@ class StaticMembers( collection.addLookupElements(descriptor, expectedInfos, matcher) { createLookupElements(it) } } - classDescriptor.getStaticScope().getContributedDescriptors().forEach(::processMember) + classDescriptor.staticScope.getContributedDescriptors().forEach(::processMember) - val companionObject = classDescriptor.getCompanionObjectDescriptor() + val companionObject = classDescriptor.companionObjectDescriptor if (companionObject != null) { - companionObject.getDefaultType().getMemberScope().getContributedDescriptors() + companionObject.defaultType.memberScope.getContributedDescriptors() .filter { !it.isExtension } .forEach(::processMember) } - var members = classDescriptor.getDefaultType().getMemberScope().getContributedDescriptors() - if (classDescriptor.getKind() != ClassKind.ENUM_CLASS) { + var members = classDescriptor.defaultType.memberScope.getContributedDescriptors() + if (classDescriptor.kind != ClassKind.ENUM_CLASS) { members = members.filter { DescriptorUtils.isNonCompanionObject(it) } } members.forEach(::processMember) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt index 043d95ee8f1..c215eee4638 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt @@ -61,7 +61,7 @@ class TypeInstantiationItems( val lookupElementFactory: LookupElementFactory, val forOrdinaryCompletion: Boolean ) { - public fun addTo( + fun addTo( items: MutableCollection, inheritanceSearchers: MutableCollection, expectedInfos: Collection @@ -130,21 +130,21 @@ class TypeInstantiationItems( } // not all inner classes can be instantiated and we handle them via constructors returned by ReferenceVariantsHelper - if (classifier.isInner()) return null + if (classifier.isInner) return null - val isAbstract = classifier.getModality() == Modality.ABSTRACT + val isAbstract = classifier.modality == Modality.ABSTRACT if (forOrdinaryCompletion && isAbstract) return null - val allConstructors = classifier.getConstructors() + val allConstructors = classifier.constructors val visibleConstructors = allConstructors.filter { if (isAbstract) - visibilityFilter(it) || it.getVisibility() == Visibilities.PROTECTED + visibilityFilter(it) || it.visibility == Visibilities.PROTECTED else visibilityFilter(it) } if (allConstructors.isNotEmpty() && visibleConstructors.isEmpty()) return null - var lookupString = lookupElement.getLookupString() + var lookupString = lookupElement.lookupString var allLookupStrings = setOf(lookupString) var itemText = lookupString var signatureText: String? = null @@ -164,11 +164,11 @@ class TypeInstantiationItems( itemText += "<...>" } - val constructorParenthesis = if (classifier.getKind() != ClassKind.INTERFACE) "()" else "" + val constructorParenthesis = if (classifier.kind != ClassKind.INTERFACE) "()" else "" itemText += constructorParenthesis itemText = "object: $itemText{...}" lookupString = "object" - allLookupStrings = setOf(lookupString, lookupElement.getLookupString()) + allLookupStrings = setOf(lookupString, lookupElement.lookupString) insertHandler = InsertHandler { context, item -> val startOffset = context.startOffset @@ -216,12 +216,12 @@ class TypeInstantiationItems( insertHandler = object : InsertHandler { override fun handleInsert(context: InsertionContext, item: LookupElement) { - context.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), typeText) - context.setTailOffset(context.getStartOffset() + typeText.length) + context.document.replaceString(context.startOffset, context.tailOffset, typeText) + context.tailOffset = context.startOffset + typeText.length baseInsertHandler.handleInsert(context, item) - shortenReferences(context, context.getStartOffset(), context.getTailOffset()) + shortenReferences(context, context.startOffset, context.tailOffset) } } if (baseInsertHandler.inputValueArguments) { @@ -240,29 +240,29 @@ class TypeInstantiationItems( override fun getAllLookupStrings() = allLookupStrings override fun renderElement(presentation: LookupElementPresentation) { - getDelegate().renderElement(presentation) - presentation.setItemText(itemText) + delegate.renderElement(presentation) + presentation.itemText = itemText presentation.clearTail() if (signatureText != null) { presentation.appendTailText(signatureText!!, false) } - presentation.appendTailText(" (" + DescriptorUtils.getFqName(classifier.getContainingDeclaration()) + ")", true) + presentation.appendTailText(" (" + DescriptorUtils.getFqName(classifier.containingDeclaration) + ")", true) } override fun handleInsert(context: InsertionContext) { - insertHandler.handleInsert(context, getDelegate()) + insertHandler.handleInsert(context, delegate) } override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is InstantiationLookupElement) return false - if (getLookupString() != other.getLookupString()) return false + if (getLookupString() != other.lookupString) return false val presentation1 = LookupElementPresentation() val presentation2 = LookupElementPresentation() renderElement(presentation1) other.renderElement(presentation2) - return presentation1.getItemText() == presentation2.getItemText() && presentation1.getTailText() == presentation2.getTailText() + return presentation1.itemText == presentation2.itemText && presentation1.tailText == presentation2.tailText } } @@ -274,11 +274,11 @@ class TypeInstantiationItems( } private fun addSamConstructorItem(collection: MutableCollection, `class`: ClassDescriptor, tail: Tail?) { - if (`class`.getKind() == ClassKind.INTERFACE) { - val container = `class`.getContainingDeclaration() + if (`class`.kind == ClassKind.INTERFACE) { + val container = `class`.containingDeclaration val scope = when (container) { is PackageFragmentDescriptor -> container.getMemberScope() - is ClassDescriptor -> container.getStaticScope() + is ClassDescriptor -> container.staticScope else -> return } val samConstructor = scope.getContributedFunctions(`class`.name, NoLookupLocation.FROM_IDE) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index 92c5995e3fa..2913228aa2f 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -44,11 +44,11 @@ import java.util.* class ArtificialElementInsertHandler( val textBeforeCaret: String, val textAfterCaret: String, val shortenRefs: Boolean) : InsertHandler{ override fun handleInsert(context: InsertionContext, item: LookupElement) { - val offset = context.getEditor().getCaretModel().getOffset() - val startOffset = offset - item.getLookupString().length - context.getDocument().deleteString(startOffset, offset) // delete inserted lookup string - context.getDocument().insertString(startOffset, textBeforeCaret + textAfterCaret) - context.getEditor().getCaretModel().moveToOffset(startOffset + textBeforeCaret.length) + val offset = context.editor.caretModel.offset + val startOffset = offset - item.lookupString.length + context.document.deleteString(startOffset, offset) // delete inserted lookup string + context.document.insertString(startOffset, textBeforeCaret + textAfterCaret) + context.editor.caretModel.moveToOffset(startOffset + textBeforeCaret.length) if (shortenRefs) { shortenReferences(context, startOffset, startOffset + textBeforeCaret.length + textAfterCaret.length) @@ -66,31 +66,31 @@ fun LookupElement.addTail(tail: Tail?): LookupElement { Tail.COMMA -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.COMMA.handleInsert(context, getDelegate()) + WithTailInsertHandler.COMMA.handleInsert(context, delegate) } } Tail.RPARENTH -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.RPARENTH.handleInsert(context, getDelegate()) + WithTailInsertHandler.RPARENTH.handleInsert(context, delegate) } } Tail.RBRACKET -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.RBRACKET.handleInsert(context, getDelegate()) + WithTailInsertHandler.RBRACKET.handleInsert(context, delegate) } } Tail.ELSE -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.ELSE.handleInsert(context, getDelegate()) + WithTailInsertHandler.ELSE.handleInsert(context, delegate) } } Tail.RBRACE -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.RBRACE.handleInsert(context, getDelegate()) + WithTailInsertHandler.RBRACE.handleInsert(context, delegate) } } } @@ -102,11 +102,11 @@ fun LookupElement.withOptions(options: ItemOptions): LookupElement { lookupElement = object : LookupElementDecorator(this) { override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setItemText("*" + presentation.getItemText()) + presentation.itemText = "*" + presentation.itemText } override fun handleInsert(context: InsertionContext) { - WithExpressionPrefixInsertHandler("*").handleInsert(context, getDelegate()) + WithExpressionPrefixInsertHandler("*").handleInsert(context, delegate) } } } @@ -118,7 +118,7 @@ fun LookupElement.addTailAndNameSimilarity( nameSimilarityExpectedInfos: Collection = matchedExpectedInfos ): LookupElement { val lookupElement = addTail(mergeTails(matchedExpectedInfos.map { it.tail })) - val similarity = calcNameSimilarity(lookupElement.getLookupString(), nameSimilarityExpectedInfos) + val similarity = calcNameSimilarity(lookupElement.lookupString, nameSimilarityExpectedInfos) if (similarity != 0) { lookupElement.putUserData(NAME_SIMILARITY_KEY, similarity) } @@ -170,7 +170,7 @@ fun MutableCollection.addLoo override fun equals(other: Any?) = descriptorsEqualWithSubstitution(this.descriptor, (other as? ItemData)?.descriptor) && itemOptions == (other as? ItemData)?.itemOptions - override fun hashCode() = if (this.descriptor != null) this.descriptor.getOriginal().hashCode() else 0 + override fun hashCode() = if (this.descriptor != null) this.descriptor.original.hashCode() else 0 } fun ItemData.createLookupElements() = lookupElementFactory(this.descriptor).map { it.withOptions(this.itemOptions) } @@ -225,10 +225,10 @@ private fun MutableCollection.addLookupElementsForNullable(factor object: LookupElementDecorator(it) { override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setItemText("!! " + presentation.getItemText()) + presentation.itemText = "!! " + presentation.itemText } override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler("!!", spaceBefore = false, spaceAfter = false).handleInsert(context, getDelegate()) + WithTailInsertHandler("!!", spaceBefore = false, spaceAfter = false).handleInsert(context, delegate) } }.postProcess() } @@ -237,10 +237,10 @@ private fun MutableCollection.addLookupElementsForNullable(factor object: LookupElementDecorator(it) { override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setItemText("?: " + presentation.getItemText()) + presentation.itemText = "?: " + presentation.itemText } override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler("?:", spaceBefore = true, spaceAfter = true).handleInsert(context, getDelegate()) //TODO: code style + WithTailInsertHandler("?:", spaceBefore = true, spaceAfter = true).handleInsert(context, delegate) //TODO: code style } }.postProcess() } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractCompiledKotlinInJavaCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractCompiledKotlinInJavaCompletionTest.kt index e9535e9f23c..8ee31fe3467 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractCompiledKotlinInJavaCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractCompiledKotlinInJavaCompletionTest.kt @@ -20,7 +20,7 @@ import com.intellij.codeInsight.completion.CompletionType import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public abstract class AbstractCompiledKotlinInJavaCompletionTest : KotlinFixtureCompletionBaseTestCase() { +abstract class AbstractCompiledKotlinInJavaCompletionTest : KotlinFixtureCompletionBaseTestCase() { override fun getPlatform() = JvmPlatform override fun getProjectDescriptor() = JdkAndMockLibraryProjectDescriptor(COMPLETION_TEST_DATA_BASE_PATH + "/injava/mockLib", false) diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractJvmWithLibBasicCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractJvmWithLibBasicCompletionTest.kt index 98743d8cce5..fea3709d375 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractJvmWithLibBasicCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractJvmWithLibBasicCompletionTest.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public abstract class AbstractJvmWithLibBasicCompletionTest : KotlinFixtureCompletionBaseTestCase() { +abstract class AbstractJvmWithLibBasicCompletionTest : KotlinFixtureCompletionBaseTestCase() { private val TEST_PATH = COMPLETION_TEST_DATA_BASE_PATH + "/basic/withLib" override fun getProjectDescriptor(): LightProjectDescriptor { diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKeywordCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKeywordCompletionTest.kt index 1d9b93bebec..8d6e8a452a0 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKeywordCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKeywordCompletionTest.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.completion.KeywordLookupObject import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public abstract class AbstractKeywordCompletionTest : KotlinFixtureCompletionBaseTestCase() { +abstract class AbstractKeywordCompletionTest : KotlinFixtureCompletionBaseTestCase() { override fun getPlatform() = JvmPlatform override fun defaultCompletionType() = CompletionType.BASIC diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt index 9cd5c6add4c..cb96fba7d61 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt @@ -22,7 +22,7 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform import java.io.File -public abstract class AbstractKotlinSourceInJavaCompletionTest : KotlinFixtureCompletionBaseTestCase() { +abstract class AbstractKotlinSourceInJavaCompletionTest : KotlinFixtureCompletionBaseTestCase() { override fun getPlatform() = JvmPlatform override fun doTest(testPath: String) { diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt index 95f96eb1cec..5f462363126 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt @@ -20,13 +20,13 @@ import com.intellij.codeInsight.completion.CompletionType import org.jetbrains.kotlin.idea.test.AstAccessControl import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public abstract class AbstractMultiFileJvmBasicCompletionTest : KotlinCompletionTestCase() { +abstract class AbstractMultiFileJvmBasicCompletionTest : KotlinCompletionTestCase() { protected fun doTest(testPath: String) { configureByFile(getTestName(false) + ".kt", "") // several tests require disabling this check after adding InclusiveRange, need to investigate why // val shouldFail = testPath.contains("NoSpecifiedType") // AstAccessControl.testWithControlledAccessToAst(shouldFail, getFile().getVirtualFile(), getProject(), getTestRootDisposable(), { - testCompletion(getFile().getText(), JvmPlatform, { completionType, invocationCount -> + testCompletion(file.text, JvmPlatform, { completionType, invocationCount -> setType(completionType) complete(invocationCount) myItems diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileSmartCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileSmartCompletionTest.kt index bf9357561ef..66c841ee521 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileSmartCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileSmartCompletionTest.kt @@ -20,7 +20,7 @@ import com.intellij.codeInsight.completion.CompletionType import org.jetbrains.kotlin.idea.test.AstAccessControl import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public abstract class AbstractMultiFileSmartCompletionTest : KotlinCompletionTestCase() { +abstract class AbstractMultiFileSmartCompletionTest : KotlinCompletionTestCase() { override fun setUp() { super.setUp() setType(CompletionType.SMART) @@ -30,7 +30,7 @@ public abstract class AbstractMultiFileSmartCompletionTest : KotlinCompletionTes configureByFile(getTestName(false) + ".kt", "") // several tests require disabling this check after adding InclusiveRange, need to investigate why // AstAccessControl.testWithControlledAccessToAst(false, getFile().getVirtualFile(), getProject(), getTestRootDisposable(), { - testCompletion(getFile().getText(), JvmPlatform, { completionType, invocationCount -> + testCompletion(file.text, JvmPlatform, { completionType, invocationCount -> setType(completionType) complete(invocationCount) myItems diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt index 7c458f27e88..fefc0d3a3b1 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt @@ -39,17 +39,17 @@ import java.util.* * Extract a number of statements about completion from the given text. Those statements * should be asserted during test execution. */ -public object ExpectedCompletionUtils { +object ExpectedCompletionUtils { - public class CompletionProposal { + class CompletionProposal { private val map: Map - public constructor(lookupString: String) { + constructor(lookupString: String) { map = HashMap() map.put(LOOKUP_STRING, lookupString) } - public constructor(map: MutableMap) { + constructor(map: MutableMap) { this.map = map for (key in map.keys) { if (key !in validKeys) { @@ -58,7 +58,7 @@ public object ExpectedCompletionUtils { } } - public constructor(json: JsonObject) { + constructor(json: JsonObject) { map = HashMap() for (entry in json.entrySet()) { val key = entry.key @@ -70,7 +70,7 @@ public object ExpectedCompletionUtils { } } - public fun matches(expectedProposal: CompletionProposal): Boolean + fun matches(expectedProposal: CompletionProposal): Boolean = expectedProposal.map.entries.none { it.value != map[it.key] } override fun toString(): String { @@ -82,13 +82,13 @@ public object ExpectedCompletionUtils { } companion object { - public val LOOKUP_STRING: String = "lookupString" - public val ALL_LOOKUP_STRINGS: String = "allLookupStrings" - public val PRESENTATION_ITEM_TEXT: String = "itemText" - public val PRESENTATION_TYPE_TEXT: String = "typeText" - public val PRESENTATION_TAIL_TEXT: String = "tailText" - public val PRESENTATION_TEXT_ATTRIBUTES: String = "attributes" - public val validKeys: Set = setOf(LOOKUP_STRING, ALL_LOOKUP_STRINGS, PRESENTATION_ITEM_TEXT, PRESENTATION_TYPE_TEXT, PRESENTATION_TAIL_TEXT, PRESENTATION_TEXT_ATTRIBUTES) + val LOOKUP_STRING: String = "lookupString" + val ALL_LOOKUP_STRINGS: String = "allLookupStrings" + val PRESENTATION_ITEM_TEXT: String = "itemText" + val PRESENTATION_TYPE_TEXT: String = "typeText" + val PRESENTATION_TAIL_TEXT: String = "tailText" + val PRESENTATION_TEXT_ATTRIBUTES: String = "attributes" + val validKeys: Set = setOf(LOOKUP_STRING, ALL_LOOKUP_STRINGS, PRESENTATION_ITEM_TEXT, PRESENTATION_TYPE_TEXT, PRESENTATION_TAIL_TEXT, PRESENTATION_TEXT_ATTRIBUTES) } } @@ -113,11 +113,11 @@ public object ExpectedCompletionUtils { private val WITH_ORDER_PREFIX = "WITH_ORDER" private val AUTOCOMPLETE_SETTING_PREFIX = "AUTOCOMPLETE_SETTING:" - public val RUNTIME_TYPE: String = "RUNTIME_TYPE:" + val RUNTIME_TYPE: String = "RUNTIME_TYPE:" private val COMPLETION_TYPE_PREFIX = "COMPLETION_TYPE:" - public val KNOWN_PREFIXES: List = ImmutableList.of( + val KNOWN_PREFIXES: List = ImmutableList.of( EXIST_LINE_PREFIX, ABSENT_LINE_PREFIX, ABSENT_JS_LINE_PREFIX, @@ -136,7 +136,7 @@ public object ExpectedCompletionUtils { LightClassComputationControl.LIGHT_CLASS_DIRECTIVE, AstAccessControl.ALLOW_AST_ACCESS_DIRECTIVE) - public fun itemsShouldExist(fileText: String, platform: TargetPlatform?): Array { + fun itemsShouldExist(fileText: String, platform: TargetPlatform?): Array { return when (platform) { JvmPlatform -> processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX) JsPlatform -> processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX) @@ -145,7 +145,7 @@ public object ExpectedCompletionUtils { } } - public fun itemsShouldAbsent(fileText: String, platform: TargetPlatform?): Array { + fun itemsShouldAbsent(fileText: String, platform: TargetPlatform?): Array { return when (platform) { JvmPlatform -> processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JAVA_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX) JsPlatform -> processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JS_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX) @@ -154,7 +154,7 @@ public object ExpectedCompletionUtils { } } - public fun processProposalAssertions(fileText: String, vararg prefixes: String): Array { + fun processProposalAssertions(fileText: String, vararg prefixes: String): Array { val proposals = ArrayList() for (proposalStr in InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, *prefixes)) { if (proposalStr.startsWith("{")) { @@ -180,7 +180,7 @@ public object ExpectedCompletionUtils { return ArrayUtil.toObjectArray(proposals, CompletionProposal::class.java) } - public fun getExpectedNumber(fileText: String, platform: TargetPlatform?): Int? { + fun getExpectedNumber(fileText: String, platform: TargetPlatform?): Int? { return when (platform) { null -> InTextDirectivesUtils.getPrefixedInt(fileText, NUMBER_LINE_PREFIX) JvmPlatform -> getPlatformExpectedNumber(fileText, NUMBER_JAVA_LINE_PREFIX) @@ -189,15 +189,15 @@ public object ExpectedCompletionUtils { } } - public fun isNothingElseExpected(fileText: String): Boolean { + fun isNothingElseExpected(fileText: String): Boolean { return !InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, NOTHING_ELSE_PREFIX).isEmpty() } - public fun getInvocationCount(fileText: String): Int? { + fun getInvocationCount(fileText: String): Int? { return InTextDirectivesUtils.getPrefixedInt(fileText, INVOCATION_COUNT_PREFIX) } - public fun getCompletionType(fileText: String): CompletionType? { + fun getCompletionType(fileText: String): CompletionType? { val completionTypeString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_TYPE_PREFIX) return when (completionTypeString) { "BASIC" -> CompletionType.BASIC @@ -207,19 +207,19 @@ public object ExpectedCompletionUtils { } } - public fun getAutocompleteSetting(fileText: String): Boolean? { + fun getAutocompleteSetting(fileText: String): Boolean? { return InTextDirectivesUtils.getPrefixedBoolean(fileText, AUTOCOMPLETE_SETTING_PREFIX) } - public fun isWithOrder(fileText: String): Boolean { + fun isWithOrder(fileText: String): Boolean { return !InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, WITH_ORDER_PREFIX).isEmpty() } - public fun assertDirectivesValid(fileText: String) { + fun assertDirectivesValid(fileText: String) { InTextDirectivesUtils.assertHasUnknownPrefixes(fileText, KNOWN_PREFIXES) } - public fun assertContainsRenderedItems(expected: Array, items: Array, checkOrder: Boolean, nothingElse: Boolean) { + fun assertContainsRenderedItems(expected: Array, items: Array, checkOrder: Boolean, nothingElse: Boolean) { val itemsInformation = getItemsInformation(items) val allItemsString = listToString(itemsInformation) @@ -272,7 +272,7 @@ public object ExpectedCompletionUtils { return InTextDirectivesUtils.getPrefixedInt(fileText, NUMBER_LINE_PREFIX) } - public fun assertNotContainsRenderedItems(unexpected: Array, items: Array) { + fun assertNotContainsRenderedItems(unexpected: Array, items: Array) { val itemsInformation = getItemsInformation(items) val allItemsString = listToString(itemsInformation) @@ -284,7 +284,7 @@ public object ExpectedCompletionUtils { } } - public fun getItemsInformation(items: Array): List { + fun getItemsInformation(items: Array): List { val presentation = LookupElementPresentation() val result = ArrayList(items.size) @@ -336,5 +336,5 @@ public object ExpectedCompletionUtils { } } - public fun listToString(items: Collection): String = items.joinToString("\n") + fun listToString(items: Collection): String = items.joinToString("\n") } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinFixtureCompletionBaseTestCase.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinFixtureCompletionBaseTestCase.kt index 8e0ba5eab50..4274335af09 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinFixtureCompletionBaseTestCase.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinFixtureCompletionBaseTestCase.kt @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.resolve.TargetPlatform import java.io.File -public abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsightFixtureTestCase() { - public abstract fun getPlatform(): TargetPlatform +abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsightFixtureTestCase() { + abstract fun getPlatform(): TargetPlatform protected open fun complete(completionType: CompletionType, invocationCount: Int): Array? = myFixture.complete(completionType, invocationCount) @@ -33,7 +33,7 @@ public abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsig protected abstract fun defaultCompletionType(): CompletionType protected open fun defaultInvocationCount(): Int = 0 - public open fun doTest(testPath: String) { + open fun doTest(testPath: String) { setUpFixture(testPath) val fileText = FileUtil.loadFile(File(testPath), true) @@ -42,7 +42,7 @@ public abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsig protected open fun setUpFixture(testPath: String) { //TODO: this is a hacky workaround for js second completion tests failing with PsiInvalidElementAccessException - LibraryModificationTracker.getInstance(getProject()).incModificationCount() + LibraryModificationTracker.getInstance(project).incModificationCount() myFixture.configureByFile(testPath) } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt index d9d60616623..88c1160a85e 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.utils.addToStdlib.indexOfOrNull import java.io.File -public abstract class AbstractCompletionHandlerTest(private val defaultCompletionType: CompletionType) : CompletionHandlerTestBase() { +abstract class AbstractCompletionHandlerTest(private val defaultCompletionType: CompletionType) : CompletionHandlerTestBase() { private val INVOCATION_COUNT_PREFIX = "INVOCATION_COUNT:" private val LOOKUP_STRING_PREFIX = "ELEMENT:" private val ELEMENT_TEXT_PREFIX = "ELEMENT_TEXT:" @@ -38,8 +38,8 @@ public abstract class AbstractCompletionHandlerTest(private val defaultCompletio setUpFixture(testPath) val settingManager = CodeStyleSettingsManager.getInstance() - val tempSettings = settingManager.getCurrentSettings().clone() - settingManager.setTemporarySettings(tempSettings) + val tempSettings = settingManager.currentSettings.clone() + settingManager.temporarySettings = tempSettings try { val fileText = FileUtil.loadFile(File(testPath)) val invocationCount = InTextDirectivesUtils.getPrefixedInt(fileText, INVOCATION_COUNT_PREFIX) ?: 1 @@ -56,16 +56,16 @@ public abstract class AbstractCompletionHandlerTest(private val defaultCompletio val completionType = ExpectedCompletionUtils.getCompletionType(fileText) ?: defaultCompletionType - val codeStyleSettings = KotlinCodeStyleSettings.getInstance(getProject()) + val codeStyleSettings = KotlinCodeStyleSettings.getInstance(project) for (line in InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, CODE_STYLE_SETTING_PREFIX)) { val index = line.indexOfOrNull('=') ?: error("Invalid code style setting '$line': '=' expected") val settingName = line.substring(0, index).trim() val settingValue = line.substring(index + 1).trim() val field = codeStyleSettings.javaClass.getDeclaredField(settingName) - when (field.getType().getName()) { + when (field.type.name) { "boolean" -> field.setBoolean(codeStyleSettings, settingValue.toBoolean()) "int" -> field.setInt(codeStyleSettings, settingValue.toInt()) - else -> error("Unsupported setting type: ${field.getType()}") + else -> error("Unsupported setting type: ${field.type}") } } @@ -83,10 +83,10 @@ public abstract class AbstractCompletionHandlerTest(private val defaultCompletio override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE } -public abstract class AbstractBasicCompletionHandlerTest() : AbstractCompletionHandlerTest(CompletionType.BASIC) +abstract class AbstractBasicCompletionHandlerTest() : AbstractCompletionHandlerTest(CompletionType.BASIC) -public abstract class AbstractSmartCompletionHandlerTest() : AbstractCompletionHandlerTest(CompletionType.SMART) +abstract class AbstractSmartCompletionHandlerTest() : AbstractCompletionHandlerTest(CompletionType.SMART) -public abstract class AbstractCompletionCharFilterTest() : AbstractCompletionHandlerTest(CompletionType.BASIC) +abstract class AbstractCompletionCharFilterTest() : AbstractCompletionHandlerTest(CompletionType.BASIC) -public abstract class AbstractKeywordCompletionHandlerTest() : AbstractCompletionHandlerTest(CompletionType.BASIC) +abstract class AbstractKeywordCompletionHandlerTest() : AbstractCompletionHandlerTest(CompletionType.BASIC) diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt index 184b3c62a00..d9218c08c9c 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt @@ -21,13 +21,12 @@ import org.jetbrains.kotlin.idea.completion.test.COMPLETION_TEST_DATA_BASE_PATH import org.jetbrains.kotlin.idea.completion.test.handlers.CompletionHandlerTestBase import java.io.File -@Deprecated("All tests from here to be moved to the generated test") -public class BasicCompletionHandlerTest : CompletionHandlerTestBase(){ +@Deprecated("All tests from here to be moved to the generated test") class BasicCompletionHandlerTest : CompletionHandlerTestBase(){ private fun checkResult(){ fixture.checkResultByFile(getTestName(false) + ".kt.after") } - override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, "/handlers").getPath() + File.separator + override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, "/handlers").path + File.separator private fun doTest() { doTest(2, "*", null, null, '\n') diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt index b9e997e648c..d72a4268938 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.test.KotlinTestUtils -public abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtureTestCase() { +abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtureTestCase() { protected val fixture: JavaCodeInsightTestFixture get() = myFixture @@ -55,8 +55,8 @@ public abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtur } private fun getExistentLookupElement(lookupString: String?, itemText: String?, tailText: String?): LookupElement? { - val lookup = LookupManager.getInstance(getProject())?.getActiveLookup() as LookupImpl? ?: return null - val items = lookup.getItems() + val lookup = LookupManager.getInstance(project)?.activeLookup as LookupImpl? ?: return null + val items = lookup.items if (lookupString == "*") { assert(itemText == null) @@ -67,13 +67,13 @@ public abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtur var foundElement : LookupElement? = null val presentation = LookupElementPresentation() for (lookupElement in items) { - val lookupOk = if (lookupString != null) lookupElement.getLookupString() == lookupString else true + val lookupOk = if (lookupString != null) lookupElement.lookupString == lookupString else true if (lookupOk) { lookupElement.renderElement(presentation) val textOk = if (itemText != null) { - val itemItemText = presentation.getItemText() + val itemItemText = presentation.itemText itemItemText != null && itemItemText == itemText } else { @@ -82,7 +82,7 @@ public abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtur if (textOk) { val tailOk = if (tailText != null) { - val itemTailText = presentation.getTailText() + val itemTailText = presentation.tailText itemTailText != null && itemTailText == tailText } else { @@ -111,17 +111,17 @@ public abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtur override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory() protected fun selectItem(item: LookupElement?, completionChar: Char) { - val lookup = (fixture.getLookup() as LookupImpl) - if (lookup.getCurrentItem() != item) { // do not touch selection if not changed - important for char filter tests - lookup.setCurrentItem(item) + val lookup = (fixture.lookup as LookupImpl) + if (lookup.currentItem != item) { // do not touch selection if not changed - important for char filter tests + lookup.currentItem = item } - lookup.setFocusDegree(LookupImpl.FocusDegree.FOCUSED); + lookup.focusDegree = LookupImpl.FocusDegree.FOCUSED; if (LookupEvent.isSpecialCompletionChar(completionChar)) { - (object : WriteCommandAction.Simple(getProject()) { - protected override fun run(result: Result) { + (object : WriteCommandAction.Simple(project) { + override fun run(result: Result) { run() } - protected override fun run() { + override fun run() { lookup.finishLookup(completionChar) } }).execute().throwException() diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionMultifileHandlerTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionMultifileHandlerTest.kt index a5dd100d2dd..22c60c50a55 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionMultifileHandlerTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionMultifileHandlerTest.kt @@ -23,24 +23,24 @@ import org.jetbrains.kotlin.idea.completion.test.KotlinCompletionTestCase import java.io.File import kotlin.test.assertTrue -public class SmartCompletionMultifileHandlerTest : KotlinCompletionTestCase() { - public fun testImportExtensionFunction() { doTest() } +class SmartCompletionMultifileHandlerTest : KotlinCompletionTestCase() { + fun testImportExtensionFunction() { doTest() } - public fun testImportExtensionProperty() { doTest() } + fun testImportExtensionProperty() { doTest() } - public fun testAnonymousObjectGenericJava() { doTest() } + fun testAnonymousObjectGenericJava() { doTest() } override fun setUp() { setType(CompletionType.SMART) super.setUp() } - public fun doTest() { + fun doTest() { val fileName = getTestName(false) val fileNames = listOf(fileName + "-1.kt", fileName + "-2.kt", fileName + ".java") - configureByFiles(null, *fileNames.filter { File(getTestDataPath() + it).exists() }.toTypedArray()) + configureByFiles(null, *fileNames.filter { File(testDataPath + it).exists() }.toTypedArray()) complete(1) if (myItems != null) { @@ -51,5 +51,5 @@ public class SmartCompletionMultifileHandlerTest : KotlinCompletionTestCase() { checkResultByFile(fileName + ".kt.after") } - override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, "/handlers/multifile/smart/").getPath() + File.separator + override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, "/handlers/multifile/smart/").path + File.separator } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt index 86302366439..19c77a7ced8 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.test.util.configureWithExtraFile import org.junit.Assert import java.io.File -public abstract class AbstractCompletionWeigherTest(val completionType: CompletionType, val relativeTestDataPath: String) : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractCompletionWeigherTest(val completionType: CompletionType, val relativeTestDataPath: String) : KotlinLightCodeInsightFixtureTestCase() { fun doTest(path: String) { val pathPrefix = RELATIVE_COMPLETION_TEST_DATA_BASE_PATH + "/" + relativeTestDataPath assert(path.startsWith(pathPrefix)) @@ -35,7 +35,7 @@ public abstract class AbstractCompletionWeigherTest(val completionType: Completi myFixture.configureWithExtraFile(relativePath, ".Data", ".Data1", ".Data2", ".Data3", ".Data4", ".Data5", ".Data6", relativePaths = true) - val text = myFixture.getEditor().getDocument().getText() + val text = myFixture.editor.document.text val items = InTextDirectivesUtils.findArrayWithPrefixes(text, "// ORDER:") Assert.assertTrue("""Some items should be defined with "// ORDER:" directive""", !items.isEmpty()) @@ -44,13 +44,13 @@ public abstract class AbstractCompletionWeigherTest(val completionType: Completi myFixture.assertPreferredCompletionItems(InTextDirectivesUtils.getPrefixedInt(text, "// SELECTED:") ?: 0, *items) } - override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, relativeTestDataPath).getPath() + File.separator + override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, relativeTestDataPath).path + File.separator } -public abstract class AbstractBasicCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.BASIC, "weighers/basic") { +abstract class AbstractBasicCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.BASIC, "weighers/basic") { override fun getProjectDescriptor() = KotlinLightProjectDescriptor.INSTANCE } -public abstract class AbstractSmartCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.SMART, "weighers/smart") { +abstract class AbstractSmartCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.SMART, "weighers/smart") { override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt index 2654c5b29d1..1866668dfc2 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt @@ -142,7 +142,7 @@ class ExpectedInfos( private val useHeuristicSignatures: Boolean = true, private val useOuterCallsExpectedTypeCount: Int = 0 ) { - public fun calculate(expressionWithType: KtExpression): Collection { + fun calculate(expressionWithType: KtExpression): Collection { val expectedInfos = calculateForArgument(expressionWithType) ?: calculateForFunctionLiteralArgument(expressionWithType) ?: calculateForIndexingArgument(expressionWithType) @@ -163,16 +163,16 @@ class ExpectedInfos( } private fun calculateForArgument(expressionWithType: KtExpression): Collection? { - val argument = expressionWithType.getParent() as? KtValueArgument ?: return null - val argumentList = argument.getParent() as? KtValueArgumentList ?: return null - val callElement = argumentList.getParent() as? KtCallElement ?: return null + val argument = expressionWithType.parent as? KtValueArgument ?: return null + val argumentList = argument.parent as? KtValueArgumentList ?: return null + val callElement = argumentList.parent as? KtCallElement ?: return null return calculateForArgument(callElement, argument) } private fun calculateForFunctionLiteralArgument(expressionWithType: KtExpression): Collection? { - val functionLiteralArgument = expressionWithType.getParent() as? KtLambdaArgument - val callExpression = functionLiteralArgument?.getParent() as? KtCallExpression ?: return null - val literalArgument = callExpression.getLambdaArguments().firstOrNull() ?: return null + val functionLiteralArgument = expressionWithType.parent as? KtLambdaArgument + val callExpression = functionLiteralArgument?.parent as? KtCallExpression ?: return null + val literalArgument = callExpression.lambdaArguments.firstOrNull() ?: return null if (literalArgument.getArgumentExpression() != expressionWithType) return null return calculateForArgument(callExpression, literalArgument) } @@ -191,7 +191,7 @@ class ExpectedInfos( return calculateForArgument(call, argument) } - public fun calculateForArgument(call: Call, argument: ValueArgument): Collection { + fun calculateForArgument(call: Call, argument: ValueArgument): Collection { val results = calculateForArgument(call, TypeUtils.NO_EXPECTED_TYPE, argument) fun makesSenseToUseOuterCallExpectedType(info: ExpectedInfo): Boolean { @@ -218,14 +218,14 @@ class ExpectedInfos( } private fun calculateForArgument(call: Call, callExpectedType: KotlinType, argument: ValueArgument): Collection { - val argumentIndex = call.getValueArguments().indexOf(argument) + val argumentIndex = call.valueArguments.indexOf(argument) assert(argumentIndex >= 0) { "Could not find argument '$argument(${argument.asElement().text})' among arguments of call: $call" } // leave only arguments before the current one val truncatedCall = object : DelegatingCall(call) { - val arguments = call.getValueArguments().subList(0, argumentIndex) + val arguments = call.valueArguments.subList(0, argumentIndex) override fun getValueArguments() = arguments override fun getFunctionLiteralArguments() = emptyList() @@ -262,7 +262,7 @@ class ExpectedInfos( // check that all arguments before the current one matched if (checkPrevArgumentsMatched && !candidate.allArgumentsMatched()) return - var descriptor = candidate.getResultingDescriptor() + var descriptor = candidate.resultingDescriptor if (descriptor.valueParameters.isEmpty()) return var argumentToParameter = call.mapArgumentsToParameters(descriptor) @@ -311,13 +311,13 @@ class ExpectedInfos( return } - val expectedName = if (descriptor.hasSynthesizedParameterNames()) null else parameter.getName().asString() + val expectedName = if (descriptor.hasSynthesizedParameterNames()) null else parameter.name.asString() fun needCommaForParameter(parameter: ValueParameterDescriptor): Boolean { if (parameter.hasDefaultValue()) return false // parameter is optional if (parameter.varargElementType != null) return false // vararg arguments list can be empty // last parameter of functional type can be placed outside parenthesis: - if (!isArrayAccess && parameter == parameters.last() && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameter.getType())) return false + if (!isArrayAccess && parameter == parameters.last() && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameter.type)) return false return true } @@ -349,16 +349,16 @@ class ExpectedInfos( } val starOptions = if (!alreadyHasStar) ItemOptions.STAR_PREFIX else ItemOptions.DEFAULT - add(ExpectedInfo.createForArgument(parameter.getType(), expectedName, varargTail, argumentPositionData, starOptions)) + add(ExpectedInfo.createForArgument(parameter.type, expectedName, varargTail, argumentPositionData, starOptions)) } else { if (alreadyHasStar) return val parameterType = if (useHeuristicSignatures) resolutionFacade.ideService(). - correctedParameterType(descriptor, parameter) ?: parameter.getType() + correctedParameterType(descriptor, parameter) ?: parameter.type else - parameter.getType() + parameter.type if (isFunctionLiteralArgument) { if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { @@ -378,8 +378,8 @@ class ExpectedInfos( = getArgumentExpression()?.let { bindingContext.getType(it) }?.isError ?: true private fun namedArgumentTail(argumentToParameter: Map, argumentName: Name, descriptor: FunctionDescriptor): Tail? { - val usedParameterNames = (argumentToParameter.values.map { it.getName() } + listOf(argumentName)).toSet() - val notUsedParameters = descriptor.getValueParameters().filter { it.getName() !in usedParameterNames } + val usedParameterNames = (argumentToParameter.values.map { it.name } + listOf(argumentName)).toSet() + val notUsedParameters = descriptor.valueParameters.filter { it.name !in usedParameterNames } return if (notUsedParameters.isEmpty()) Tail.RPARENTH // named arguments no supported for [] else if (notUsedParameters.all { it.hasDefaultValue() }) @@ -389,11 +389,11 @@ class ExpectedInfos( } private fun calculateForEqAndAssignment(expressionWithType: KtExpression): Collection? { - val binaryExpression = expressionWithType.getParent() as? KtBinaryExpression + val binaryExpression = expressionWithType.parent as? KtBinaryExpression if (binaryExpression != null) { - val operationToken = binaryExpression.getOperationToken() + val operationToken = binaryExpression.operationToken if (operationToken == KtTokens.EQ || operationToken in COMPARISON_TOKENS) { - val otherOperand = if (expressionWithType == binaryExpression.getRight()) binaryExpression.getLeft() else binaryExpression.getRight() + val otherOperand = if (expressionWithType == binaryExpression.right) binaryExpression.left else binaryExpression.right if (otherOperand != null) { var expectedType = bindingContext.getType(otherOperand) ?: return null @@ -421,16 +421,16 @@ class ExpectedInfos( } private fun calculateForIf(expressionWithType: KtExpression): Collection? { - val ifExpression = (expressionWithType.getParent() as? KtContainerNode)?.getParent() as? KtIfExpression ?: return null + val ifExpression = (expressionWithType.parent as? KtContainerNode)?.parent as? KtIfExpression ?: return null return when (expressionWithType) { - ifExpression.getCondition() -> listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, Tail.RPARENTH, additionalData = IfConditionAdditionalData)) + ifExpression.condition -> listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, Tail.RPARENTH, additionalData = IfConditionAdditionalData)) - ifExpression.getThen() -> calculate(ifExpression).map { ExpectedInfo(it.filter, it.expectedName, Tail.ELSE) } + ifExpression.then -> calculate(ifExpression).map { ExpectedInfo(it.filter, it.expectedName, Tail.ELSE) } - ifExpression.getElse() -> { + ifExpression.`else` -> { val ifExpectedInfo = calculate(ifExpression) - val thenType = ifExpression.getThen()?.let { bindingContext.getType(it) } - val filteredInfo = if (thenType != null && !thenType.isError()) + val thenType = ifExpression.then?.let { bindingContext.getType(it) } + val filteredInfo = if (thenType != null && !thenType.isError) ifExpectedInfo.filter { it.matchingSubstitutor(thenType) != null } else ifExpectedInfo @@ -442,11 +442,11 @@ class ExpectedInfos( } private fun calculateForElvis(expressionWithType: KtExpression): Collection? { - val binaryExpression = expressionWithType.getParent() as? KtBinaryExpression + val binaryExpression = expressionWithType.parent as? KtBinaryExpression if (binaryExpression != null) { - val operationToken = binaryExpression.getOperationToken() - if (operationToken == KtTokens.ELVIS && expressionWithType == binaryExpression.getRight()) { - val leftExpression = binaryExpression.getLeft() ?: return null + val operationToken = binaryExpression.operationToken + if (operationToken == KtTokens.ELVIS && expressionWithType == binaryExpression.right) { + val leftExpression = binaryExpression.left ?: return null val leftType = bindingContext.getType(leftExpression) val leftTypeNotNullable = leftType?.makeNotNullable() val expectedInfos = calculate(binaryExpression) @@ -486,10 +486,10 @@ class ExpectedInfos( } private fun calculateForWhenEntryValue(expressionWithType: KtExpression): Collection? { - val condition = expressionWithType.getParent() as? KtWhenConditionWithExpression ?: return null - val entry = condition.getParent() as KtWhenEntry - val whenExpression = entry.getParent() as KtWhenExpression - val subject = whenExpression.getSubjectExpression() + val condition = expressionWithType.parent as? KtWhenConditionWithExpression ?: return null + val entry = condition.parent as KtWhenEntry + val whenExpression = entry.parent as KtWhenExpression + val subject = whenExpression.subjectExpression if (subject != null) { val subjectType = bindingContext.getType(subject) ?: return null return listOf(ExpectedInfo(subjectType, null, null, additionalData = WhenEntryAdditionalData(whenWithSubject = true))) @@ -500,32 +500,32 @@ class ExpectedInfos( } private fun calculateForExclOperand(expressionWithType: KtExpression): Collection? { - val prefixExpression = expressionWithType.getParent() as? KtPrefixExpression ?: return null - if (prefixExpression.getOperationToken() != KtTokens.EXCL) return null + val prefixExpression = expressionWithType.parent as? KtPrefixExpression ?: return null + if (prefixExpression.operationToken != KtTokens.EXCL) return null return listOf(ExpectedInfo(resolutionFacade.moduleDescriptor.builtIns.booleanType, null, null)) } private fun calculateForInitializer(expressionWithType: KtExpression): Collection? { - val property = expressionWithType.getParent() as? KtProperty ?: return null - if (expressionWithType != property.getInitializer()) return null + val property = expressionWithType.parent as? KtProperty ?: return null + if (expressionWithType != property.initializer) return null val propertyDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, property] as? VariableDescriptor ?: return null val expectedName = propertyDescriptor.name.asString() val expectedInfo = if (property.typeReference != null) - ExpectedInfo(propertyDescriptor.getType(), expectedName, null) + ExpectedInfo(propertyDescriptor.type, expectedName, null) else ExpectedInfo(ByTypeFilter.All, expectedName, null) // no explicit type - only expected name known return listOf(expectedInfo) } private fun calculateForExpressionBody(expressionWithType: KtExpression): Collection? { - val declaration = expressionWithType.getParent() as? KtDeclarationWithBody ?: return null - if (expressionWithType != declaration.getBodyExpression() || declaration.hasBlockBody()) return null + val declaration = expressionWithType.parent as? KtDeclarationWithBody ?: return null + if (expressionWithType != declaration.bodyExpression || declaration.hasBlockBody()) return null val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] as? FunctionDescriptor ?: return null return functionReturnValueExpectedInfo(descriptor, expectType = declaration.hasDeclaredReturnType()).singletonOrEmptyList() } private fun calculateForReturn(expressionWithType: KtExpression): Collection? { - val returnExpression = expressionWithType.getParent() as? KtReturnExpression ?: return null + val returnExpression = expressionWithType.parent as? KtReturnExpression ?: return null val descriptor = returnExpression.getTargetFunctionDescriptor(bindingContext) ?: return null return functionReturnValueExpectedInfo(descriptor, expectType = true).singletonOrEmptyList() } @@ -539,7 +539,7 @@ class ExpectedInfos( is PropertyGetterDescriptor -> { if (descriptor !is PropertyGetterDescriptor) return null - val property = descriptor.getCorrespondingProperty() + val property = descriptor.correspondingProperty val expectedType = if (expectType) property.type else null ExpectedInfo.createForReturnValue(expectedType, property) } @@ -595,9 +595,9 @@ class ExpectedInfos( private fun expectedNameFromExpression(expression: KtExpression?): String? { return when (expression) { is KtSimpleNameExpression -> expression.getReferencedName() - is KtQualifiedExpression -> expectedNameFromExpression(expression.getSelectorExpression()) - is KtCallExpression -> expectedNameFromExpression(expression.getCalleeExpression()) - is KtArrayAccessExpression -> expectedNameFromExpression(expression.getArrayExpression())?.unpluralize() + is KtQualifiedExpression -> expectedNameFromExpression(expression.selectorExpression) + is KtCallExpression -> expectedNameFromExpression(expression.calleeExpression) + is KtArrayAccessExpression -> expectedNameFromExpression(expression.arrayExpression)?.unpluralize() else -> null } } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/HeuristicSignatures.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/HeuristicSignatures.kt index 53be07f1563..254a9d54061 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/HeuristicSignatures.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/HeuristicSignatures.kt @@ -41,16 +41,16 @@ internal class HeuristicSignatures( private val project: Project, private val typeResolver: TypeResolver ) { - public fun correctedParameterType(function: FunctionDescriptor, parameter: ValueParameterDescriptor): KotlinType? { - val parameterIndex = function.getValueParameters().indexOf(parameter) + fun correctedParameterType(function: FunctionDescriptor, parameter: ValueParameterDescriptor): KotlinType? { + val parameterIndex = function.valueParameters.indexOf(parameter) assert(parameterIndex >= 0) return correctedParameterType(function, parameterIndex) } private fun correctedParameterType(function: FunctionDescriptor, parameterIndex: Int): KotlinType? { - val ownerType = function.getDispatchReceiverParameter()?.getType() ?: return null + val ownerType = function.dispatchReceiverParameter?.type ?: return null - val superFunctions = function.getOverriddenDescriptors() + val superFunctions = function.overriddenDescriptors if (superFunctions.isNotEmpty()) { for (superFunction in superFunctions) { val correctedType = correctedParameterType(superFunction, parameterIndex) ?: continue @@ -60,12 +60,12 @@ internal class HeuristicSignatures( return null } else { - val ownerClass = ownerType.getConstructor().getDeclarationDescriptor() ?: return null + val ownerClass = ownerType.constructor.declarationDescriptor ?: return null val classFqName = DescriptorUtils.getFqName(ownerClass) - if (!classFqName.isSafe()) return null - val parameterTypes = signatures[classFqName.toSafe() to function.getName()] ?: return null + if (!classFqName.isSafe) return null + val parameterTypes = signatures[classFqName.toSafe() to function.name] ?: return null val typeStr = parameterTypes[parameterIndex] - val typeParameters = ownerClass.getTypeConstructor().getParameters() + val typeParameters = ownerClass.typeConstructor.parameters val type = typeFromText(typeStr, typeParameters) @@ -81,7 +81,7 @@ internal class HeuristicSignatures( typeParameters.forEach { addClassifierDescriptor(it) } } val type = typeResolver.resolveType(scope, typeRef, BindingTraceContext(), false) - assert(!type.isError()) { "No type resolved from '$text'" } + assert(!type.isError) { "No type resolved from '$text'" } return type } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ImportableFqNameClassifier.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ImportableFqNameClassifier.kt index 95b32a1e8fb..eb31a05162f 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ImportableFqNameClassifier.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ImportableFqNameClassifier.kt @@ -30,10 +30,10 @@ class ImportableFqNameClassifier(private val file: KtFile) { private val allUnderImports = HashSet() init { - for (import in file.getImportDirectives()) { - val importPath = import.getImportPath() ?: continue + for (import in file.importDirectives) { + val importPath = import.importPath ?: continue val fqName = importPath.fqnPart() - if (importPath.isAllUnder()) { + if (importPath.isAllUnder) { allUnderImports.add(fqName) } else { diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt index 9d6298b379f..88f5d04201f 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.expressions.ForLoopConventionsChecker import org.jetbrains.kotlin.util.isValidOperator import java.util.* -public class IterableTypesDetection( +class IterableTypesDetection( private val project: Project, private val forLoopConventionsChecker: ForLoopConventionsChecker ) { @@ -42,7 +42,7 @@ public class IterableTypesDetection( private val iteratorName = Name.identifier("iterator") } - public fun createDetector(scope: LexicalScope): IterableTypesDetector { + fun createDetector(scope: LexicalScope): IterableTypesDetector { return Detector(scope) } private inner class Detector(private val scope: LexicalScope): IterableTypesDetector { @@ -89,10 +89,10 @@ public class IterableTypesDetection( } } -public interface IterableTypesDetector { - public fun isIterable(type: KotlinType, loopVarType: KotlinType? = null): Boolean +interface IterableTypesDetector { + fun isIterable(type: KotlinType, loopVarType: KotlinType? = null): Boolean - public fun isIterable(type: FuzzyType, loopVarType: KotlinType? = null): Boolean + fun isIterable(type: FuzzyType, loopVarType: KotlinType? = null): Boolean - public fun elementType(type: KotlinType): FuzzyType? + fun elementType(type: KotlinType): FuzzyType? } \ No newline at end of file diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt index 1323fc33a9f..25321491670 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt @@ -58,7 +58,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* -public class KotlinIndicesHelper( +class KotlinIndicesHelper( private val resolutionFacade: ResolutionFacade, private val scope: GlobalSearchScope, visibilityFilter: (DeclarationDescriptor) -> Boolean, @@ -76,7 +76,7 @@ public class KotlinIndicesHelper( true } - public fun getTopLevelCallablesByName(name: String): Collection { + fun getTopLevelCallablesByName(name: String): Collection { val declarations = HashSet() declarations.addTopLevelNonExtensionCallablesByName(KotlinFunctionShortNameIndex.getInstance(), name) declarations.addTopLevelNonExtensionCallablesByName(KotlinPropertyShortNameIndex.getInstance(), name) @@ -89,10 +89,10 @@ public class KotlinIndicesHelper( index: StringStubIndexExtension, name: String ) { - index.get(name, project, scope).filterTo(this) { it.getParent() is KtFile && it.getReceiverTypeReference() == null } + index.get(name, project, scope).filterTo(this) { it.parent is KtFile && it.receiverTypeReference == null } } - public fun processTopLevelCallables(nameFilter: (String) -> Boolean, processor: (CallableDescriptor) -> Unit) { + fun processTopLevelCallables(nameFilter: (String) -> Boolean, processor: (CallableDescriptor) -> Unit) { fun processIndex(index: StringStubIndexExtension) { for (key in index.getAllKeys(project)) { ProgressManager.checkCanceled() @@ -114,7 +114,7 @@ public class KotlinIndicesHelper( processIndex(KotlinTopLevelPropertyFqnNameIndex.getInstance()) } - public fun getCallableTopLevelExtensions( + fun getCallableTopLevelExtensions( callTypeAndReceiver: CallTypeAndReceiver<*, *>, position: KtExpression, bindingContext: BindingContext, @@ -125,7 +125,7 @@ public class KotlinIndicesHelper( return getCallableTopLevelExtensions(callTypeAndReceiver, receiverTypes, nameFilter) } - public fun getCallableTopLevelExtensions( + fun getCallableTopLevelExtensions( callTypeAndReceiver: CallTypeAndReceiver<*, *>, receiverTypes: Collection, nameFilter: (String) -> Boolean @@ -161,9 +161,9 @@ public class KotlinIndicesHelper( } private fun MutableCollection.addTypeNames(type: KotlinType) { - val constructor = type.getConstructor() - addIfNotNull(constructor.getDeclarationDescriptor()?.getName()?.asString()) - constructor.getSupertypes().forEach { addTypeNames(it) } + val constructor = type.constructor + addIfNotNull(constructor.declarationDescriptor?.name?.asString()) + constructor.supertypes.forEach { addTypeNames(it) } } /** @@ -187,14 +187,14 @@ public class KotlinIndicesHelper( return result } - public fun getJvmClassesByName(name: String): Collection { + fun getJvmClassesByName(name: String): Collection { return PsiShortNamesCache.getInstance(project).getClassesByName(name, scope) .mapNotNull { it.resolveToDescriptor(resolutionFacade) } .filter(descriptorFilter) .toSet() } - public fun getKotlinClasses(nameFilter: (String) -> Boolean, kindFilter: (ClassKind) -> Boolean): Collection { + fun getKotlinClasses(nameFilter: (String) -> Boolean, kindFilter: (ClassKind) -> Boolean): Collection { return KotlinFullClassNameIndex.getInstance().getAllKeys(project).asSequence() .map { FqName(it) } .filter { @@ -214,11 +214,11 @@ public class KotlinIndicesHelper( } // Note: Can't search with psi element as analyzer could be built over temp files - return ResolveSessionUtils.getClassOrObjectDescriptorsByFqName(moduleDescriptor, classFQName) { kindFilter(it.getKind()) } + return ResolveSessionUtils.getClassOrObjectDescriptorsByFqName(moduleDescriptor, classFQName) { kindFilter(it.kind) } .filter(descriptorFilter) } - public fun processObjectMembers( + fun processObjectMembers( descriptorKindFilter: DescriptorKindFilter, nameFilter: (String) -> Boolean, filter: (KtCallableDeclaration, KtObjectDeclaration) -> Boolean, @@ -251,7 +251,7 @@ public class KotlinIndicesHelper( } } - public fun processJavaStaticMembers( + fun processJavaStaticMembers( descriptorKindFilter: DescriptorKindFilter, nameFilter: (String) -> Boolean, processor: (DeclarationDescriptor) -> Unit @@ -308,7 +308,7 @@ public class KotlinIndicesHelper( } private fun KtCallableDeclaration.resolveToDescriptorsWithHack(): Collection { - if (getContainingKtFile().isCompiled()) { //TODO: it's temporary while resolveToDescriptor does not work for compiled declarations + if (getContainingKtFile().isCompiled) { //TODO: it's temporary while resolveToDescriptor does not work for compiled declarations return resolutionFacade.resolveImportReference(moduleDescriptor, fqName!!).filterIsInstance() } else { diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt index ca3b0d14d1c..35330143313 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt @@ -33,8 +33,8 @@ import org.jetbrains.kotlin.types.typeUtil.builtIns import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart import java.util.* -public object KotlinNameSuggester { - public fun suggestNamesByExpressionAndType( +object KotlinNameSuggester { + fun suggestNamesByExpressionAndType( expression: KtExpression, type: KotlinType?, bindingContext: BindingContext?, @@ -56,7 +56,7 @@ public object KotlinNameSuggester { return result } - public fun suggestNamesByType(type: KotlinType, validator: (String) -> Boolean, defaultName: String? = null): List { + fun suggestNamesByType(type: KotlinType, validator: (String) -> Boolean, defaultName: String? = null): List { val result = ArrayList() result.addNamesByType(type, validator) @@ -68,7 +68,7 @@ public object KotlinNameSuggester { return result } - public fun suggestNamesByExpressionOnly( + fun suggestNamesByExpressionOnly( expression: KtExpression, bindingContext: BindingContext?, validator: (String) -> Boolean, defaultName: String? = null): List { @@ -83,7 +83,7 @@ public object KotlinNameSuggester { return result } - public fun suggestIterationVariableNames( + fun suggestIterationVariableNames( collection: KtExpression, elementType: KotlinType, bindingContext: BindingContext?, @@ -105,7 +105,7 @@ public object KotlinNameSuggester { private val COMMON_TYPE_PARAMETER_NAMES = listOf("T", "U", "V", "W", "X", "Y", "Z") - public fun suggestNamesForTypeParameters(count: Int, validator: (String) -> Boolean): List { + fun suggestNamesForTypeParameters(count: Int, validator: (String) -> Boolean): List { val result = ArrayList() for (i in 0..count - 1) { result.add(suggestNameByMultipleNames(COMMON_TYPE_PARAMETER_NAMES, validator)) @@ -118,7 +118,7 @@ public object KotlinNameSuggester { * @param name to check it in scope * @return name or nameI, where I is number */ - public fun suggestNameByName(name: String, validator: (String) -> Boolean): String { + fun suggestNameByName(name: String, validator: (String) -> Boolean): String { if (validator(name)) return name var i = 1 while (!validator(name + i)) { @@ -134,7 +134,7 @@ public object KotlinNameSuggester { * @param names to check it in scope * @return name or nameI, where name is one of variants and I is a number */ - public fun suggestNameByMultipleNames(names: Collection, validator: (String) -> Boolean): String { + fun suggestNameByMultipleNames(names: Collection, validator: (String) -> Boolean): String { var i = 0 while (true) { for (name in names) { @@ -151,66 +151,66 @@ public object KotlinNameSuggester { val typeChecker = KotlinTypeChecker.DEFAULT if (ErrorUtils.containsErrorType(type)) return - if (typeChecker.equalTypes(builtIns.getBooleanType(), type)) { + if (typeChecker.equalTypes(builtIns.booleanType, type)) { addName("b", validator) } - else if (typeChecker.equalTypes(builtIns.getIntType(), type)) { + else if (typeChecker.equalTypes(builtIns.intType, type)) { addName("i", validator) } - else if (typeChecker.equalTypes(builtIns.getByteType(), type)) { + else if (typeChecker.equalTypes(builtIns.byteType, type)) { addName("byte", validator) } - else if (typeChecker.equalTypes(builtIns.getLongType(), type)) { + else if (typeChecker.equalTypes(builtIns.longType, type)) { addName("l", validator) } - else if (typeChecker.equalTypes(builtIns.getFloatType(), type)) { + else if (typeChecker.equalTypes(builtIns.floatType, type)) { addName("fl", validator) } - else if (typeChecker.equalTypes(builtIns.getDoubleType(), type)) { + else if (typeChecker.equalTypes(builtIns.doubleType, type)) { addName("d", validator) } - else if (typeChecker.equalTypes(builtIns.getShortType(), type)) { + else if (typeChecker.equalTypes(builtIns.shortType, type)) { addName("sh", validator) } - else if (typeChecker.equalTypes(builtIns.getCharType(), type)) { + else if (typeChecker.equalTypes(builtIns.charType, type)) { addName("c", validator) } - else if (typeChecker.equalTypes(builtIns.getStringType(), type)) { + else if (typeChecker.equalTypes(builtIns.stringType, type)) { addName("s", validator) } else if (KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { val elementType = builtIns.getArrayElementType(type) - if (typeChecker.equalTypes(builtIns.getBooleanType(), elementType)) { + if (typeChecker.equalTypes(builtIns.booleanType, elementType)) { addName("booleans", validator) } - else if (typeChecker.equalTypes(builtIns.getIntType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.intType, elementType)) { addName("ints", validator) } - else if (typeChecker.equalTypes(builtIns.getByteType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.byteType, elementType)) { addName("bytes", validator) } - else if (typeChecker.equalTypes(builtIns.getLongType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.longType, elementType)) { addName("longs", validator) } - else if (typeChecker.equalTypes(builtIns.getFloatType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.floatType, elementType)) { addName("floats", validator) } - else if (typeChecker.equalTypes(builtIns.getDoubleType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.doubleType, elementType)) { addName("doubles", validator) } - else if (typeChecker.equalTypes(builtIns.getShortType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.shortType, elementType)) { addName("shorts", validator) } - else if (typeChecker.equalTypes(builtIns.getCharType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.charType, elementType)) { addName("chars", validator) } - else if (typeChecker.equalTypes(builtIns.getStringType(), elementType)) { + else if (typeChecker.equalTypes(builtIns.stringType, elementType)) { addName("strings", validator) } else { val classDescriptor = TypeUtils.getClassDescriptor(elementType) if (classDescriptor != null) { - val className = classDescriptor.getName() + val className = classDescriptor.name addName("arrayOf" + StringUtil.capitalize(className.asString()) + "s", validator) } } @@ -219,10 +219,10 @@ public object KotlinNameSuggester { addName("function", validator) } else { - val descriptor = type.getConstructor().getDeclarationDescriptor() + val descriptor = type.constructor.declarationDescriptor if (descriptor != null) { - val className = descriptor.getName() - if (!className.isSpecial()) { + val className = descriptor.name + if (!className.isSpecial) { addCamelNames(className.asString(), validator) } } @@ -231,7 +231,7 @@ public object KotlinNameSuggester { private val ACCESSOR_PREFIXES = arrayOf("get", "is", "set") - public fun getCamelNames(name: String, validator: (String) -> Boolean, startLowerCase: Boolean): List { + fun getCamelNames(name: String, validator: (String) -> Boolean, startLowerCase: Boolean): List { val result = ArrayList() result.addCamelNames(name, validator, startLowerCase) return result @@ -331,13 +331,13 @@ public object KotlinNameSuggester { add(suggestNameByName(correctedName, validator)) } - public fun isIdentifier(name: String?): Boolean { + fun isIdentifier(name: String?): Boolean { if (name == null || name.isEmpty()) return false val lexer = KotlinLexer() lexer.start(name, 0, name.length) - if (lexer.getTokenType() !== KtTokens.IDENTIFIER) return false + if (lexer.tokenType !== KtTokens.IDENTIFIER) return false lexer.advance() - return lexer.getTokenType() == null + return lexer.tokenType == null } } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/NameValidators.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/NameValidators.kt index d96ff945f9e..27a7b1ec630 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/NameValidators.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/NameValidators.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.* -public class CollectingNameValidator @JvmOverloads constructor( +class CollectingNameValidator @JvmOverloads constructor( existingNames: Collection = Collections.emptySet(), private val filter: (String) -> Boolean = { true } ): (String) -> Boolean { @@ -52,24 +52,24 @@ public class CollectingNameValidator @JvmOverloads constructor( return false } - public fun addName(name: String) { + fun addName(name: String) { existingNames.add(name) } } -public class NewDeclarationNameValidator( +class NewDeclarationNameValidator( private val visibleDeclarationsContext: KtElement?, private val checkDeclarationsIn: Sequence, private val target: NewDeclarationNameValidator.Target ) : (String) -> Boolean { - public constructor(container: PsiElement, anchor: PsiElement?, target: NewDeclarationNameValidator.Target) + constructor(container: PsiElement, anchor: PsiElement?, target: NewDeclarationNameValidator.Target) : this( (anchor ?: container).parentsWithSelf.firstIsInstanceOrNull(), anchor?.siblings() ?: container.allChildren, target) - public enum class Target { + enum class Target { VARIABLES, FUNCTIONS_AND_CLASSES } @@ -106,8 +106,8 @@ public class NewDeclarationNameValidator( } private fun KtNamedDeclaration.isConflicting(name: Name): Boolean { - if (getNameAsName() != name) return false - if (this is KtCallableDeclaration && getReceiverTypeReference() != null) return false + if (nameAsName != name) return false + if (this is KtCallableDeclaration && receiverTypeReference != null) return false return when(target) { Target.VARIABLES -> this is KtVariableDeclaration Target.FUNCTIONS_AND_CLASSES -> this is KtNamedFunction || this is KtClassOrObject diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/OptionalParametersHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/OptionalParametersHelper.kt index 1f9791ad0e9..13e21077c55 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/OptionalParametersHelper.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/OptionalParametersHelper.kt @@ -37,23 +37,23 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import java.util.* -public object OptionalParametersHelper { - public fun detectArgumentsToDropForDefaults( +object OptionalParametersHelper { + fun detectArgumentsToDropForDefaults( resolvedCall: ResolvedCall, project: Project, canDrop: (ValueArgument) -> Boolean = { true } ): Collection { if (!resolvedCall.isReallySuccess()) return emptyList() - val descriptor = resolvedCall.getResultingDescriptor() + val descriptor = resolvedCall.resultingDescriptor - val parameterToDefaultValue = descriptor.getValueParameters() + val parameterToDefaultValue = descriptor.valueParameters .mapNotNull { parameter -> defaultParameterValue(parameter, project)?.let { parameter to it } } .toMap() if (parameterToDefaultValue.isEmpty()) return emptyList() //TODO: drop functional literal out of parenthesis too - val arguments = resolvedCall.getCall().getValueArgumentsInParentheses() + val arguments = resolvedCall.call.getValueArgumentsInParentheses() val argumentsToDrop = ArrayList() for (argument in arguments.asReversed()) { if (!canDrop(argument) || !argument.matchesDefault(resolvedCall, parameterToDefaultValue)) { @@ -70,7 +70,7 @@ public object OptionalParametersHelper { val defaultValue = parameterToDefaultValue[parameter] ?: return false val expression = defaultValue.substituteArguments(resolvedCall) val argumentExpression = getArgumentExpression()!! - return argumentExpression.getText() == expression.getText() //TODO + return argumentExpression.text == expression.text //TODO } private fun DefaultValue.substituteArguments(resolvedCall: ResolvedCall): KtExpression { @@ -79,9 +79,9 @@ public object OptionalParametersHelper { val key = Key("SUBSTITUTION") for ((parameter, usages) in parameterUsages) { - val resolvedArgument = resolvedCall.getValueArguments()[parameter]!! + val resolvedArgument = resolvedCall.valueArguments[parameter]!! if (resolvedArgument is ExpressionValueArgument) { - val argument = resolvedArgument.getValueArgument()!!.getArgumentExpression()!! + val argument = resolvedArgument.valueArgument!!.getArgumentExpression()!! usages.forEach { it.putCopyableUserData(key, argument) } } //TODO: vararg @@ -109,31 +109,31 @@ public object OptionalParametersHelper { return expressionCopy } - public data class DefaultValue( - public val expression: KtExpression, - public val parameterUsages: Map> + data class DefaultValue( + val expression: KtExpression, + val parameterUsages: Map> ) - public fun defaultParameterValueExpression(parameter: ValueParameterDescriptor, project: Project): KtExpression? { + fun defaultParameterValueExpression(parameter: ValueParameterDescriptor, project: Project): KtExpression? { if (!parameter.hasDefaultValue()) return null if (!parameter.declaresDefaultValue()) { - val overridden = parameter.getOverriddenDescriptors().firstOrNull { it.hasDefaultValue() } ?: return null + val overridden = parameter.overriddenDescriptors.firstOrNull { it.hasDefaultValue() } ?: return null return defaultParameterValueExpression(overridden, project) } //TODO: parameter in overriding method! //TODO: it's a temporary code while we don't have default values accessible from descriptors - val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, parameter)?.getNavigationElement() as? KtParameter + val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, parameter)?.navigationElement as? KtParameter return declaration?.defaultValue } //TODO: handle imports //TODO: handle implicit receivers - public fun defaultParameterValue(parameter: ValueParameterDescriptor, project: Project): DefaultValue? { + fun defaultParameterValue(parameter: ValueParameterDescriptor, project: Project): DefaultValue? { val expression = defaultParameterValueExpression(parameter, project) ?: return null - val allParameters = parameter.getContainingDeclaration().getValueParameters().toSet() + val allParameters = parameter.containingDeclaration.valueParameters.toSet() val parameterUsages = HashMap>() diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/TypesWithContainsDetector.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/TypesWithContainsDetector.kt index c204164216b..4dca38f1d92 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/TypesWithContainsDetector.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/TypesWithContainsDetector.kt @@ -43,10 +43,10 @@ internal class TypesWithContainsDetector( private val typesWithExtensionContains: Collection = scope .collectFunctions(containsName, NoLookupLocation.FROM_IDE) - .filter { it.getExtensionReceiverParameter() != null && isGoodContainsFunction(it, listOf()) } - .map { it.getExtensionReceiverParameter()!!.getType() } + .filter { it.extensionReceiverParameter != null && isGoodContainsFunction(it, listOf()) } + .map { it.extensionReceiverParameter!!.type } - public fun hasContains(type: FuzzyType): Boolean { + fun hasContains(type: FuzzyType): Boolean { return cache.getOrPut(type, { hasContainsNoCache(type) }) } @@ -57,10 +57,10 @@ internal class TypesWithContainsDetector( } private fun isGoodContainsFunction(function: FunctionDescriptor, freeTypeParams: Collection): Boolean { - if (!TypeUtils.equalTypes(function.getReturnType()!!, booleanType)) return false - val parameter = function.getValueParameters().singleOrNull() ?: return false - val parameterType = heuristicSignatures.correctedParameterType(function, parameter) ?: parameter.getType() - val fuzzyParameterType = FuzzyType(parameterType, function.getTypeParameters() + freeTypeParams) + if (!TypeUtils.equalTypes(function.returnType!!, booleanType)) return false + val parameter = function.valueParameters.singleOrNull() ?: return false + val parameterType = heuristicSignatures.correctedParameterType(function, parameter) ?: parameter.type + val fuzzyParameterType = FuzzyType(parameterType, function.typeParameters + freeTypeParams) return fuzzyParameterType.checkIsSuperTypeOf(argumentType) != null } } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt index ec011ccb828..7bd566404bc 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt @@ -47,16 +47,16 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import java.util.* -public fun Call.mapArgumentsToParameters(targetDescriptor: CallableDescriptor): Map { - val parameters = targetDescriptor.getValueParameters() +fun Call.mapArgumentsToParameters(targetDescriptor: CallableDescriptor): Map { + val parameters = targetDescriptor.valueParameters if (parameters.isEmpty()) return emptyMap() val map = HashMap() - val parametersByName = parameters.toMapBy { it.getName() } + val parametersByName = parameters.toMapBy { it.name } var positionalArgumentIndex: Int? = 0 - for (argument in getValueArguments()) { + for (argument in valueArguments) { if (argument is LambdaArgument) { map[argument] = parameters.last() } @@ -88,22 +88,22 @@ public fun Call.mapArgumentsToParameters(targetDescriptor: CallableDescriptor): return map } -public fun ImplicitReceiver.asExpression(resolutionScope: LexicalScope, psiFactory: KtPsiFactory): KtExpression? { +fun ImplicitReceiver.asExpression(resolutionScope: LexicalScope, psiFactory: KtPsiFactory): KtExpression? { val expressionFactory = resolutionScope.getImplicitReceiversWithInstanceToExpression() .entries - .firstOrNull { it.key.getContainingDeclaration() == this.declarationDescriptor } + .firstOrNull { it.key.containingDeclaration == this.declarationDescriptor } ?.value ?: return null return expressionFactory.createExpression(psiFactory) } -public fun KtImportDirective.targetDescriptors(resolutionFacade: ResolutionFacade = this.getResolutionFacade()): Collection { +fun KtImportDirective.targetDescriptors(resolutionFacade: ResolutionFacade = this.getResolutionFacade()): Collection { // For codeFragments imports are created in dummy file if (this.getContainingKtFile().doNotAnalyze != null) return emptyList() val nameExpression = importedReference?.getQualifiedElementSelector() as? KtSimpleNameExpression ?: return emptyList() return nameExpression.mainReference.resolveToDescriptors(resolutionFacade.analyze(nameExpression)) } -public fun Call.resolveCandidates( +fun Call.resolveCandidates( bindingContext: BindingContext, resolutionFacade: ResolutionFacade, expectedType: KotlinType = expectedType(this, bindingContext), diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt index 41aed30a03b..de12798fe2c 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt @@ -23,15 +23,15 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -public interface DeclarationLookupObject : Iconable { - public val psiElement: PsiElement? - public val descriptor: DeclarationDescriptor? - public val name: Name? - public val importableFqName: FqName? - public val isDeprecated: Boolean +interface DeclarationLookupObject : Iconable { + val psiElement: PsiElement? + val descriptor: DeclarationDescriptor? + val name: Name? + val importableFqName: FqName? + val isDeprecated: Boolean } -public data class PackageLookupObject(val fqName: FqName) : DeclarationLookupObject { +data class PackageLookupObject(val fqName: FqName) : DeclarationLookupObject { override val psiElement: PsiElement? get() = null override val descriptor: DeclarationDescriptor? get() = null diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt index 8583b912483..7bb8184e1a6 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt @@ -85,7 +85,7 @@ private fun compareDescriptorsText(project: Project, d1: DeclarationDescriptor, return false } -public fun compareDescriptors(project: Project, currentDescriptor: DeclarationDescriptor?, originalDescriptor: DeclarationDescriptor?): Boolean { +fun compareDescriptors(project: Project, currentDescriptor: DeclarationDescriptor?, originalDescriptor: DeclarationDescriptor?): Boolean { if (currentDescriptor == originalDescriptor) return true if (currentDescriptor == null || originalDescriptor == null) return false @@ -110,7 +110,7 @@ public fun compareDescriptors(project: Project, currentDescriptor: DeclarationDe return false } -public fun Visibility.toKeywordToken(): KtModifierKeywordToken { +fun Visibility.toKeywordToken(): KtModifierKeywordToken { val normalized = normalize() when (normalized) { Visibilities.PUBLIC -> return KtTokens.PUBLIC_KEYWORD diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/ImplementMembersHandler.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/ImplementMembersHandler.kt index 1d8c144b852..83de9886b45 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/ImplementMembersHandler.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/ImplementMembersHandler.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtEnumEntry import org.jetbrains.kotlin.resolve.OverrideResolver -public open class ImplementMembersHandler : OverrideImplementMembersHandler(), IntentionAction { +open class ImplementMembersHandler : OverrideImplementMembersHandler(), IntentionAction { override fun collectMembersToGenerate(descriptor: ClassDescriptor, project: Project): Collection { return OverrideResolver.getMissingImplementations(descriptor) .map { OverrideMemberChooserObject.create(project, it, it, OverrideMemberChooserObject.BodyType.EMPTY) } @@ -45,7 +45,7 @@ public open class ImplementMembersHandler : OverrideImplementMembersHandler(), I override fun isAvailable(project: Project, editor: Editor, file: PsiFile) = isValidFor(editor, file) } -public class ImplementAsConstructorParameter : ImplementMembersHandler() { +class ImplementAsConstructorParameter : ImplementMembersHandler() { override fun getText() = "Implement as constructor parameters" override fun isValidForClass(classOrObject: KtClassOrObject): Boolean { diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideImplementMembersHandler.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideImplementMembersHandler.kt index 2efb2489b0a..8e262efca05 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideImplementMembersHandler.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideImplementMembersHandler.kt @@ -32,9 +32,9 @@ import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType -public abstract class OverrideImplementMembersHandler : LanguageCodeInsightActionHandler { +abstract class OverrideImplementMembersHandler : LanguageCodeInsightActionHandler { - public fun collectMembersToGenerate(classOrObject: KtClassOrObject): Collection { + fun collectMembersToGenerate(classOrObject: KtClassOrObject): Collection { val descriptor = classOrObject.resolveToDescriptor() as? ClassDescriptor ?: return emptySet() return collectMembersToGenerate(descriptor, classOrObject.project) } @@ -62,7 +62,7 @@ public abstract class OverrideImplementMembersHandler : LanguageCodeInsightActio protected abstract fun getNoMembersFoundHint(): String - public fun invoke(project: Project, editor: Editor, file: PsiFile, implementAll: Boolean) { + fun invoke(project: Project, editor: Editor, file: PsiFile, implementAll: Boolean) { val elementAtCaret = file.findElementAt(editor.caretModel.offset) val classOrObject = elementAtCaret?.getNonStrictParentOfType()!! @@ -93,7 +93,7 @@ public abstract class OverrideImplementMembersHandler : LanguageCodeInsightActio override fun startInWriteAction(): Boolean = false companion object { - public fun generateMembers(editor: Editor?, classOrObject: KtClassOrObject, selectedElements: Collection) { + fun generateMembers(editor: Editor?, classOrObject: KtClassOrObject, selectedElements: Collection) { val project = classOrObject.project insertMembersAfter(editor, classOrObject, selectedElements.map { it.generateMember(project) }) } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMemberChooserObject.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMemberChooserObject.kt index 44d2d9b741a..e564a962180 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMemberChooserObject.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMemberChooserObject.kt @@ -143,7 +143,7 @@ private fun generateFunction(project: Project, descriptor: FunctionDescriptor, b return KtPsiFactory(project).createFunction(OVERRIDE_RENDERER.render(newDescriptor) + body) } -public fun generateUnsupportedOrSuperCall(descriptor: CallableMemberDescriptor, bodyType: OverrideMemberChooserObject.BodyType): String { +fun generateUnsupportedOrSuperCall(descriptor: CallableMemberDescriptor, bodyType: OverrideMemberChooserObject.BodyType): String { if (bodyType == OverrideMemberChooserObject.BodyType.EMPTY) { return "throw UnsupportedOperationException()" } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt index fd308cf508e..1802acaea7d 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import java.util.* -public class OverrideMembersHandler(private val preferConstructorParameters: Boolean = false) : OverrideImplementMembersHandler() { +class OverrideMembersHandler(private val preferConstructorParameters: Boolean = false) : OverrideImplementMembersHandler() { override fun collectMembersToGenerate(descriptor: ClassDescriptor, project: Project): Collection { val result = ArrayList() for (member in descriptor.unsubstitutedMemberScope.getContributedDescriptors()) { diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/packageUtils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/packageUtils.kt index cd5531ee625..ff6bda37c11 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/packageUtils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/packageUtils.kt @@ -23,11 +23,11 @@ import com.intellij.psi.PsiPackage import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile -public fun PsiDirectory.getPackage(): PsiPackage? = JavaDirectoryService.getInstance()!!.getPackage(this) +fun PsiDirectory.getPackage(): PsiPackage? = JavaDirectoryService.getInstance()!!.getPackage(this) -public fun PsiFile.getFqNameByDirectory(): FqName { - val qualifiedNameByDirectory = getParent()?.getPackage()?.getQualifiedName() +fun PsiFile.getFqNameByDirectory(): FqName { + val qualifiedNameByDirectory = parent?.getPackage()?.qualifiedName return qualifiedNameByDirectory?.let { FqName(it) } ?: FqName.ROOT } -public fun KtFile.packageMatchesDirectory(): Boolean = getPackageFqName() == getFqNameByDirectory() \ No newline at end of file +fun KtFile.packageMatchesDirectory(): Boolean = packageFqName == getFqNameByDirectory() \ No newline at end of file diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiFilters.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiFilters.kt index 5497eb5fbc1..0996623d4a1 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiFilters.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiFilters.kt @@ -20,17 +20,17 @@ import com.intellij.psi.filters.position.PositionElementFilter import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil -public class FirstChildInParentFilter(val level: Int = 1) : PositionElementFilter() { +class FirstChildInParentFilter(val level: Int = 1) : PositionElementFilter() { override fun isAcceptable(element: Any?, context: PsiElement?): Boolean { if (element !is PsiElement) return false var parent: PsiElement? = element for (i in 1..level) { if (parent == null) break - parent = parent.getContext() + parent = parent.context } - return (parent != null) && PsiTreeUtil.isAncestor(parent.getFirstChild(), element, true) + return (parent != null) && PsiTreeUtil.isAncestor(parent.firstChild, element, true) } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiModificationUtils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiModificationUtils.kt index ab369ebfa0c..ef9c42ac150 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiModificationUtils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/psiModificationUtils.kt @@ -33,34 +33,33 @@ import org.jetbrains.kotlin.resolve.OverridingUtil import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses @Suppress("UNCHECKED_CAST") -public inline fun PsiElement.replaced(newElement: T): T { +inline fun PsiElement.replaced(newElement: T): T { val result = replace(newElement) return if (result is T) result else - (result as KtParenthesizedExpression).getExpression() as T + (result as KtParenthesizedExpression).expression as T } -@Suppress("UNCHECKED_CAST") -public fun T.copied(): T = copy() as T +@Suppress("UNCHECKED_CAST") fun T.copied(): T = copy() as T -public fun KtLambdaArgument.moveInsideParentheses(bindingContext: BindingContext): KtCallExpression { +fun KtLambdaArgument.moveInsideParentheses(bindingContext: BindingContext): KtCallExpression { return moveInsideParenthesesAndReplaceWith(this.getArgumentExpression(), bindingContext) } -public fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith( +fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith( replacement: KtExpression, bindingContext: BindingContext ): KtCallExpression = moveInsideParenthesesAndReplaceWith(replacement, getLambdaArgumentName(bindingContext)) -public fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith( +fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith( replacement: KtExpression, functionLiteralArgumentName: Name? ): KtCallExpression { - val oldCallExpression = getParent() as KtCallExpression + val oldCallExpression = parent as KtCallExpression val newCallExpression = oldCallExpression.copy() as KtCallExpression - val psiFactory = KtPsiFactory(getProject()) + val psiFactory = KtPsiFactory(project) val argument = if (newCallExpression.getValueArgumentsInParentheses().any { it.isNamed() }) { psiFactory.createArgument(replacement, functionLiteralArgumentName) } @@ -68,13 +67,13 @@ public fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith( psiFactory.createArgument(replacement) } - val functionLiteralArgument = newCallExpression.getLambdaArguments().firstOrNull()!! - val valueArgumentList = newCallExpression.getValueArgumentList() ?: psiFactory.createCallArguments("()") + val functionLiteralArgument = newCallExpression.lambdaArguments.firstOrNull()!! + val valueArgumentList = newCallExpression.valueArgumentList ?: psiFactory.createCallArguments("()") valueArgumentList.addArgument(argument) - (functionLiteralArgument.getPrevSibling() as? PsiWhiteSpace)?.delete() - if (newCallExpression.getValueArgumentList() != null) { + (functionLiteralArgument.prevSibling as? PsiWhiteSpace)?.delete() + if (newCallExpression.valueArgumentList != null) { functionLiteralArgument.delete() } else { @@ -83,17 +82,17 @@ public fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith( return oldCallExpression.replace(newCallExpression) as KtCallExpression } -public fun KtCallExpression.moveFunctionLiteralOutsideParentheses() { - assert(getLambdaArguments().isEmpty()) - val argumentList = getValueArgumentList()!! - val argument = argumentList.getArguments().last() +fun KtCallExpression.moveFunctionLiteralOutsideParentheses() { + assert(lambdaArguments.isEmpty()) + val argumentList = valueArgumentList!! + val argument = argumentList.arguments.last() val expression = argument.getArgumentExpression()!! assert(expression.unpackFunctionLiteral() != null) val dummyCall = KtPsiFactory(this).createExpressionByPattern("foo()$0:'{}'", expression) as KtCallExpression - val functionLiteralArgument = dummyCall.getLambdaArguments().single() + val functionLiteralArgument = dummyCall.lambdaArguments.single() this.add(functionLiteralArgument) - if (argumentList.getArguments().size > 1) { + if (argumentList.arguments.size > 1) { argumentList.removeArgument(argument) } else { @@ -101,15 +100,15 @@ public fun KtCallExpression.moveFunctionLiteralOutsideParentheses() { } } -public fun KtBlockExpression.appendElement(element: KtElement, addNewLine: Boolean = false): KtElement { - val rBrace = getRBrace() +fun KtBlockExpression.appendElement(element: KtElement, addNewLine: Boolean = false): KtElement { + val rBrace = rBrace val newLine = KtPsiFactory(this).createNewLine() val anchor = if (rBrace == null) { - val lastChild = getLastChild() + val lastChild = lastChild if (lastChild !is PsiWhiteSpace) addAfter(newLine, lastChild)!! else lastChild } else { - rBrace.getPrevSibling()!! + rBrace.prevSibling!! } val addedElement = addAfter(element, anchor)!! as KtElement if (addNewLine) { @@ -119,8 +118,8 @@ public fun KtBlockExpression.appendElement(element: KtElement, addNewLine: Boole } //TODO: git rid of this method -public fun PsiElement.deleteElementAndCleanParent() { - val parent = getParent() +fun PsiElement.deleteElementAndCleanParent() { + val parent = parent deleteElementWithDelimiters(this) deleteChildlessElement(parent, this.javaClass) @@ -140,32 +139,32 @@ private fun deleteElementWithDelimiters(element: PsiElement) { val from: PsiElement val to: PsiElement if (paramBefore != null) { - from = paramBefore.getNextSibling() + from = paramBefore.nextSibling to = element } else { val paramAfter = PsiTreeUtil.getNextSiblingOfType(element, element.javaClass) from = element - to = if (paramAfter != null) paramAfter.getPrevSibling() else element + to = if (paramAfter != null) paramAfter.prevSibling else element } - val parent = element.getParent() + val parent = element.parent parent.deleteChildRange(from, to) } -public fun PsiElement.deleteSingle() { - CodeEditUtil.removeChild(getParent()?.getNode() ?: return, getNode() ?: return) +fun PsiElement.deleteSingle() { + CodeEditUtil.removeChild(parent?.node ?: return, node ?: return) } -public fun KtClass.getOrCreateCompanionObject() : KtObjectDeclaration { +fun KtClass.getOrCreateCompanionObject() : KtObjectDeclaration { getCompanionObjects().firstOrNull()?.let { return it } return addDeclaration(KtPsiFactory(this).createCompanionObject()) as KtObjectDeclaration } //TODO: code style option whether to insert redundant 'public' keyword or not -public fun KtDeclaration.setVisibility(visibilityModifier: KtModifierKeywordToken) { +fun KtDeclaration.setVisibility(visibilityModifier: KtModifierKeywordToken) { val defaultVisibilityKeyword = implicitVisibility() if (visibilityModifier == defaultVisibilityKeyword) { diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/DescriptorMemberChooserObject.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/DescriptorMemberChooserObject.kt index ba8c4b98338..e027491df1d 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/DescriptorMemberChooserObject.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/DescriptorMemberChooserObject.kt @@ -37,9 +37,9 @@ import org.jetbrains.kotlin.renderer.render import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import javax.swing.Icon -public open class DescriptorMemberChooserObject( +open class DescriptorMemberChooserObject( psiElement: PsiElement, - public open val descriptor: DeclarationDescriptor + open val descriptor: DeclarationDescriptor ) : PsiElementMemberChooserObject(psiElement, DescriptorMemberChooserObject.getText(descriptor), DescriptorMemberChooserObject.getIcon(psiElement, descriptor)), ClassMemberWithElement { override fun getParentNodeDelegate(): MemberChooserObject { @@ -73,14 +73,14 @@ public open class DescriptorMemberChooserObject( nameShortness = NameShortness.SHORT } - public fun getText(descriptor: DeclarationDescriptor): String { + fun getText(descriptor: DeclarationDescriptor): String { return if (descriptor is ClassDescriptor) descriptor.fqNameUnsafe.render() else MEMBER_RENDERER.render(descriptor) } - public fun getIcon(declaration: PsiElement?, descriptor: DeclarationDescriptor): Icon { + fun getIcon(declaration: PsiElement?, descriptor: DeclarationDescriptor): Icon { if (declaration != null && declaration.isValid) { val isClass = declaration is PsiClass || declaration is KtClass val flags = if (isClass) 0 else Iconable.ICON_FLAG_VISIBILITY diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt index 67c73cf0b77..2d06cf18557 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt @@ -16,10 +16,10 @@ package org.jetbrains.kotlin.config -public class CompilerSettings { - public var additionalArguments: String = DEFAULT_ADDITIONAL_ARGUMENTS - public var copyJsLibraryFiles: Boolean = true - public var outputDirectoryForJsLibraryFiles: String = DEFAULT_OUTPUT_DIRECTORY +class CompilerSettings { + var additionalArguments: String = DEFAULT_ADDITIONAL_ARGUMENTS + var copyJsLibraryFiles: Boolean = true + var outputDirectoryForJsLibraryFiles: String = DEFAULT_OUTPUT_DIRECTORY companion object { private val DEFAULT_ADDITIONAL_ARGUMENTS = "-version" diff --git a/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/KotlinShortenFQNamesProcessor.kt b/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/KotlinShortenFQNamesProcessor.kt index fee47acbe58..525ae0f981f 100644 --- a/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/KotlinShortenFQNamesProcessor.kt +++ b/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/KotlinShortenFQNamesProcessor.kt @@ -28,14 +28,14 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences import com.intellij.psi.util.PsiUtilBase import org.jetbrains.kotlin.psi.KtFile -public class KotlinShortenFQNamesProcessor : TemplateOptionalProcessor { +class KotlinShortenFQNamesProcessor : TemplateOptionalProcessor { override fun processText(project: Project, template: Template, document: Document, templateRange: RangeMarker, editor: Editor) { - if (!template.isToShortenLongNames()) return + if (!template.isToShortenLongNames) return PsiDocumentManager.getInstance(project).commitDocument(document) val file = PsiUtilBase.getPsiFileInEditor(editor, project) as? KtFile ?: return - ShortenReferences.DEFAULT.process(file, templateRange.getStartOffset(), templateRange.getEndOffset()) + ShortenReferences.DEFAULT.process(file, templateRange.startOffset, templateRange.endOffset) PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document) } @@ -44,7 +44,7 @@ public class KotlinShortenFQNamesProcessor : TemplateOptionalProcessor { return CodeInsightBundle.message("dialog.edit.template.checkbox.shorten.fq.names")!! } - override fun isEnabled(template: Template) = template.isToShortenLongNames() + override fun isEnabled(template: Template) = template.isToShortenLongNames override fun setEnabled(template: Template, value: Boolean) { } diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt index 379e847364d..4e57dde7d13 100644 --- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt +++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt @@ -21,25 +21,25 @@ import com.intellij.testFramework.UsefulTestCase import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import java.io.File -public class LiveTemplatesContextTest : KotlinLightCodeInsightFixtureTestCase() { +class LiveTemplatesContextTest : KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath(): String = File(TEST_DATA_BASE_PATH, "/context").path + File.separator - public fun testInDocComment() { + fun testInDocComment() { myFixture.configureByFile(getTestName(false) + ".kt") assertInContexts( KotlinTemplateContextType.Generic::class.java, KotlinTemplateContextType.Comment::class.java) } - public fun testTopLevel() { + fun testTopLevel() { myFixture.configureByFile(getTestName(false) + ".kt") assertInContexts( KotlinTemplateContextType.Generic::class.java, KotlinTemplateContextType.TopLevel::class.java) } - public fun testInExpression() { + fun testInExpression() { myFixture.configureByFile(getTestName(false) + ".kt") assertInContexts( KotlinTemplateContextType.Generic::class.java, @@ -47,8 +47,8 @@ public class LiveTemplatesContextTest : KotlinLightCodeInsightFixtureTestCase() } private fun assertInContexts(vararg expectedContexts: Class) { - val allContexts = TemplateContextType.EP_NAME.getExtensions().filter { it is KotlinTemplateContextType } - val enabledContexts = allContexts.filter { it.isInContext(myFixture.getFile(), myFixture.getCaretOffset()) }.map { it.javaClass } + val allContexts = TemplateContextType.EP_NAME.extensions.filter { it is KotlinTemplateContextType } + val enabledContexts = allContexts.filter { it.isInContext(myFixture.file, myFixture.caretOffset) }.map { it.javaClass } UsefulTestCase.assertSameElements(enabledContexts, *expectedContexts) } } diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt index 99b3a1e0ff2..11c6be9de1f 100644 --- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt +++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt @@ -37,7 +37,7 @@ import java.util.* class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() { override fun setUp() { super.setUp() - myFixture.testDataPath = File(TEST_DATA_BASE_PATH).getPath() + File.separator + myFixture.testDataPath = File(TEST_DATA_BASE_PATH).path + File.separator (TemplateManager.getInstance(project) as TemplateManagerImpl).setTemplateTesting(true) } diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/CommandExecutor.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/CommandExecutor.kt index 8eb2e07b1ef..dbf34a67f86 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/CommandExecutor.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/CommandExecutor.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.console.actions.logError private val XML_PREAMBLE = "" -public class CommandExecutor(private val runner: KotlinConsoleRunner) { +class CommandExecutor(private val runner: KotlinConsoleRunner) { private val commandHistory = runner.commandHistory private val historyUpdater = HistoryUpdater(runner) diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt index ad245ebe23e..afc70b10a98 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt @@ -24,7 +24,7 @@ import com.intellij.openapi.compiler.CompilerManager import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project -public class ConsoleCompilerHelper( +class ConsoleCompilerHelper( private val project: Project, private val module: Module, private val executor: Executor, diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryUpdater.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryUpdater.kt index c319dd29a30..a8c933dafe2 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryUpdater.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryUpdater.kt @@ -25,7 +25,7 @@ import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.console.gutter.ConsoleIndicatorRenderer import org.jetbrains.kotlin.console.gutter.ReplIcons -public class HistoryUpdater(private val runner: KotlinConsoleRunner) { +class HistoryUpdater(private val runner: KotlinConsoleRunner) { private val consoleView: LanguageConsoleImpl by lazy { runner.consoleView as LanguageConsoleImpl } fun printNewCommandInHistory(trimmedCommandText: String): TextRange { diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt index 06eb535492f..154626df875 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt @@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap private val REPL_TITLE = "Kotlin REPL" -public class KotlinConsoleKeeper(val project: Project) { +class KotlinConsoleKeeper(val project: Project) { private val consoleMap: MutableMap = ConcurrentHashMap() fun getConsoleByVirtualFile(virtualFile: VirtualFile) = consoleMap[virtualFile] diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleRunner.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleRunner.kt index 60a4bad33a0..2b1649fc3f7 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleRunner.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleRunner.kt @@ -59,7 +59,7 @@ import kotlin.properties.Delegates private val KOTLIN_SHELL_EXECUTE_ACTION_ID = "KotlinShellExecute" -public class KotlinConsoleRunner( +class KotlinConsoleRunner( val module: Module, private val cmdLine: GeneralCommandLine, internal val previousCompilationFailed: Boolean, diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplColors.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplColors.kt index baa72ae6124..38183c7dbb6 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplColors.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplColors.kt @@ -23,22 +23,22 @@ import com.intellij.ui.Gray import com.intellij.ui.JBColor import java.awt.Font -public object ReplColors { - public val HISTORY_GUTTER_COLOR: JBColor = JBColor(Gray.xF2, Gray.x41) - public val EDITOR_GUTTER_COLOR: JBColor = JBColor(Gray.xCF, Gray.x31) - public val PLACEHOLDER_COLOR: JBColor = JBColor.LIGHT_GRAY +object ReplColors { + val HISTORY_GUTTER_COLOR: JBColor = JBColor(Gray.xF2, Gray.x41) + val EDITOR_GUTTER_COLOR: JBColor = JBColor(Gray.xCF, Gray.x31) + val PLACEHOLDER_COLOR: JBColor = JBColor.LIGHT_GRAY - public val WARNING_INFO_CONTENT_TYPE: ConsoleViewContentType = + val WARNING_INFO_CONTENT_TYPE: ConsoleViewContentType = ConsoleViewContentType( "KOTLIN_CONSOLE_WARNING_INFO", TextAttributes().apply { fontType = Font.ITALIC; foregroundColor = JBColor.RED } ) - public val INITIAL_PROMPT_CONTENT_TYPE: ConsoleViewContentType = + val INITIAL_PROMPT_CONTENT_TYPE: ConsoleViewContentType = ConsoleViewContentType( "KOTLIN_CONSOLE_INITIAL_PROMPT", TextAttributes().apply { fontType = Font.BOLD } ) - public val USER_OUTPUT_CONTENT_TYPE: ConsoleViewContentType = + val USER_OUTPUT_CONTENT_TYPE: ConsoleViewContentType = ConsoleViewContentType( "KOTLIN_CONSOLE_USER_OUTPUT", TextAttributes().apply { fontType = Font.ITALIC; foregroundColor = Colors.DARK_GREEN } diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputHandler.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputHandler.kt index 47f0867b917..96b5d659c01 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputHandler.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputHandler.kt @@ -30,8 +30,8 @@ import javax.xml.parsers.DocumentBuilderFactory private val XML_PREFIX = " = arrayOf("#n", "#diez") -public val SOURCE_CHARS: Array = arrayOf("\n", "#") +val XML_REPLACEMENTS: Array = arrayOf("#n", "#diez") +val SOURCE_CHARS: Array = arrayOf("\n", "#") data class SeverityDetails(val severity: Severity, val description: String, val range: TextRange) diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt index 44efc636c51..582196395ca 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.console.gutter.ConsoleIndicatorRenderer import org.jetbrains.kotlin.console.gutter.ReplIcons import org.jetbrains.kotlin.diagnostics.Severity -public class ReplOutputProcessor( +class ReplOutputProcessor( private val runner: KotlinConsoleRunner ) { private val project = runner.project diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/ConsoleModuleDialog.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/ConsoleModuleDialog.kt index bf054e10943..0a7f626503e 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/ConsoleModuleDialog.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/ConsoleModuleDialog.kt @@ -24,10 +24,10 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.ui.popup.JBPopupFactory import org.jetbrains.kotlin.console.KotlinConsoleKeeper -public class ConsoleModuleDialog(private val project: Project) { +class ConsoleModuleDialog(private val project: Project) { private val TITLE = "Choose context module..." - public fun showIfNeeded(dataContext: DataContext) { + fun showIfNeeded(dataContext: DataContext) { val module = getModule(dataContext) if (module != null) return runConsole(module) diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt index c4ecc056d29..c08da35ba83 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt @@ -36,7 +36,7 @@ fun errorNotification(project: Project?, message: String) { fun logError(cl: Class<*>, message: String) = with(Logger.getInstance(cl)) { error(message) } -public class RunKotlinConsoleAction : AnAction() { +class RunKotlinConsoleAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return errorNotification(null, "Project not found") @@ -44,7 +44,7 @@ public class RunKotlinConsoleAction : AnAction() { } } -public class KtExecuteCommandAction(private val consoleFile: VirtualFile) : AnAction() { +class KtExecuteCommandAction(private val consoleFile: VirtualFile) : AnAction() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return errorNotification(null, "Cannot find project") val ktConsole = KotlinConsoleKeeper.getInstance(project).getConsoleByVirtualFile(consoleFile) ?: return @@ -53,7 +53,7 @@ public class KtExecuteCommandAction(private val consoleFile: VirtualFile) : AnAc } } -public class BuildAndRestartConsoleAction( +class BuildAndRestartConsoleAction( private val runner: KotlinConsoleRunner ) : AnAction("Build and restart", "Build module '${runner.module.name}' and restart", AllIcons.Actions.Restart) { diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleErrorRenderer.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleErrorRenderer.kt index faf0f14d69e..7728e14a8bc 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleErrorRenderer.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleErrorRenderer.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer import org.jetbrains.kotlin.console.SeverityDetails import org.jetbrains.kotlin.diagnostics.Severity -public class ConsoleErrorRenderer(private val messages: List) : GutterIconRenderer() { +class ConsoleErrorRenderer(private val messages: List) : GutterIconRenderer() { private fun msgType(severity: Severity) = when (severity) { Severity.ERROR -> "Error:" Severity.WARNING -> "Warning:" diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleGutterContentProvider.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleGutterContentProvider.kt index 165c910c81a..0e8ddf9a868 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleGutterContentProvider.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleGutterContentProvider.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.console.gutter import com.intellij.execution.console.BasicGutterContentProvider import com.intellij.openapi.editor.Editor -public class ConsoleGutterContentProvider : BasicGutterContentProvider() { +class ConsoleGutterContentProvider : BasicGutterContentProvider() { /** * This method overriding is needed to prevent [BasicGutterContentProvider] from adding some strange unicode * symbols of zero width and to ease range highlighting. diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleIndicatorRenderer.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleIndicatorRenderer.kt index fe7d616c55e..e3189ff6841 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleIndicatorRenderer.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ConsoleIndicatorRenderer.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.console.gutter import com.intellij.openapi.editor.markup.GutterIconRenderer -public class ConsoleIndicatorRenderer(iconWithTooltip: IconWithTooltip) : GutterIconRenderer() { +class ConsoleIndicatorRenderer(iconWithTooltip: IconWithTooltip) : GutterIconRenderer() { private val icon = iconWithTooltip.icon private val tooltip = iconWithTooltip.tooltip diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt index dc61a5715da..3ed8c4d27a4 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt @@ -20,19 +20,19 @@ import com.intellij.icons.AllIcons import org.jetbrains.kotlin.idea.KotlinIcons import javax.swing.Icon -public data class IconWithTooltip(val icon: Icon, val tooltip: String?) +data class IconWithTooltip(val icon: Icon, val tooltip: String?) -public object ReplIcons { - public val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Ide.Warning_notifications, null) - public val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.MessageHistory, "History of executed commands") - public val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here") - public val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...") - public val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.General.Run, "Executed command") - public val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Icons.Ide.SpeedSearchPrompt, "Input line") +object ReplIcons { + val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Ide.Warning_notifications, null) + val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.MessageHistory, "History of executed commands") + val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here") + val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...") + val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.General.Run, "Executed command") + val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Icons.Ide.SpeedSearchPrompt, "Input line") // command result icons - public val SYSTEM_HELP: IconWithTooltip = IconWithTooltip(AllIcons.Actions.Menu_help, "System help") - public val RESULT: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.Equal, "Result") - public val COMPILER_ERROR: Icon = AllIcons.General.Error - public val RUNTIME_EXCEPTION: IconWithTooltip = IconWithTooltip(AllIcons.General.BalloonWarning, "Runtime exception") + val SYSTEM_HELP: IconWithTooltip = IconWithTooltip(AllIcons.Actions.Menu_help, "System help") + val RESULT: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.Equal, "Result") + val COMPILER_ERROR: Icon = AllIcons.General.Error + val RUNTIME_EXCEPTION: IconWithTooltip = IconWithTooltip(AllIcons.General.BalloonWarning, "Runtime exception") } \ No newline at end of file diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/AstAccessControl.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/AstAccessControl.kt index 45212badd74..44b5b81021f 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/AstAccessControl.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/AstAccessControl.kt @@ -27,8 +27,8 @@ import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.test.InTextDirectivesUtils import kotlin.test.fail -public object AstAccessControl { - public val ALLOW_AST_ACCESS_DIRECTIVE: String = "ALLOW_AST_ACCESS" +object AstAccessControl { + val ALLOW_AST_ACCESS_DIRECTIVE: String = "ALLOW_AST_ACCESS" // Please provide at least one test that fails ast switch check (shouldFail should be true for at least one test) // This kind of inconvenience is justified by the fact that the check can be invalidated by slight misconfiguration of the test @@ -56,7 +56,7 @@ public object AstAccessControl { val manager = (PsiManager.getInstance(project) as PsiManagerImpl) val filter = VirtualFileFilter { file -> - if (file!!.getFileType() != KotlinFileType.INSTANCE || file in allowedFiles) { + if (file!!.fileType != KotlinFileType.INSTANCE || file in allowedFiles) { false } else { diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt index 748c53a5e55..55c83610956 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt @@ -25,13 +25,13 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.InTextDirectivesUtils -public object DirectiveBasedActionUtils { - public fun checkForUnexpectedErrors(file: KtFile) { - if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// DISABLE-ERRORS").isNotEmpty()) { +object DirectiveBasedActionUtils { + fun checkForUnexpectedErrors(file: KtFile) { + if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// DISABLE-ERRORS").isNotEmpty()) { return } - val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ERROR:").sorted() + val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ERROR:").sorted() val actualErrors = file.analyzeFully().getDiagnostics() .filter { it.getSeverity() == Severity.ERROR } @@ -43,13 +43,13 @@ public object DirectiveBasedActionUtils { expectedErrors) } - public fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection) { - val expectedActions = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:").sorted() + fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection) { + val expectedActions = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ACTION:").sorted() UsefulTestCase.assertEmpty("Irrelevant actions should not be specified in ACTION directive for they are not checked anyway", expectedActions.filter { isIrrelevantAction(it) }) - val actualActions = availableActions.map { it.getText() }.sorted() + val actualActions = availableActions.map { it.text }.sorted() UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position. Use // ACTION: directive", filterOutIrrelevantActions(actualActions), diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt index b446a750583..857cbb2a8ca 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt @@ -40,20 +40,20 @@ import java.io.File import java.io.IOException import java.util.* -public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFixtureTestCase() { +abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFixtureTestCase() { private var kotlinInternalModeOriginalValue = false private val exceptions = ArrayList() override fun setUp() { super.setUp() - (StartupManager.getInstance(getProject()) as StartupManagerImpl).runPostStartupActivities() + (StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities() VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory()) kotlinInternalModeOriginalValue = KotlinInternalMode.enabled KotlinInternalMode.enabled = true - getProject().getComponent(EditorTracker::class.java)?.projectOpened() + project.getComponent(EditorTracker::class.java)?.projectOpened() invalidateLibraryCache(project) @@ -71,7 +71,7 @@ public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFi KotlinInternalMode.enabled = kotlinInternalModeOriginalValue VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) - unInvalidateBuiltinsAndStdLib(getProject()) { + unInvalidateBuiltinsAndStdLib(project) { super.tearDown() } @@ -100,7 +100,7 @@ public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFi protected fun getProjectDescriptorFromFileDirective(): LightProjectDescriptor { if (!isAllFilesPresentInTest()) { try { - val fileText = FileUtil.loadFile(File(getTestDataPath(), fileName()), true) + val fileText = FileUtil.loadFile(File(testDataPath, fileName()), true) val withLibraryDirective = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "WITH_LIBRARY:") if (!withLibraryDirective.isEmpty()) { @@ -130,14 +130,14 @@ public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFi = getTestName(false) + ".kt" protected fun performNotWriteEditorAction(actionId: String): Boolean { - val dataContext = (myFixture.getEditor() as EditorEx).getDataContext() + val dataContext = (myFixture.editor as EditorEx).dataContext val managerEx = ActionManagerEx.getInstanceEx() val action = managerEx.getAction(actionId) val event = AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, Presentation(), managerEx, 0) action.update(event) - if (!event.getPresentation().isEnabled()) { + if (!event.presentation.isEnabled) { return false } diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt index 568bca23ade..d33cc5c8afa 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt @@ -23,12 +23,12 @@ import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCa import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode import org.jetbrains.kotlin.test.KotlinTestUtils -public abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeInsightFixtureTestCase() { +abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeInsightFixtureTestCase() { private var kotlinInternalModeOriginalValue: Boolean = false override fun setUp() { super.setUp() - (StartupManager.getInstance(getProject()) as StartupManagerImpl).runPostStartupActivities() + (StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities() VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory()) invalidateLibraryCache(project) @@ -40,7 +40,7 @@ public abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatfo KotlinInternalMode.enabled = kotlinInternalModeOriginalValue VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) - unInvalidateBuiltinsAndStdLib(getProject()) { + unInvalidateBuiltinsAndStdLib(project) { super.tearDown() } } diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt index 37e0c5f8a4b..2dbfaef9bba 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt @@ -23,7 +23,7 @@ import com.intellij.refactoring.MultiFileTestCase import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.test.KotlinTestUtils -public abstract class KotlinMultiFileTestCase : MultiFileTestCase() { +abstract class KotlinMultiFileTestCase : MultiFileTestCase() { protected fun extractCaretOffset(doc: Document): Int { val offset = runWriteAction { val text = StringBuilder(doc.getText()) diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinStdJSProjectDescriptor.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinStdJSProjectDescriptor.kt index 4ee61a21baa..9230edf1945 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinStdJSProjectDescriptor.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinStdJSProjectDescriptor.kt @@ -18,9 +18,9 @@ package org.jetbrains.kotlin.idea.test import com.intellij.testFramework.LightProjectDescriptor -public open class KotlinStdJSProjectDescriptor : KotlinLightProjectDescriptor() { +open class KotlinStdJSProjectDescriptor : KotlinLightProjectDescriptor() { companion object { - public val instance: KotlinStdJSProjectDescriptor + val instance: KotlinStdJSProjectDescriptor = Class.forName("org.jetbrains.kotlin.test.KotlinStdJSProjectDescriptorImpl").newInstance() as KotlinStdJSProjectDescriptor } } \ No newline at end of file diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/testUtils.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/testUtils.kt index 52d70037a7a..c863d3132c2 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/testUtils.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/testUtils.kt @@ -37,19 +37,19 @@ import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile import org.jetbrains.kotlin.psi.KtFile import java.util.* -public enum class ModuleKind { +enum class ModuleKind { KOTLIN_JVM_WITH_STDLIB_SOURCES, KOTLIN_JAVASCRIPT } -public fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) { +fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) { val module = this updateModel(module, object : Consumer { override fun consume(model: ModifiableRootModel) { - if (descriptor.getSdk() != null) { - model.setSdk(descriptor.getSdk()) + if (descriptor.sdk != null) { + model.sdk = descriptor.sdk } - val entries = model.getContentEntries() + val entries = model.contentEntries if (entries.isEmpty()) { descriptor.configureModule(module, model) } @@ -60,7 +60,7 @@ public fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) { }) } -public fun Module.configureAs(kind: ModuleKind) { +fun Module.configureAs(kind: ModuleKind) { when(kind) { ModuleKind.KOTLIN_JVM_WITH_STDLIB_SOURCES -> this.configureAs(ProjectDescriptorWithStdlibSources.INSTANCE) @@ -72,18 +72,18 @@ public fun Module.configureAs(kind: ModuleKind) { } } -public fun KtFile.dumpTextWithErrors(): String { +fun KtFile.dumpTextWithErrors(): String { val diagnostics = analyzeFullyAndGetResult().bindingContext.getDiagnostics() val errors = diagnostics.filter { it.getSeverity() == Severity.ERROR } - if (errors.isEmpty()) return getText() + if (errors.isEmpty()) return text val header = errors.map { "// ERROR: " + DefaultErrorMessages.render(it).replace('\n', ' ') }.joinToString("\n", postfix = "\n") - return header + getText() + return header + text } -public fun closeAndDeleteProject(): Unit = +fun closeAndDeleteProject(): Unit = ApplicationManager.getApplication().runWriteAction() { LightPlatformTestCase.closeAndDeleteProject() } -public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWithException) { +fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWithException) { val stdLibViewProviders = HashSet() val vFileToViewProviderMap = ((PsiManager.getInstance(project) as PsiManagerEx).fileManager as FileManagerImpl).vFileToViewProviderMap for ((file, viewProvider) in vFileToViewProviderMap) { @@ -97,7 +97,7 @@ public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWit // Base tearDown() invalidates builtins and std-lib files. Restore them with brute force. fun unInvalidateFile(file: PsiFileImpl) { val field = PsiFileImpl::class.java.getDeclaredField("myInvalidated")!! - field.setAccessible(true) + field.isAccessible = true field.set(file, false) } @@ -109,10 +109,10 @@ public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWit private val VirtualFile.isStdLibFile: Boolean get() = presentableUrl.contains("kotlin-runtime.jar") -public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) { +fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) { unInvalidateBuiltinsAndStdLib(project, RunnableWithException { runnable() }) } -public fun invalidateLibraryCache(project: Project) { +fun invalidateLibraryCache(project: Project) { LibraryModificationTracker.getInstance(project).incModificationCount() } \ No newline at end of file diff --git a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt index 4d002d6f9d2..3423edadfe5 100644 --- a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt +++ b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt @@ -37,7 +37,7 @@ fun parse(line: String, reader: OutputLineReader, messages: MutableList, lo if (colonIndex2 >= 0) { val path = lineWoSeverity.substringBeforeAndTrim(colonIndex2) val file = File(path) - if (!file.isFile() && FileUtilRt.getExtension(file.getName()) != "kt") { + if (!file.isFile && FileUtilRt.getExtension(file.name) != "kt") { return addMessage(KotlinOutputParserHelper.createMessage(logger, severity, lineWoSeverity.amendNextLinesIfNeeded(reader)), messages) } @@ -223,7 +223,7 @@ object KotlinOutputParserHelper { else Class.forName("$packagePrefix.GradleMessage\$Kind") - val messageKindConstants = messageKindClass.getEnumConstants() as Array + val messageKindConstants = messageKindClass.enumConstants as Array for (kind in messageKindConstants) { when(kind.toString()) { "ERROR" -> severityObjectMap.put("e", kind) diff --git a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt index 344c7c65577..8f475c3b7d3 100644 --- a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt +++ b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt @@ -43,12 +43,12 @@ fun getInfo( if (info != null) return info val topMostQualified = referenceExpression.getParentQualified().getParentQualified() ?: return null - val selectorCandidate = topMostQualified.getSelectorExpression() as? KtSimpleNameExpression ?: return null + val selectorCandidate = topMostQualified.selectorExpression as? KtSimpleNameExpression ?: return null return getReferredInfo(selectorCandidate, facet) } private fun KtExpression?.getParentQualified(): KtDotQualifiedExpression? { - return this?.getParent() as? KtDotQualifiedExpression + return this?.parent as? KtDotQualifiedExpression } // returns info if passed expression is 'b' in 'R.a.b' @@ -71,19 +71,19 @@ private fun getReferredInfo( //the following code is copied from // org.jetbrains.android.util.AndroidResourceUtil.getReferredResourceOrManifestField // (org.jetbrains.android.facet.AndroidFacet, com.intellij.psi.PsiReferenceExpression, java.lang.String, boolean) - val classShortName = resolvedClass.getName() + val classShortName = resolvedClass.name val fromManifest = AndroidUtils.MANIFEST_CLASS_NAME == classShortName if (!fromManifest && AndroidUtils.R_CLASS_NAME != classShortName) { return null } - val qName = resolvedClass.getQualifiedName() + val qName = resolvedClass.qualifiedName if (SdkConstants.CLASS_R == qName || AndroidPsiElementFinder.INTERNAL_R_CLASS_QNAME == qName) { return AndroidResourceUtil.MyReferredResourceFieldInfo(resClassName, resFieldName, true, false) } - val containingFile = resolvedClass.getContainingFile() ?: return null + val containingFile = resolvedClass.containingFile ?: return null val isFromCorrectFile = if (fromManifest) AndroidResourceUtil.isManifestJavaFile(facet, containingFile) @@ -103,7 +103,7 @@ private fun getReceiverAsSimpleNameExpression(exp: KtSimpleNameExpression): KtSi receiver } is KtDotQualifiedExpression -> { - receiver.getSelectorExpression() as? KtSimpleNameExpression + receiver.selectorExpression as? KtSimpleNameExpression } else -> null } diff --git a/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt b/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt index 8988de949ca..1b6a4000807 100644 --- a/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt @@ -24,16 +24,16 @@ import com.sun.jdi.request.StepRequest import org.jetbrains.kotlin.idea.debugger.KotlinPositionManager import org.jetbrains.kotlin.idea.util.application.runReadAction -public class ExtraSteppingFilter : com.intellij.debugger.engine.ExtraSteppingFilter { +class ExtraSteppingFilter : com.intellij.debugger.engine.ExtraSteppingFilter { override fun isApplicable(context: SuspendContext?): Boolean { if (context == null) { return false; } - val debugProcess = context.getDebugProcess() + val debugProcess = context.debugProcess val positionManager = KotlinPositionManager(debugProcess!!) - val location = context.getFrameProxy()!!.location() + val location = context.frameProxy!!.location() return runReadAction { shouldFilter(positionManager, location) } diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinFoldingBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinFoldingBuilder.kt index ab6e56c57c9..846d7f55dee 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinFoldingBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinFoldingBuilder.kt @@ -35,18 +35,18 @@ import org.jetbrains.kotlin.psi.psiUtil.allChildren import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware { +class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware { override fun buildLanguageFoldRegions(descriptors: MutableList, root: PsiElement, document: Document, quick: Boolean) { if (root !is KtFile) { return } - val imports = root.getImportDirectives() + val imports = root.importDirectives if (imports.size > 1) { - val importKeyword = imports.get(0).getFirstChild() + val importKeyword = imports.get(0).firstChild val startOffset = importKeyword.endOffset + 1 - val importList = root.getImportList() + val importList = root.importList if (importList != null) { val endOffset = importList.endOffset @@ -55,7 +55,7 @@ public class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware { } } - appendDescriptors(root.getNode(), document, descriptors) + appendDescriptors(root.node, document, descriptors) } private fun appendDescriptors(node: ASTNode, document: Document, descriptors: MutableList) { @@ -66,54 +66,54 @@ public class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware { } } - var child = node.getFirstChildNode() + var child = node.firstChildNode while (child != null) { appendDescriptors(child, document, descriptors) - child = child.getTreeNext() + child = child.treeNext } } private fun needFolding(node: ASTNode): Boolean { - val type = node.getElementType() - val parentType = node.getTreeParent()?.getElementType() + val type = node.elementType + val parentType = node.treeParent?.elementType return type == KtNodeTypes.FUNCTION_LITERAL || (type == KtNodeTypes.BLOCK && parentType != KtNodeTypes.FUNCTION_LITERAL) || type == KtNodeTypes.CLASS_BODY || type == KtTokens.BLOCK_COMMENT || type == KDocTokens.KDOC } private fun getRangeToFold(node: ASTNode): TextRange { - if (node.getElementType() == KtNodeTypes.FUNCTION_LITERAL) { - val psi = node.getPsi() as? KtFunctionLiteral - val lbrace = psi?.getLBrace() - val rbrace = psi?.getRBrace() + if (node.elementType == KtNodeTypes.FUNCTION_LITERAL) { + val psi = node.psi as? KtFunctionLiteral + val lbrace = psi?.lBrace + val rbrace = psi?.rBrace if (lbrace != null && rbrace != null) { return TextRange(lbrace.startOffset, rbrace.endOffset) } } - return node.getTextRange() + return node.textRange } private fun isOneLine(textRange: TextRange, document: Document) = - document.getLineNumber(textRange.getStartOffset()) == document.getLineNumber(textRange.getEndOffset()) + document.getLineNumber(textRange.startOffset) == document.getLineNumber(textRange.endOffset) override fun getLanguagePlaceholderText(node: ASTNode, range: TextRange): String = when { - node.getElementType() == KtTokens.BLOCK_COMMENT -> "/.../" - node.getElementType() == KDocTokens.KDOC -> "/**...*/" - node.getPsi() is KtImportList -> "..." + node.elementType == KtTokens.BLOCK_COMMENT -> "/.../" + node.elementType == KDocTokens.KDOC -> "/**...*/" + node.psi is KtImportList -> "..." else -> "{...}" } override fun isRegionCollapsedByDefault(node: ASTNode): Boolean { val settings = JavaCodeFoldingSettings.getInstance() - if (node.getPsi() is KtImportList) { - return settings.isCollapseImports() + if (node.psi is KtImportList) { + return settings.isCollapseImports } - val type = node.getElementType() + val type = node.elementType if (type == KtTokens.BLOCK_COMMENT || type == KDocTokens.KDOC) { - if (isFirstElementInFile(node.getPsi())) { - return settings.isCollapseFileHeader() + if (isFirstElementInFile(node.psi)) { + return settings.isCollapseFileHeader } } @@ -121,13 +121,13 @@ public class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware { } override fun isCustomFoldingRoot(node: ASTNode) - = node.getElementType() == KtNodeTypes.BLOCK || node.getElementType() == KtNodeTypes.CLASS_BODY + = node.elementType == KtNodeTypes.BLOCK || node.elementType == KtNodeTypes.CLASS_BODY private fun isFirstElementInFile(element: PsiElement): Boolean { - val parent = element.getParent() + val parent = element.parent if (parent is KtFile) { val firstNonWhiteSpace = parent.allChildren.firstOrNull { - it.getTextLength() != 0 && it !is PsiWhiteSpace + it.textLength != 0 && it !is PsiWhiteSpace } return element == firstNonWhiteSpace diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinJavaScriptMetaFileTypeFactory.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinJavaScriptMetaFileTypeFactory.kt index bd8dbeefb8a..2f42c0c7f0c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinJavaScriptMetaFileTypeFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinJavaScriptMetaFileTypeFactory.kt @@ -20,8 +20,8 @@ import com.intellij.openapi.fileTypes.FileTypeConsumer import com.intellij.openapi.fileTypes.FileTypeFactory import org.jetbrains.kotlin.idea.decompiler.js.KotlinJavaScriptMetaFileType -public class KotlinJavaScriptMetaFileTypeFactory : FileTypeFactory() { +class KotlinJavaScriptMetaFileTypeFactory : FileTypeFactory() { override fun createFileTypes(consumer: FileTypeConsumer) { - consumer.consume(KotlinJavaScriptMetaFileType, KotlinJavaScriptMetaFileType.getDefaultExtension()) + consumer.consume(KotlinJavaScriptMetaFileType, KotlinJavaScriptMetaFileType.defaultExtension) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt index b916941680b..cbe8c4d8b79 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt @@ -194,7 +194,7 @@ class KotlinPluginUpdater(val propertiesComponent: PropertiesComponent) : Dispos ProgressManager.getInstance().run(object : Task.Backgroundable(null, "Downloading plugins", true) { override fun run(indicator: ProgressIndicator) { if (pluginDownloader.prepareToInstall(indicator)) { - val pluginDescriptor = pluginDownloader.getDescriptor() + val pluginDescriptor = pluginDownloader.descriptor if (pluginDescriptor != null) { pluginDownloader.install() diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinQuickDocumentationProvider.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinQuickDocumentationProvider.kt index 5f1079cb50a..c4f2812b9cf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinQuickDocumentationProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinQuickDocumentationProvider.kt @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.utils.addToStdlib.constant -public class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() { +class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() { override fun getQuickNavigateInfo(element: PsiElement?, originalElement: PsiElement?): String? { return if (element == null) null else getText(element, originalElement, true) @@ -66,7 +66,7 @@ public class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() val descriptors = resolveKDocLink(context.getResolutionFacade(), contextDescriptor, null, StringUtil.split(link, ",")) val target = descriptors.firstOrNull() if (target is DeclarationDescriptorWithSource) { - val source = target.getSource() + val source = target.source return (source as? PsiSourceElement)?.psi } return null diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt index 41d32d9b206..b3ed86e1e75 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt @@ -26,16 +26,16 @@ import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator import org.jetbrains.kotlin.js.resolve.JsPlatform import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public abstract class ConfigureKotlinInProjectAction : AnAction() { +abstract class ConfigureKotlinInProjectAction : AnAction() { abstract fun getAbleToRunConfigurators(project: Project): Collection override fun actionPerformed(e: AnActionEvent) { - val project = CommonDataKeys.PROJECT.getData(e.getDataContext()) + val project = CommonDataKeys.PROJECT.getData(e.dataContext) if (project == null) return if (ConfigureKotlinInProjectUtils.isProjectConfigured(project)) { - Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText()!!) + Messages.showInfoMessage("All modules with kotlin files are configured", e.presentation.text!!) return } @@ -43,23 +43,23 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() { when { configurators.size == 1 -> configurators.first().configure(project) - configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText()!!) + configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.presentation.text!!) else -> { - Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText()!!) + Messages.showErrorDialog("More than one configurator is available", e.presentation.text!!) ConfigureKotlinInProjectUtils.showConfigureKotlinNotificationIfNeeded(project) } } } } -public class ConfigureKotlinJsInProjectAction: ConfigureKotlinInProjectAction() { +class ConfigureKotlinJsInProjectAction: ConfigureKotlinInProjectAction() { override fun getAbleToRunConfigurators(project: Project) = ConfigureKotlinInProjectUtils.getAbleToRunConfigurators(project).filter { - it.getTargetPlatform() == JsPlatform + it.targetPlatform == JsPlatform } } -public class ConfigureKotlinJavaInProjectAction: ConfigureKotlinInProjectAction() { +class ConfigureKotlinJavaInProjectAction: ConfigureKotlinInProjectAction() { override fun getAbleToRunConfigurators(project: Project) = ConfigureKotlinInProjectUtils.getAbleToRunConfigurators(project).filter { - it.getTargetPlatform() == JvmPlatform + it.targetPlatform == JvmPlatform } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt index e5aa11c763a..7b40c84969d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt @@ -44,14 +44,14 @@ import java.io.File import java.io.IOException import java.util.ArrayList -public class JavaToKotlinAction : AnAction() { +class JavaToKotlinAction : AnAction() { companion object { private fun uniqueKotlinFileName(javaFile: VirtualFile): String { - val ioFile = File(javaFile.getPath().replace('/', File.separatorChar)) + val ioFile = File(javaFile.path.replace('/', File.separatorChar)) var i = 0 while (true) { - val fileName = javaFile.getNameWithoutExtension() + (if (i > 0) i else "") + ".kt" + val fileName = javaFile.nameWithoutExtension + (if (i > 0) i else "") + ".kt" if (!ioFile.resolveSibling(fileName).exists()) return fileName i++ } @@ -60,7 +60,7 @@ public class JavaToKotlinAction : AnAction() { private fun saveResults(javaFiles: List, convertedTexts: List): List { val result = ArrayList() for ((psiFile, text) in javaFiles.zip(convertedTexts)) { - val virtualFile = psiFile.getVirtualFile() + val virtualFile = psiFile.virtualFile val fileName = uniqueKotlinFileName(virtualFile) try { virtualFile.rename(this, fileName) @@ -68,7 +68,7 @@ public class JavaToKotlinAction : AnAction() { result.add(virtualFile) } catch (e: IOException) { - MessagesEx.error(psiFile.getProject(), e.message).showLater() + MessagesEx.error(psiFile.project, e.message).showLater() } } return result @@ -80,7 +80,7 @@ public class JavaToKotlinAction : AnAction() { var converterResult: JavaToKotlinConverter.FilesResult? = null fun convert() { val converter = JavaToKotlinConverter(project, ConverterSettings.defaultSettings, IdeaJavaToKotlinServices) - converterResult = converter.filesToKotlin(javaFiles, J2kPostProcessor(formatCode = true), ProgressManager.getInstance().getProgressIndicator()) + converterResult = converter.filesToKotlin(javaFiles, J2kPostProcessor(formatCode = true), ProgressManager.getInstance().progressIndicator) } val title = "Convert Java to Kotlin" @@ -101,7 +101,7 @@ public class JavaToKotlinAction : AnAction() { ProgressManager.getInstance().runProcessWithProgressSynchronously( { runReadAction { - externalCodeUpdate = converterResult!!.externalCodeProcessing!!.prepareWriteOperation(ProgressManager.getInstance().getProgressIndicator()) + externalCodeUpdate = converterResult!!.externalCodeProcessing!!.prepareWriteOperation(ProgressManager.getInstance().progressIndicator) } }, title, @@ -128,18 +128,18 @@ public class JavaToKotlinAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val javaFiles = selectedJavaFiles(e).toList() - val project = CommonDataKeys.PROJECT.getData(e.getDataContext())!! + val project = CommonDataKeys.PROJECT.getData(e.dataContext)!! convertFiles(javaFiles, project) } override fun update(e: AnActionEvent) { val enabled = selectedJavaFiles(e).any() - e.getPresentation().setEnabled(enabled) + e.presentation.isEnabled = enabled } private fun selectedJavaFiles(e: AnActionEvent): Sequence { val virtualFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY) ?: return sequenceOf() - val project = e.getProject() ?: return sequenceOf() + val project = e.project ?: return sequenceOf() return allJavaFiles(virtualFiles, project) } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/KotlinAddImportAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/KotlinAddImportAction.kt index 19e1ae2ed3b..6a1d5923844 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/KotlinAddImportAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/KotlinAddImportAction.kt @@ -112,7 +112,7 @@ class KotlinAddImportAction internal constructor( if (variants.isEmpty()) return false val hintText = ShowAutoImportPass.getMessage(variants.size > 1, variants.first().hint) - HintManager.getInstance().showQuestionHint(editor, hintText, element.getTextOffset(), element.getTextRange()!!.getEndOffset(), this) + HintManager.getInstance().showQuestionHint(editor, hintText, element.textOffset, element.textRange!!.endOffset, this) return true } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/KotlinQualifiedNameProvider.kt b/idea/src/org/jetbrains/kotlin/idea/actions/KotlinQualifiedNameProvider.kt index 278f1aefeec..49e71c2f17c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/KotlinQualifiedNameProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/KotlinQualifiedNameProvider.kt @@ -27,16 +27,16 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.psi.KtClassOrObject -public class KotlinQualifiedNameProvider: QualifiedNameProvider { +class KotlinQualifiedNameProvider: QualifiedNameProvider { override fun adjustElementToCopy(element: PsiElement?) = null override fun getQualifiedName(element: PsiElement?): String? { when (element) { - is KtClassOrObject -> return element.getFqName()?.asString() + is KtClassOrObject -> return element.fqName?.asString() is KtNamedFunction, is KtProperty -> { val descriptor = (element as KtDeclaration).resolveToDescriptor() val fqNameUnsafe = DescriptorUtils.getFqName(descriptor) - if (fqNameUnsafe.isSafe()) { + if (fqNameUnsafe.isSafe) { return fqNameUnsafe.asString() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt index d7b624ac882..6ac508c9d62 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt @@ -37,27 +37,26 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.KotlinType -@Deprecated("Remove once we no longer support IDEA 14.1") -public class ShowExpressionTypeAction : AnAction() { +@Deprecated("Remove once we no longer support IDEA 14.1") class ShowExpressionTypeAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val editor = e.getData(CommonDataKeys.EDITOR) ?: return val psiFile = e.getData(CommonDataKeys.PSI_FILE) as? KtFile ?: return - val type = if (editor.getSelectionModel().hasSelection()) { - val startOffset = editor.getSelectionModel().getSelectionStart() - val endOffset = editor.getSelectionModel().getSelectionEnd() + val type = if (editor.selectionModel.hasSelection()) { + val startOffset = editor.selectionModel.selectionStart + val endOffset = editor.selectionModel.selectionEnd val expression = CodeInsightUtilCore.findElementInRange(psiFile, startOffset, endOffset, KtExpression::class.java, KotlinLanguage.INSTANCE) ?: return typeByExpression(expression) } else { - val offset = editor.getCaretModel().getOffset() + val offset = editor.caretModel.offset val token = psiFile.findElementAt(offset) ?: return val pair = token.parents .filterIsInstance() .map { it to typeByExpression(it) } .firstOrNull { it.second != null } ?: return val (expression, type) = pair - editor.getSelectionModel().setSelection(expression.startOffset, expression.endOffset) + editor.selectionModel.setSelection(expression.startOffset, expression.endOffset) type } @@ -76,7 +75,7 @@ public class ShowExpressionTypeAction : AnAction() { val editor = e.getData(CommonDataKeys.EDITOR) val psiFile = e.getData(CommonDataKeys.PSI_FILE) - e.getPresentation().setEnabled(editor != null && psiFile is KtFile) + e.presentation.isEnabled = editor != null && psiFile is KtFile } companion object { @@ -88,7 +87,7 @@ public class ShowExpressionTypeAction : AnAction() { if (expression is KtCallableDeclaration) { val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, expression] as? CallableDescriptor if (descriptor != null) { - return descriptor.getReturnType() + return descriptor.returnType } } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt index 99b5c81bcaf..cd7e79d83f7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt @@ -26,19 +26,19 @@ import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.internal.KotlinBytecodeToolWindow -public class ShowKotlinBytecodeAction(): AnAction() { +class ShowKotlinBytecodeAction(): AnAction() { val TOOLWINDOW_ID = "Kotlin Bytecode" override fun actionPerformed(e: AnActionEvent) { - val project = e.getProject() ?: return + val project = e.project ?: return val toolWindowManager = ToolWindowManager.getInstance(project) var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID) if (toolWindow == null) { toolWindow = toolWindowManager.registerToolWindow("Kotlin Bytecode", true, ToolWindowAnchor.RIGHT) - toolWindow.setIcon(KotlinIcons.SMALL_LOGO_13) + toolWindow.icon = KotlinIcons.SMALL_LOGO_13 - val contentManager = toolWindow.getContentManager() + val contentManager = toolWindow.contentManager val contentFactory = ContentFactory.SERVICE.getInstance() contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, toolWindow), "", false)) } @@ -47,6 +47,6 @@ public class ShowKotlinBytecodeAction(): AnAction() { override fun update(e: AnActionEvent) { val file = e.getData(CommonDataKeys.PSI_FILE) - e.getPresentation().setEnabled(e.getProject() != null && file?.getFileType() == KotlinFileType.INSTANCE) + e.presentation.isEnabled = e.project != null && file?.fileType == KotlinFileType.INSTANCE } } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt index d6ff5724c18..6f9709e98bd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateTestSupportActionBase.kt @@ -93,24 +93,24 @@ abstract class KotlinGenerateTestSupportActionBase( } } - public class SetUp : KotlinGenerateTestSupportActionBase(MethodKind.SET_UP) { + class SetUp : KotlinGenerateTestSupportActionBase(MethodKind.SET_UP) { override fun isApplicableTo(framework: TestFramework, targetClass: KtClassOrObject): Boolean { return framework.findSetUpMethod(targetClass.toLightClass()!!) == null } } - public class Test : KotlinGenerateTestSupportActionBase(MethodKind.TEST) { + class Test : KotlinGenerateTestSupportActionBase(MethodKind.TEST) { override fun isApplicableTo(framework: TestFramework, targetClass: KtClassOrObject) = true } - public class Data : KotlinGenerateTestSupportActionBase(MethodKind.DATA) { + class Data : KotlinGenerateTestSupportActionBase(MethodKind.DATA) { override fun isApplicableTo(framework: TestFramework, targetClass: KtClassOrObject): Boolean { if (framework !is JavaTestFramework) return false return framework.findParametersMethod(targetClass.toLightClass()) == null } } - public class TearDown : KotlinGenerateTestSupportActionBase(MethodKind.TEAR_DOWN) { + class TearDown : KotlinGenerateTestSupportActionBase(MethodKind.TEAR_DOWN) { override fun isApplicableTo(framework: TestFramework, targetClass: KtClassOrObject): Boolean { return framework.findTearDownMethod(targetClass.toLightClass()!!) == null } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt index 75ac706316a..94f0167d33c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt @@ -48,10 +48,10 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.ArrayList import javax.swing.SwingUtilities -public class CheckPartialBodyResolveAction : AnAction() { +class CheckPartialBodyResolveAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val selectedFiles = selectedKotlinFiles(e).toList() - val project = CommonDataKeys.PROJECT.getData(e.getDataContext())!! + val project = CommonDataKeys.PROJECT.getData(e.dataContext)!! ProgressManager.getInstance().runProcessWithProgressSynchronously( { @@ -64,10 +64,10 @@ public class CheckPartialBodyResolveAction : AnAction() { private fun checkResolve(files: Collection, project: Project) { //TODO: drop resolve caches if any - val progressIndicator = ProgressManager.getInstance().getProgressIndicator() + val progressIndicator = ProgressManager.getInstance().progressIndicator for ((i, file) in files.withIndex()) { - progressIndicator?.setText("Checking resolve $i of ${files.size}...") - progressIndicator?.setText2(file.getVirtualFile().getPath()) + progressIndicator?.text = "Checking resolve $i of ${files.size}..." + progressIndicator?.text2 = file.virtualFile.path val partialResolveDump = dumpResolve(file) { element, resolutionFacade -> resolutionFacade.analyze(element, BodyResolveMode.PARTIAL) @@ -77,15 +77,15 @@ public class CheckPartialBodyResolveAction : AnAction() { } if (partialResolveDump != goldDump) { SwingUtilities.invokeLater { - val title = "Difference Found in File ${file.getVirtualFile().getPath()}" + val title = "Difference Found in File ${file.virtualFile.path}" val request = SimpleDiffRequest(project, title) request.setContents(SimpleContent(goldDump), SimpleContent(partialResolveDump)) request.setContentTitles("Expected", "Partial Body Resolve") val diffBuilder = DialogBuilder(project) - val diffPanel = DiffManager.getInstance().createDiffPanel(diffBuilder.getWindow(), project, diffBuilder, null) as DiffPanelImpl - diffPanel.getOptions().setShowSourcePolicy(DiffPanelOptions.ShowSourcePolicy.DONT_SHOW) - diffBuilder.setCenterPanel(diffPanel.getComponent()) + val diffPanel = DiffManager.getInstance().createDiffPanel(diffBuilder.window, project, diffBuilder, null) as DiffPanelImpl + diffPanel.options.setShowSourcePolicy(DiffPanelOptions.ShowSourcePolicy.DONT_SHOW) + diffBuilder.setCenterPanel(diffPanel.component) diffBuilder.setDimensionServiceKey("org.jetbrains.kotlin.idea.actions.internal.CheckPartialBodyResolveAction.Diff") diffPanel.setDiffRequest(request) diffBuilder.addOkAction().setText("Close") @@ -96,7 +96,7 @@ public class CheckPartialBodyResolveAction : AnAction() { return } - progressIndicator?.setFraction((i + 1) / files.size.toDouble()) + progressIndicator?.fraction = (i + 1) / files.size.toDouble() } SwingUtilities.invokeLater { @@ -107,7 +107,7 @@ public class CheckPartialBodyResolveAction : AnAction() { private fun dumpResolve(file: KtFile, resolver: (KtElement, ResolutionFacade) -> BindingContext): String { val builder = StringBuilder() val resolutionFacade = file.getResolutionFacade() - val document = FileDocumentManager.getInstance().getDocument(file.getVirtualFile())!! + val document = FileDocumentManager.getInstance().getDocument(file.virtualFile)!! file.acceptChildren(object : KtVisitorVoid(){ override fun visitKtElement(element: KtElement) { ProgressManager.checkCanceled() @@ -124,10 +124,10 @@ public class CheckPartialBodyResolveAction : AnAction() { val bindingContext = resolver(expression, resolutionFacade) - val offset = expression.getTextOffset() + val offset = expression.textOffset val line = document.getLineNumber(offset) val column = offset - document.getLineStartOffset(line) - val exprName = if (expression is KtNameReferenceExpression) expression.getReferencedName() else expression.javaClass.getSimpleName() + val exprName = if (expression is KtNameReferenceExpression) expression.getReferencedName() else expression.javaClass.simpleName builder.append("$exprName at (${line + 1}:${column + 1})") if (expression is KtReferenceExpression) { @@ -151,18 +151,18 @@ public class CheckPartialBodyResolveAction : AnAction() { override fun update(e: AnActionEvent) { if (!KotlinInternalMode.enabled) { - e.getPresentation().setVisible(false) - e.getPresentation().setEnabled(false) + e.presentation.isVisible = false + e.presentation.isEnabled = false } else { - e.getPresentation().setVisible(true) - e.getPresentation().setEnabled(selectedKotlinFiles(e).any()) + e.presentation.isVisible = true + e.presentation.isEnabled = selectedKotlinFiles(e).any() } } private fun selectedKotlinFiles(e: AnActionEvent): Sequence { val virtualFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY) ?: return sequenceOf() - val project = CommonDataKeys.PROJECT.getData(e.getDataContext()) ?: return sequenceOf() + val project = CommonDataKeys.PROJECT.getData(e.dataContext) ?: return sequenceOf() return allKotlinFiles(virtualFiles, project) } @@ -188,7 +188,7 @@ public class CheckPartialBodyResolveAction : AnAction() { //TODO: currently copied from PartialBodyResolveFilter - not good private fun isValueNeeded(expression: KtExpression): Boolean { - val parent = expression.getParent() + val parent = expression.parent return when (parent) { is KtBlockExpression -> expression == parent.lastStatement() && isValueNeeded(parent) @@ -198,7 +198,7 @@ public class CheckPartialBodyResolveAction : AnAction() { } is KtDeclarationWithBody -> { - if (expression == parent.getBodyExpression()) + if (expression == parent.bodyExpression) !parent.hasBlockBody() && !parent.hasDeclaredReturnType() else true @@ -209,5 +209,5 @@ public class CheckPartialBodyResolveAction : AnAction() { } private fun KtBlockExpression.lastStatement(): KtExpression? - = getLastChild()?.siblings(forward = false)?.firstIsInstanceOrNull() + = lastChild?.siblings(forward = false)?.firstIsInstanceOrNull() } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt index d279d344680..9298fc356e2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt @@ -44,12 +44,12 @@ import org.jetbrains.kotlin.types.KotlinType import java.util.* import javax.swing.SwingUtilities -public class FindImplicitNothingAction : AnAction() { +class FindImplicitNothingAction : AnAction() { private val LOG = Logger.getInstance("#org.jetbrains.kotlin.idea.actions.internal.FindImplicitNothingAction") override fun actionPerformed(e: AnActionEvent) { val selectedFiles = selectedKotlinFiles(e).toList() - val project = CommonDataKeys.PROJECT.getData(e.getDataContext())!! + val project = CommonDataKeys.PROJECT.getData(e.dataContext)!! ProgressManager.getInstance().runProcessWithProgressSynchronously( Runnable { find(selectedFiles, project) }, @@ -59,11 +59,11 @@ public class FindImplicitNothingAction : AnAction() { } private fun find(files: Collection, project: Project) { - val progressIndicator = ProgressManager.getInstance().getProgressIndicator() + val progressIndicator = ProgressManager.getInstance().progressIndicator val found = ArrayList() for ((i, file) in files.withIndex()) { - progressIndicator?.setText("Scanning files: $i of ${files.size} file. ${found.size} occurences found") - progressIndicator?.setText2(file.getVirtualFile().getPath()) + progressIndicator?.text = "Scanning files: $i of ${files.size} file. ${found.size} occurences found" + progressIndicator?.text2 = file.virtualFile.path val resolutionFacade = file.getResolutionFacade() file.acceptChildren(object : KtVisitorVoid() { @@ -91,14 +91,14 @@ public class FindImplicitNothingAction : AnAction() { } }) - progressIndicator?.setFraction((i + 1) / files.size.toDouble()) + progressIndicator?.fraction = (i + 1) / files.size.toDouble() } SwingUtilities.invokeLater { if (found.isNotEmpty()) { val usages = found.map { UsageInfo2UsageAdapter(UsageInfo(it)) }.toTypedArray() val presentation = UsageViewPresentation() - presentation.setTabName("Implicit Nothing's") + presentation.tabName = "Implicit Nothing's" UsageViewManager.getInstance(project).showUsages(arrayOf(), usages, presentation) } else { @@ -112,10 +112,10 @@ public class FindImplicitNothingAction : AnAction() { when (callee) { is KtSimpleNameExpression -> { val target = bindingContext[BindingContext.REFERENCE_TARGET, callee] ?: return false - val callableDescriptor = (target as? CallableDescriptor ?: return false).getOriginal() + val callableDescriptor = (target as? CallableDescriptor ?: return false).original val declaration = DescriptorToSourceUtils.descriptorToDeclaration(callableDescriptor) as? KtCallableDeclaration - if (declaration != null && declaration.getTypeReference() == null) return false // implicit type - val type = callableDescriptor.getReturnType() ?: return false + if (declaration != null && declaration.typeReference == null) return false // implicit type + val type = callableDescriptor.returnType ?: return false return type.isNothingOrNothingFunctionType() } @@ -137,18 +137,18 @@ public class FindImplicitNothingAction : AnAction() { override fun update(e: AnActionEvent) { if (!KotlinInternalMode.enabled) { - e.getPresentation().setVisible(false) - e.getPresentation().setEnabled(false) + e.presentation.isVisible = false + e.presentation.isEnabled = false } else { - e.getPresentation().setVisible(true) - e.getPresentation().setEnabled(selectedKotlinFiles(e).any()) + e.presentation.isVisible = true + e.presentation.isEnabled = selectedKotlinFiles(e).any() } } private fun selectedKotlinFiles(e: AnActionEvent): Sequence { val virtualFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY) ?: return sequenceOf() - val project = CommonDataKeys.PROJECT.getData(e.getDataContext()) ?: return sequenceOf() + val project = CommonDataKeys.PROJECT.getData(e.dataContext) ?: return sequenceOf() return allKotlinFiles(virtualFiles, project) } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalModeToggleAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalModeToggleAction.kt index bc982e45112..872ae11b018 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalModeToggleAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/KotlinInternalModeToggleAction.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.actionSystem.ToggleAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer -public class KotlinInternalModeToggleAction: ToggleAction("Kotlin Internal Mode", "Show debug highlighting", null) { +class KotlinInternalModeToggleAction: ToggleAction("Kotlin Internal Mode", "Show debug highlighting", null) { override fun isSelected(e: AnActionEvent?): Boolean { return KotlinInternalMode.enabled } @@ -28,6 +28,6 @@ public class KotlinInternalModeToggleAction: ToggleAction("Kotlin Internal Mode" override fun setSelected(e: AnActionEvent?, state: Boolean) { KotlinInternalMode.enabled = state - DaemonCodeAnalyzer.getInstance(e!!.getProject())!!.settingsChanged() + DaemonCodeAnalyzer.getInstance(e!!.project)!!.settingsChanged() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/StoredExceptionsThrowToggleAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/StoredExceptionsThrowToggleAction.kt index 46ed689e9ca..5041903280c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/StoredExceptionsThrowToggleAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/StoredExceptionsThrowToggleAction.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.actionSystem.ToggleAction import org.jetbrains.kotlin.utils.WrappedValues -public class StoredExceptionsThrowToggleAction : ToggleAction("Internal: toggle throwing cached PCE", "Rethrow stored PCE as a new runtime exception", null) { +class StoredExceptionsThrowToggleAction : ToggleAction("Internal: toggle throwing cached PCE", "Rethrow stored PCE as a new runtime exception", null) { override fun isSelected(e: AnActionEvent?): Boolean { return WrappedValues.throwWrappedProcessCanceledException } @@ -33,6 +33,6 @@ public class StoredExceptionsThrowToggleAction : ToggleAction("Internal: toggle override fun update(e: AnActionEvent) { super.update(e) - e.getPresentation().setEnabled(KotlinInternalMode.enabled) + e.presentation.isEnabled = KotlinInternalMode.enabled } } diff --git a/idea/src/org/jetbrains/kotlin/idea/caches/FileAttributeServiceImpl.kt b/idea/src/org/jetbrains/kotlin/idea/caches/FileAttributeServiceImpl.kt index b6c7c726846..ca01468dd0f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/caches/FileAttributeServiceImpl.kt +++ b/idea/src/org/jetbrains/kotlin/idea/caches/FileAttributeServiceImpl.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.vfs.newvfs.FileAttribute import com.intellij.util.containers.ContainerUtil import com.intellij.util.io.DataInputOutputUtil -public class FileAttributeServiceImpl : FileAttributeService { +class FileAttributeServiceImpl : FileAttributeService { val attributes: MutableMap = ContainerUtil.newConcurrentMap() override fun register(id: String, version: Int) { diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt index f278ecf8e91..a81af8036ae 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -64,7 +64,7 @@ import java.io.IOException import java.util.* //NOTE: this class is based on CopyPasteReferenceProcessor and JavaCopyPasteReferenceProcessor -public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor() { +class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor() { private val LOG = Logger.getInstance(KotlinCopyPasteReferenceProcessor::class.java) private val IGNORE_REFERENCES_INSIDE: Array> = arrayOf( @@ -95,7 +95,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { - if (file !is KtFile || DumbService.getInstance(file.getProject()).isDumb()) return listOf() + if (file !is KtFile || DumbService.getInstance(file.getProject()).isDumb) return listOf() val collectedData = try { collectReferenceData(file, startOffsets, endOffsets) @@ -116,7 +116,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor, values: List ) { - if (DumbService.getInstance(project).isDumb()) return + if (DumbService.getInstance(project).isDumb) return - val document = editor.getDocument() + val document = editor.document val file = PsiDocumentManager.getInstance(project).getPsiFile(document) if (file !is KtFile) return @@ -185,7 +185,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor) { + fun processReferenceData(project: Project, file: KtFile, blockStart: Int, referenceData: Array) { PsiDocumentManager.getInstance(project).commitAllDocuments() val referencesPossibleToRestore = findReferencesToRestore(file, blockStart, referenceData) @@ -263,8 +263,8 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor, file: KtFile) { - val importHelper = ImportInsertHelper.getInstance(file.getProject()) - val smartPointerManager = SmartPointerManager.getInstance(file.getProject()) + val importHelper = ImportInsertHelper.getInstance(file.project) + val smartPointerManager = SmartPointerManager.getInstance(file.project) data class BindingRequest( val pointer: SmartPsiElementPointer, @@ -290,10 +290,10 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { return file.resolveImportReference(fqName).filterNot { /*TODO: temporary hack until we don't have ability to insert qualified reference into root package*/ - DescriptorUtils.getParentOfType(it, PackageFragmentDescriptor::class.java)?.fqName?.isRoot() ?: false + DescriptorUtils.getParentOfType(it, PackageFragmentDescriptor::class.java)?.fqName?.isRoot ?: false } } @@ -312,7 +312,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor): Collection { val fqNames = referencesToRestore.map { it.refData.fqName }.toSortedSet() - if (ApplicationManager.getApplication().isUnitTestMode()) { + if (ApplicationManager.getApplication().isUnitTestMode) { declarationsToImportSuggested = fqNames } @@ -324,7 +324,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor = emptyList() + @TestOnly var declarationsToImportSuggested: Collection = emptyList() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinReferenceTransferableData.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinReferenceTransferableData.kt index bc54c62cbad..556cd0da0ca 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinReferenceTransferableData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinReferenceTransferableData.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import java.awt.datatransfer.DataFlavor import java.io.Serializable -public class KotlinReferenceTransferableData( +class KotlinReferenceTransferableData( val data: Array ) : TextBlockTransferableData, Cloneable, Serializable { @@ -52,14 +52,14 @@ public class KotlinReferenceTransferableData( public override fun clone() = KotlinReferenceTransferableData(Array(data.size, { data[it].clone() })) } -public class KotlinReferenceData( - public var startOffset: Int, - public var endOffset: Int, - public val fqName: String, - public val kind: KotlinReferenceData.Kind +class KotlinReferenceData( + var startOffset: Int, + var endOffset: Int, + val fqName: String, + val kind: KotlinReferenceData.Kind ) : Cloneable, Serializable { - public enum class Kind { + enum class Kind { CLASS, PACKAGE, NON_EXTENSION_CALLABLE, @@ -67,7 +67,7 @@ public class KotlinReferenceData( EXTENSION_PROPERTY; companion object { - public fun fromDescriptor(descriptor: DeclarationDescriptor): KotlinReferenceData.Kind? { + fun fromDescriptor(descriptor: DeclarationDescriptor): KotlinReferenceData.Kind? { return when (descriptor.getImportableDescriptor()) { is ClassDescriptor -> KotlinReferenceData.Kind.CLASS @@ -98,12 +98,12 @@ public class KotlinReferenceData( } companion object { - public val dataFlavor: DataFlavor? by lazy { + val dataFlavor: DataFlavor? by lazy { try { val dataClass = KotlinReferenceData::class.java - DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + dataClass.getName(), + DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + dataClass.name, "KotlinReferenceData", - dataClass.getClassLoader()) + dataClass.classLoader) } catch (e: NoClassDefFoundError) { null diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinShortenReferencesRefactoringHelper.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinShortenReferencesRefactoringHelper.kt index 7af809ff217..8f6dca362e8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinShortenReferencesRefactoringHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinShortenReferencesRefactoringHelper.kt @@ -24,10 +24,10 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.idea.codeInsight.shorten.* import org.jetbrains.kotlin.idea.util.application.runWriteAction -public class KotlinShortenReferencesRefactoringHelper: RefactoringHelper { +class KotlinShortenReferencesRefactoringHelper: RefactoringHelper { override fun prepareOperation(usages: Array?): Any? { if (usages != null && usages.isNotEmpty()) { - val project = usages[0].getProject() + val project = usages[0].project prepareElementsToShorten(project) } return null diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt index 3d4ea80c344..1fe2ecc3559 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt @@ -40,11 +40,11 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -public class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() { +class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() { override fun isApplicable(expression: KtExpression): Boolean { - if (!expression.isPhysical()) return false - val file = expression.getContainingFile() + if (!expression.isPhysical) return false + val file = expression.containingFile if (file !is KtCodeFragment) return false val type = expression.analyze(BodyResolveMode.PARTIAL).getType(expression) ?: return false @@ -53,13 +53,13 @@ public class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() { } override fun surroundExpression(project: Project, editor: Editor, expression: KtExpression): TextRange? { - val debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext() - val debuggerSession = debuggerContext.getDebuggerSession() + val debuggerContext = DebuggerManagerEx.getInstanceEx(project).context + val debuggerSession = debuggerContext.debuggerSession if (debuggerSession != null) { - val progressWindow = ProgressWindowWithNotification(true, expression.getProject()) + val progressWindow = ProgressWindowWithNotification(true, expression.project) val worker = SurroundWithCastWorker(editor, expression, debuggerContext, progressWindow) - progressWindow.setTitle(DebuggerBundle.message("title.evaluating")) - debuggerContext.getDebugProcess()?.getManagerThread()?.startProgress(worker, progressWindow) + progressWindow.title = DebuggerBundle.message("title.evaluating") + debuggerContext.debugProcess?.managerThread?.startProgress(worker, progressWindow) } return null } @@ -80,32 +80,32 @@ public class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() { hold() - val project = myEditor.getProject() + val project = myEditor.project DebuggerInvocationUtil.invokeLater(project, Runnable { object : WriteCommandAction(project, CodeInsightBundle.message("command.name.surround.with.runtime.cast")) { override fun run(result: Result) { try { - val factory = KtPsiFactory(myElement.getProject()) + val factory = KtPsiFactory(myElement.project) - val fqName = DescriptorUtils.getFqName(type.getConstructor().getDeclarationDescriptor()!!) + val fqName = DescriptorUtils.getFqName(type.constructor.declarationDescriptor!!) val parentCast = factory.createExpression("(expr as " + fqName.asString() + ")") as KtParenthesizedExpression - val cast = parentCast.getExpression() as KtBinaryExpressionWithTypeRHS - cast.getLeft().replace(myElement) + val cast = parentCast.expression as KtBinaryExpressionWithTypeRHS + cast.left.replace(myElement) val expr = myElement.replace(parentCast) as KtExpression ShortenReferences.DEFAULT.process(expr) - val range = expr.getTextRange() - myEditor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset()) - myEditor.getCaretModel().moveToOffset(range.getEndOffset()) - myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE) + val range = expr.textRange + myEditor.selectionModel.setSelection(range.startOffset, range.endOffset) + myEditor.caretModel.moveToOffset(range.endOffset) + myEditor.scrollingModel.scrollToCaret(ScrollType.RELATIVE) } finally { release() } } }.execute() - }, myProgressIndicator.getModalityState()) + }, myProgressIndicator.modalityState) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt index b27c13638ba..269cae00518 100644 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.compiler.configuration import com.intellij.compiler.server.BuildProcessParametersProvider import org.jetbrains.kotlin.idea.PluginStartupComponent -public class KotlinBuildProcessParametersProvider(private val compilerWorkspaceSettings: KotlinCompilerWorkspaceSettings, +class KotlinBuildProcessParametersProvider(private val compilerWorkspaceSettings: KotlinCompilerWorkspaceSettings, private val kotlinPluginStartupComponent: PluginStartupComponent ): BuildProcessParametersProvider() { override fun getVMArguments(): MutableList { diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerWorkspaceSettings.kt b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerWorkspaceSettings.kt index d2ebaad3de1..d3aa585ff56 100644 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerWorkspaceSettings.kt +++ b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerWorkspaceSettings.kt @@ -27,10 +27,9 @@ import com.intellij.util.xmlb.XmlSerializerUtil storages = arrayOf( Storage(file = StoragePathMacros.WORKSPACE_FILE) ) -) -public class KotlinCompilerWorkspaceSettings() : PersistentStateComponent { - public var preciseIncrementalEnabled: Boolean = false - public var enableDaemon: Boolean = true +) class KotlinCompilerWorkspaceSettings() : PersistentStateComponent { + var preciseIncrementalEnabled: Boolean = false + var enableDaemon: Boolean = true override fun getState(): KotlinCompilerWorkspaceSettings { return this diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinJavaFrameworkSupportProvider.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinJavaFrameworkSupportProvider.kt index dba6d6518d0..76147b1ea41 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinJavaFrameworkSupportProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinJavaFrameworkSupportProvider.kt @@ -27,7 +27,7 @@ import org.jetbrains.plugins.gradle.frameworkSupport.BuildScriptDataBuilder import org.jetbrains.plugins.gradle.frameworkSupport.GradleFrameworkSupportProvider import javax.swing.Icon -public class GradleKotlinJavaFrameworkSupportProvider() : GradleFrameworkSupportProvider() { +class GradleKotlinJavaFrameworkSupportProvider() : GradleFrameworkSupportProvider() { override fun getFrameworkType(): FrameworkTypeEx = object : FrameworkTypeEx("KOTLIN") { override fun getIcon(): Icon = KotlinIcons.FILE diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupSDKNotificationProvider.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupSDKNotificationProvider.kt index d9b7635b11c..51e15e066f1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupSDKNotificationProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupSDKNotificationProvider.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.util.application.runWriteAction // Code is very same to com.intellij.codeInsight.daemon.impl.SetupSDKNotificationProvider -public class KotlinSetupSDKNotificationProvider( +class KotlinSetupSDKNotificationProvider( private val myProject: Project, notifications: EditorNotifications) : EditorNotifications.Provider(), DumbAware { diff --git a/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ConvertJavaCopyPastePostProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ConvertJavaCopyPastePostProcessor.kt index 8832283379b..2604c08f263 100644 --- a/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ConvertJavaCopyPastePostProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ConvertJavaCopyPastePostProcessor.kt @@ -50,7 +50,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.awt.datatransfer.Transferable import java.util.* -public class ConvertJavaCopyPastePostProcessor : CopyPastePostProcessor() { +class ConvertJavaCopyPastePostProcessor : CopyPastePostProcessor() { private val LOG = Logger.getInstance("#org.jetbrains.kotlin.idea.conversion.copy.ConvertJavaCopyPastePostProcessor") override fun extractTransferableData(content: Transferable): List { @@ -65,21 +65,21 @@ public class ConvertJavaCopyPastePostProcessor : CopyPastePostProcessor { + override fun collectTransferableData(file: PsiFile, editor: Editor, startOffsets: IntArray, endOffsets: IntArray): List { if (file !is PsiJavaFile) return listOf() return listOf(CopiedJavaCode(file.getText()!!, startOffsets, endOffsets)) } - public override fun processTransferableData(project: Project, editor: Editor, bounds: RangeMarker, caretOffset: Int, indented: Ref, values: List) { - if (DumbService.getInstance(project).isDumb()) return + override fun processTransferableData(project: Project, editor: Editor, bounds: RangeMarker, caretOffset: Int, indented: Ref, values: List) { + if (DumbService.getInstance(project).isDumb) return val jetEditorOptions = KotlinEditorOptions.getInstance() - if (!jetEditorOptions.isEnableJavaToKotlinConversion()) return + if (!jetEditorOptions.isEnableJavaToKotlinConversion) return val data = values.single() if (data !is CopiedJavaCode) return - val document = editor.getDocument() + val document = editor.document val targetFile = PsiDocumentManager.getInstance(project).getPsiFile(document) as? KtFile ?: return val elementAt = targetFile.findElementAt(caretOffset) @@ -103,8 +103,8 @@ public class ConvertJavaCopyPastePostProcessor : CopyPastePostProcessor true is PsiJavaToken -> { - when (element.getTokenType()) { + when (element.tokenType) { // modifiers JavaTokenType.PUBLIC_KEYWORD, JavaTokenType.PROTECTED_KEYWORD, JavaTokenType.PRIVATE_KEYWORD, JavaTokenType.STATIC_KEYWORD, JavaTokenType.ABSTRACT_KEYWORD, JavaTokenType.FINAL_KEYWORD, @@ -160,7 +160,7 @@ data class DataForConversion private constructor( is PsiCodeBlock -> element.getParent() is PsiMethod - else -> element.getFirstChild() == null + else -> element.firstChild == null } } @@ -170,7 +170,7 @@ data class DataForConversion private constructor( private fun tryClipRightSide(element: PsiElement, rightBound: Int): Int? { fun Int.transform() = Int.MAX_VALUE - this fun TextRange.transform() = TextRange(end.transform(), start.transform()) - return tryClipSide(element, rightBound.transform(), { range.transform() }, { getLastChild().siblings(forward = false) })?.transform() + return tryClipSide(element, rightBound.transform(), { range.transform() }, { lastChild.siblings(forward = false) })?.transform() } private fun tryClipSide( @@ -179,7 +179,7 @@ data class DataForConversion private constructor( rangeFunction: PsiElement.() -> TextRange, childrenFunction: PsiElement.() -> Sequence ): Int? { - if (element.getFirstChild() == null) return null + if (element.firstChild == null) return null val elementRange = element.rangeFunction() assert(elementRange.start < rangeBound && rangeBound < elementRange.end) @@ -227,22 +227,22 @@ data class DataForConversion private constructor( private fun buildImportsAndPackage(sourceFile: PsiJavaFile): String { return buildString { - val packageName = sourceFile.getPackageName() + val packageName = sourceFile.packageName if (!packageName.isEmpty()) { append("package $packageName\n") } - val importList = sourceFile.getImportList() + val importList = sourceFile.importList if (importList != null) { - for (import in importList.getImportStatements()) { - val qualifiedName = import.getQualifiedName() ?: continue - if (import.isOnDemand()) { + for (import in importList.importStatements) { + val qualifiedName = import.qualifiedName ?: continue + if (import.isOnDemand) { append("import $qualifiedName.*\n") } else { val fqName = FqNameUnsafe(qualifiedName) // skip explicit imports of platform classes mapped into Kotlin classes - if (fqName.isSafe() && JavaToKotlinClassMap.INSTANCE.mapPlatformClass(fqName.toSafe()).isNotEmpty()) continue + if (fqName.isSafe && JavaToKotlinClassMap.INSTANCE.mapPlatformClass(fqName.toSafe()).isNotEmpty()) continue append("import $qualifiedName\n") } } diff --git a/idea/src/org/jetbrains/kotlin/idea/conversion/copy/RangeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/conversion/copy/RangeUtils.kt index a8a54f6dda8..3e75e31c965 100644 --- a/idea/src/org/jetbrains/kotlin/idea/conversion/copy/RangeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/conversion/copy/RangeUtils.kt @@ -22,14 +22,14 @@ import com.intellij.psi.PsiElement //NOTE: should be moved to some "util" place -public val TextRange.start: Int - get() = getStartOffset() +val TextRange.start: Int + get() = startOffset -public val TextRange.end: Int - get() = getEndOffset() +val TextRange.end: Int + get() = endOffset -public val PsiElement.range: TextRange - get() = getTextRange()!! +val PsiElement.range: TextRange + get() = textRange!! -public val RangeMarker.range: TextRange? - get() = if (isValid()) TextRange(getStartOffset(), getEndOffset()) else null +val RangeMarker.range: TextRange? + get() = if (isValid) TextRange(startOffset, endOffset) else null diff --git a/idea/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt b/idea/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt index 13161f651de..4cc45a5ff70 100644 --- a/idea/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt +++ b/idea/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile import java.io.File -public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { +class KotlinCoverageExtension(): JavaCoverageEngineExtension() { private val LOG = Logger.getInstance(KotlinCoverageExtension::class.java) override fun isApplicableTo(conf: RunConfigurationBase?): Boolean = conf is JetRunConfiguration @@ -61,7 +61,7 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { if (element !is KtFile) { return null } - LOG.info("Retrieving coverage for " + element.getName()) + LOG.info("Retrieving coverage for " + element.name) val qualifiedNames = collectGeneratedClassQualifiedNames(findOutputRoot(element), element) return if (qualifiedNames == null) null else totalCoverageForQualifiedNames(coverageAnnotator, qualifiedNames) @@ -79,7 +79,7 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { suite: CoverageSuitesBundle, classFiles: MutableSet): Boolean { if (srcFile is KtFile) { - val fileIndex = ProjectRootManager.getInstance(srcFile.getProject()).getFileIndex() + val fileIndex = ProjectRootManager.getInstance(srcFile.getProject()).fileIndex if (fileIndex.isInLibraryClasses(srcFile.getVirtualFile()) || fileIndex.isInLibrarySource(srcFile.getVirtualFile())) { return false @@ -88,7 +88,7 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { runReadAction { val outputRoot = findOutputRoot(srcFile) val existingClassFiles = getClassesGeneratedFromFile(outputRoot, srcFile) - existingClassFiles.mapTo(classFiles) { File(it.getPath()) } + existingClassFiles.mapTo(classFiles) { File(it.path) } } return true } @@ -103,7 +103,7 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { if (existingClassFiles.isEmpty()) { return null } - LOG.debug("Classfiles: [${existingClassFiles.map { it.getName() }.joinToString()}]") + LOG.debug("Classfiles: [${existingClassFiles.map { it.name }.joinToString()}]") return existingClassFiles.map { val relativePath = VfsUtilCore.getRelativePath(it, outputRoot!!)!! StringUtil.trimEnd(relativePath, ".class").replace("/", ".") @@ -133,16 +133,16 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { } private fun getClassesGeneratedFromFile(outputRoot: VirtualFile?, file: KtFile): List { - val relativePath = file.getPackageFqName().asString().replace('.', '/') + val relativePath = file.packageFqName.asString().replace('.', '/') val packageOutputDir = outputRoot?.findFileByRelativePath(relativePath) if (packageOutputDir == null) return listOf() val prefixes = collectClassFilePrefixes(file) LOG.debug("Classfile prefixes: [${prefixes.joinToString(", ")}]") - return packageOutputDir.getChildren().filter { + return packageOutputDir.children.filter { file -> prefixes.any { - (file.getName().startsWith(it + "$") && FileUtilRt.getExtension(file.getName()) == "class") || - file.getName() == it + ".class" + (file.name.startsWith(it + "$") && FileUtilRt.getExtension(file.name) == "class") || + file.name == it + ".class" } } } @@ -150,17 +150,17 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() { private fun findOutputRoot(file: KtFile): VirtualFile? { val module = ModuleUtilCore.findModuleForPsiElement(file) if (module == null) return null - val fileIndex = ProjectRootManager.getInstance(file.getProject()).getFileIndex() - val inTests = fileIndex.isInTestSourceContent(file.getVirtualFile()) + val fileIndex = ProjectRootManager.getInstance(file.project).fileIndex + val inTests = fileIndex.isInTestSourceContent(file.virtualFile) val compilerOutputExtension = CompilerModuleExtension.getInstance(module) return if (inTests) - compilerOutputExtension!!.getCompilerOutputPathForTests() + compilerOutputExtension!!.compilerOutputPathForTests else - compilerOutputExtension!!.getCompilerOutputPath() + compilerOutputExtension!!.compilerOutputPath } private fun collectClassFilePrefixes(file: KtFile): Collection { - val result = file.getChildren().filter { it is KtClassOrObject }.map { (it as KtClassOrObject).getName()!! } + val result = file.children.filter { it is KtClassOrObject }.map { (it as KtClassOrObject).name!! } val packagePartFqName = JvmFileClassUtil.getFileClassInfoNoResolve(file).fileClassFqName return result.union(arrayListOf(packagePartFqName.shortName().asString())) } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/DiagnosticSuppressorForDebugger.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/DiagnosticSuppressorForDebugger.kt index 8a4a598ff34..4f57cedf8bd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/DiagnosticSuppressorForDebugger.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/DiagnosticSuppressorForDebugger.kt @@ -22,13 +22,13 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode import org.jetbrains.kotlin.resolve.diagnostics.DiagnosticSuppressor -public class DiagnosticSuppressorForDebugger : DiagnosticSuppressor { +class DiagnosticSuppressorForDebugger : DiagnosticSuppressor { override fun isSuppressed(diagnostic: Diagnostic): Boolean { - val element = diagnostic.getPsiElement() - val containingFile = element.getContainingFile() + val element = diagnostic.psiElement + val containingFile = element.containingFile if (containingFile is KtFile && containingFile.suppressDiagnosticsInDebugMode) { - val diagnosticFactory = diagnostic.getFactory() + val diagnosticFactory = diagnostic.factory return diagnosticFactory == Errors.INVISIBLE_MEMBER || diagnosticFactory == Errors.INVISIBLE_REFERENCE || diagnosticFactory == Errors.INVISIBLE_SETTER || diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt index 4eb540424ad..1ff9dc15511 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt @@ -29,14 +29,13 @@ import com.intellij.xdebugger.settings.DebuggerSettingsCategory import com.intellij.xdebugger.settings.XDebuggerSettings import org.jetbrains.kotlin.idea.debugger.stepping.KotlinSteppingConfigurableUi -@State(name = "KotlinDebuggerSettings", storages = arrayOf(Storage(file = StoragePathMacros.APP_CONFIG + "/kotlin_debug.xml"))) -public class KotlinDebuggerSettings : XDebuggerSettings("kotlin_debugger"), Getter { - public var DEBUG_RENDER_DELEGATED_PROPERTIES: Boolean = true - public var DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES: Boolean = true - public var DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED: Boolean = false +@State(name = "KotlinDebuggerSettings", storages = arrayOf(Storage(file = StoragePathMacros.APP_CONFIG + "/kotlin_debug.xml"))) class KotlinDebuggerSettings : XDebuggerSettings("kotlin_debugger"), Getter { + var DEBUG_RENDER_DELEGATED_PROPERTIES: Boolean = true + var DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES: Boolean = true + var DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED: Boolean = false companion object { - public fun getInstance(): KotlinDebuggerSettings { + fun getInstance(): KotlinDebuggerSettings { return XDebuggerUtil.getInstance()?.getDebuggerSettings(KotlinDebuggerSettings::class.java)!! } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt index e866e29a2ae..6dfaed5d361 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt @@ -31,14 +31,14 @@ class KotlinEditorTextProvider : EditorTextProvider { override fun getEditorText(elementAtCaret: PsiElement): TextWithImports? { val expression = findExpressionInner(elementAtCaret, true) ?: return null - val expressionText = getElementInfo(expression) { it.getText() } + val expressionText = getElementInfo(expression) { it.text } return TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText, "", KotlinFileType.INSTANCE) } override fun findExpression(elementAtCaret: PsiElement, allowMethodCalls: Boolean): Pair? { val expression = findExpressionInner(elementAtCaret, allowMethodCalls) ?: return null - val expressionRange = getElementInfo(expression) { it.getTextRange() } + val expressionRange = getElementInfo(expression) { it.textRange } return Pair(expression, expressionRange) } @@ -47,7 +47,7 @@ class KotlinEditorTextProvider : EditorTextProvider { fun getElementInfo(expr: KtExpression, f: (PsiElement) -> T): T { var expressionText = f(expr) if (expr is KtProperty) { - val nameIdentifier = expr.getNameIdentifier() + val nameIdentifier = expr.nameIdentifier if (nameIdentifier != null) { expressionText = f(nameIdentifier) } @@ -62,34 +62,34 @@ class KotlinEditorTextProvider : EditorTextProvider { if (jetElement == null) return null if (jetElement is KtProperty) { - val nameIdentifier = jetElement.getNameIdentifier() + val nameIdentifier = jetElement.nameIdentifier if (nameIdentifier == element) { return jetElement } } - val parent = jetElement.getParent() + val parent = jetElement.parent if (parent == null) return null val newExpression = when (parent) { is KtThisExpression, is KtSuperExpression, is KtReferenceExpression -> { - val pparent = parent.getParent() + val pparent = parent.parent when (pparent) { is KtQualifiedExpression -> pparent else -> parent } } is KtQualifiedExpression -> { - if (parent.getReceiverExpression() != jetElement) { + if (parent.receiverExpression != jetElement) { parent } else { null } } is KtOperationExpression -> { - if (parent.getOperationReference() == jetElement) { + if (parent.operationReference == jetElement) { parent } else { null @@ -102,7 +102,7 @@ class KotlinEditorTextProvider : EditorTextProvider { fun PsiElement.isCall() = this is KtCallExpression || this is KtOperationExpression || this is KtArrayAccessExpression if (newExpression.isCall() || - newExpression is KtQualifiedExpression && newExpression.getSelectorExpression()!!.isCall()) { + newExpression is KtQualifiedExpression && newExpression.selectorExpression!!.isCall()) { return null } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt index 4ba2ef31e1b..2e0f3344742 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.utils.addToStdlib.check import java.util.* -public class KotlinFrameExtraVariablesProvider : FrameExtraVariablesProvider { +class KotlinFrameExtraVariablesProvider : FrameExtraVariablesProvider { override fun isAvailable(sourcePosition: SourcePosition, evalContext: EvaluationContext): Boolean { if (sourcePosition.line < 0) return false return sourcePosition.file.fileType == KotlinFileType.INSTANCE && DebuggerSettings.getInstance().AUTO_VARIABLES_MODE diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt index 83754e3fb17..6d8f841f86b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt @@ -77,7 +77,7 @@ import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.* import com.intellij.debugger.engine.DebuggerUtils as JDebuggerUtils -public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiRequestPositionManager, PositionManagerEx() { +class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiRequestPositionManager, PositionManagerEx() { private val myTypeMappers = WeakHashMap>() @@ -281,7 +281,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M } } - public fun classNamesForPosition(sourcePosition: SourcePosition): Collection { + fun classNamesForPosition(sourcePosition: SourcePosition): Collection { val psiElement = runReadAction { sourcePosition.elementAt } ?: return emptyList() return classNamesForPosition(psiElement) } @@ -350,8 +350,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M } } - @TestOnly - public fun addTypeMapper(file: KtFile, typeMapper: JetTypeMapper) { + @TestOnly fun addTypeMapper(file: KtFile, typeMapper: JetTypeMapper) { val value = CachedValuesManager.getManager(file.project).createCachedValue( { CachedValueProvider.Result(typeMapper, PsiModificationTracker.MODIFICATION_COUNT) }, false) val key = createKeyForTypeMapper(file) @@ -442,7 +441,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M return PsiTreeUtil.getParentOfType(notPositionedElement, *TYPES_TO_CALCULATE_CLASSNAME) } - public fun getJvmInternalNameForPropertyOwner(typeMapper: JetTypeMapper, descriptor: PropertyDescriptor): String { + fun getJvmInternalNameForPropertyOwner(typeMapper: JetTypeMapper, descriptor: PropertyDescriptor): String { return typeMapper.mapOwner( if (JvmAbi.isPropertyWithBackingFieldInOuterClass(descriptor)) descriptor.containingDeclaration else descriptor ).internalName @@ -475,7 +474,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M return state.typeMapper } - public fun isInlinedLambda(functionLiteral: KtFunction, context: BindingContext): Boolean { + fun isInlinedLambda(functionLiteral: KtFunction, context: BindingContext): Boolean { return InlineUtil.isInlinedArgument(functionLiteral, context, false) } @@ -585,7 +584,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M private fun String?.toSet() = if (this == null) emptySet() else setOf(this) companion object { - public fun createTypeMapper(file: KtFile): JetTypeMapper { + fun createTypeMapper(file: KtFile): JetTypeMapper { val project = file.project val analysisResult = file.analyzeFullyAndGetResult() diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt index d461c451fa2..492347f92f9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt @@ -21,7 +21,7 @@ import com.intellij.debugger.engine.SourcePositionHighlighter import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.psi.KtFunctionLiteral -public class KotlinSourcePositionHighlighter: SourcePositionHighlighter() { +class KotlinSourcePositionHighlighter: SourcePositionHighlighter() { override fun getHighlightRange(sourcePosition: SourcePosition?): TextRange? { val lambda = sourcePosition?.elementAt?.parent if (lambda is KtFunctionLiteral) { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt index 5d26128ccb3..3dd4cab21f7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt @@ -45,9 +45,9 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.source.KotlinSourceElement import org.jetbrains.kotlin.resolve.source.getPsi -public class KotlinSourcePositionProvider: SourcePositionProvider() { +class KotlinSourcePositionProvider: SourcePositionProvider() { override fun computeSourcePosition(descriptor: NodeDescriptor, project: Project, context: DebuggerContextImpl, nearest: Boolean): SourcePosition? { - if (context.getFrameProxy() == null) return null + if (context.frameProxy == null) return null if (descriptor is FieldDescriptor) { return computeSourcePosition(descriptor, project, context, nearest) @@ -62,22 +62,22 @@ public class KotlinSourcePositionProvider: SourcePositionProvider() { private fun computeSourcePosition(descriptor: LocalVariableDescriptor, project: Project, context: DebuggerContextImpl, nearest: Boolean): SourcePosition? { val place = PositionUtil.getContextElement(context) ?: return null - if (place.getContainingFile() !is KtFile) return null + if (place.containingFile !is KtFile) return null val contextElement = KotlinCodeFragmentFactory.getContextElement(place) ?: return null - val codeFragment = KtPsiFactory(project).createExpressionCodeFragment(descriptor.getName(), contextElement) + val codeFragment = KtPsiFactory(project).createExpressionCodeFragment(descriptor.name, contextElement) val expression = codeFragment.getContentElement() if (expression is KtSimpleNameExpression) { val bindingContext = expression.analyze(BodyResolveMode.PARTIAL) val declarationDescriptor = BindingContextUtils.extractVariableDescriptorIfAny(bindingContext, expression, false) - val sourceElement = declarationDescriptor?.getSource() + val sourceElement = declarationDescriptor?.source if (sourceElement is KotlinSourceElement) { val element = sourceElement.getPsi() ?: return null if (nearest) { - return DebuggerContextUtil.findNearest(context, element, element.getContainingFile()) + return DebuggerContextUtil.findNearest(context, element, element.containingFile) } - return SourcePosition.createFromOffset(element.getContainingFile(), element.getTextOffset()) + return SourcePosition.createFromOffset(element.containingFile, element.textOffset) } } @@ -85,33 +85,33 @@ public class KotlinSourcePositionProvider: SourcePositionProvider() { } private fun computeSourcePosition(descriptor: FieldDescriptor, project: Project, context: DebuggerContextImpl, nearest: Boolean): SourcePosition? { - val fieldName = descriptor.getField().name() + val fieldName = descriptor.field.name() if (fieldName == AsmUtil.CAPTURED_THIS_FIELD || fieldName == AsmUtil.CAPTURED_RECEIVER_FIELD) { return null } - val type = descriptor.getField().declaringType() - val myClass = findClassByType(project, type, context)?.getNavigationElement() as? KtClassOrObject ?: return null + val type = descriptor.field.declaringType() + val myClass = findClassByType(project, type, context)?.navigationElement as? KtClassOrObject ?: return null - val field = myClass.getDeclarations().firstOrNull { fieldName == it.getName() } ?: return null + val field = myClass.declarations.firstOrNull { fieldName == it.name } ?: return null if (nearest) { - return DebuggerContextUtil.findNearest(context, field, myClass.getContainingFile()) + return DebuggerContextUtil.findNearest(context, field, myClass.containingFile) } - return SourcePosition.createFromOffset(field.getContainingFile(), field.getTextOffset()) + return SourcePosition.createFromOffset(field.containingFile, field.textOffset) } private fun findClassByType(project: Project, type: ReferenceType, context: DebuggerContextImpl): PsiElement? { - val session = context.getDebuggerSession() - val scope = if (session != null) session.getSearchScope() else GlobalSearchScope.allScope(project) - val className = JvmClassName.byInternalName(type.name()).getFqNameForClassNameWithoutDollars().asString() + val session = context.debuggerSession + val scope = if (session != null) session.searchScope else GlobalSearchScope.allScope(project) + val className = JvmClassName.byInternalName(type.name()).fqNameForClassNameWithoutDollars.asString() val myClass = JavaPsiFacade.getInstance(project).findClass(className, scope) if (myClass != null) return myClass val position = getLastSourcePosition(type, context) if (position != null) { - val element = position.getElementAt() + val element = position.elementAt if (element != null) { return element.getStrictParentOfType() } @@ -120,13 +120,13 @@ public class KotlinSourcePositionProvider: SourcePositionProvider() { } private fun getLastSourcePosition(type: ReferenceType, context: DebuggerContextImpl): SourcePosition? { - val debugProcess = context.getDebugProcess() + val debugProcess = context.debugProcess if (debugProcess != null) { try { val locations = type.allLineLocations() if (!locations.isEmpty()) { val lastLocation = locations.get(locations.size - 1) - return debugProcess.getPositionManager().getSourcePosition(lastLocation) + return debugProcess.positionManager.getSourcePosition(lastLocation) } } catch (ignored: AbsentInformationException) { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinBreakpointHandlerFactory.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinBreakpointHandlerFactory.kt index 7701c42519b..8a92b551af0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinBreakpointHandlerFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinBreakpointHandlerFactory.kt @@ -20,17 +20,17 @@ import com.intellij.debugger.engine.DebugProcessImpl import com.intellij.debugger.engine.JavaBreakpointHandler import com.intellij.debugger.engine.JavaBreakpointHandlerFactory -public class KotlinFieldBreakpointHandlerFactory : JavaBreakpointHandlerFactory { +class KotlinFieldBreakpointHandlerFactory : JavaBreakpointHandlerFactory { override fun createHandler(process: DebugProcessImpl): JavaBreakpointHandler? { return KotlinFieldBreakpointHandler(process) } } -public class KotlinLineBreakpointHandlerFactory: JavaBreakpointHandlerFactory { +class KotlinLineBreakpointHandlerFactory: JavaBreakpointHandlerFactory { override fun createHandler(process: DebugProcessImpl): JavaBreakpointHandler? { return KotlinLineBreakpointHandler(process) } } -public class KotlinFieldBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(KotlinFieldBreakpointType::class.java, process) -public class KotlinLineBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(KotlinLineBreakpointType::class.java, process) \ No newline at end of file +class KotlinFieldBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(KotlinFieldBreakpointType::class.java, process) +class KotlinLineBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(KotlinLineBreakpointType::class.java, process) \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt index 2883883025f..babfef6c640 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt @@ -71,25 +71,25 @@ class KotlinFieldBreakpoint( private var breakpointType: BreakpointType = BreakpointType.FIELD override fun isValid(): Boolean { - if (!BreakpointWithHighlighter.isPositionValid(getXBreakpoint().getSourcePosition())) return false + if (!BreakpointWithHighlighter.isPositionValid(xBreakpoint.sourcePosition)) return false return runReadAction { val field = getField() - field != null && field.isValid() + field != null && field.isValid } } - public fun getField(): KtCallableDeclaration? { - val sourcePosition = getSourcePosition() + fun getField(): KtCallableDeclaration? { + val sourcePosition = sourcePosition return getProperty(sourcePosition) } private fun getProperty(sourcePosition: SourcePosition?): KtCallableDeclaration? { - val property: KtProperty? = PositionUtil.getPsiElementAt(getProject(), KtProperty::class.java, sourcePosition) + val property: KtProperty? = PositionUtil.getPsiElementAt(project, KtProperty::class.java, sourcePosition) if (property != null) { return property } - val parameter: KtParameter? = PositionUtil.getPsiElementAt(getProject(), KtParameter::class.java, sourcePosition) + val parameter: KtParameter? = PositionUtil.getPsiElementAt(project, KtParameter::class.java, sourcePosition) if (parameter != null) { return parameter } @@ -97,45 +97,45 @@ class KotlinFieldBreakpoint( } override fun reload(psiFile: PsiFile?) { - val property = getProperty(getSourcePosition()) + val property = getProperty(sourcePosition) if (property != null) { - setFieldName(property.getName()!!) + setFieldName(property.name!!) - if (property is KtProperty && property.isTopLevel()) { - getProperties().myClassName = JvmFileClassUtil.getFileClassInfoNoResolve(property.getContainingKtFile()).fileClassFqName.asString() + if (property is KtProperty && property.isTopLevel) { + properties.myClassName = JvmFileClassUtil.getFileClassInfoNoResolve(property.getContainingKtFile()).fileClassFqName.asString() } else { val ktClass: KtClassOrObject? = PsiTreeUtil.getParentOfType(property, KtClassOrObject::class.java) if (ktClass is KtClassOrObject) { - val fqName = ktClass.getFqName() + val fqName = ktClass.fqName if (fqName != null) { - getProperties().myClassName = fqName.asString() + properties.myClassName = fqName.asString() } } } - setInstanceFiltersEnabled(false) + isInstanceFiltersEnabled = false } } override fun createRequestForPreparedClass(debugProcess: DebugProcessImpl?, refType: ReferenceType?) { if (debugProcess == null || refType == null) return - val property = getProperty(getSourcePosition()) ?: return + val property = getProperty(sourcePosition) ?: return breakpointType = computeBreakpointType(property) - val vm = debugProcess.getVirtualMachineProxy() + val vm = debugProcess.virtualMachineProxy try { - if (getProperties().WATCH_INITIALIZATION) { - val sourcePosition = getSourcePosition() + if (properties.WATCH_INITIALIZATION) { + val sourcePosition = sourcePosition if (sourcePosition != null) { - debugProcess.getPositionManager() + debugProcess.positionManager .locationsOfLine(refType, sourcePosition) - .filter { it.method().isConstructor() || it.method().isStaticInitializer() } + .filter { it.method().isConstructor || it.method().isStaticInitializer } .forEach { - val request = debugProcess.getRequestsManager().createBreakpointRequest(this, it) - debugProcess.getRequestsManager().enableRequest(request) - if (LOG.isDebugEnabled()) { + val request = debugProcess.requestsManager.createBreakpointRequest(this, it) + debugProcess.requestsManager.enableRequest(request) + if (LOG.isDebugEnabled) { LOG.debug("Breakpoint request added") } } @@ -146,18 +146,18 @@ class KotlinFieldBreakpoint( BreakpointType.FIELD -> { val field = refType.fieldByName(getFieldName()) if (field != null) { - val manager = debugProcess.getRequestsManager() - if (getProperties().WATCH_MODIFICATION && vm.canWatchFieldModification()) { + val manager = debugProcess.requestsManager + if (properties.WATCH_MODIFICATION && vm.canWatchFieldModification()) { val request = manager.createModificationWatchpointRequest(this, field) - debugProcess.getRequestsManager().enableRequest(request) - if (LOG.isDebugEnabled()) { + debugProcess.requestsManager.enableRequest(request) + if (LOG.isDebugEnabled) { LOG.debug("Modification request added") } } - if (getProperties().WATCH_ACCESS && vm.canWatchFieldAccess()) { + if (properties.WATCH_ACCESS && vm.canWatchFieldAccess()) { val request = manager.createAccessWatchpointRequest(this, field) - debugProcess.getRequestsManager().enableRequest(request) - if (LOG.isDebugEnabled()) { + debugProcess.requestsManager.enableRequest(request) + if (LOG.isDebugEnabled) { LOG.debug("Field access request added (field = ${field.name()}; refType = ${refType.name()})") } } @@ -166,14 +166,14 @@ class KotlinFieldBreakpoint( BreakpointType.METHOD -> { val fieldName = getFieldName() - if (getProperties().WATCH_ACCESS) { + if (properties.WATCH_ACCESS) { val getter = refType.methodsByName(JvmAbi.getterName(fieldName)).firstOrNull() if (getter != null) { createMethodBreakpoint(debugProcess, refType, getter) } } - if (getProperties().WATCH_MODIFICATION) { + if (properties.WATCH_MODIFICATION) { val setter = refType.methodsByName(JvmAbi.setterName(fieldName)).firstOrNull() if (setter != null) { createMethodBreakpoint(debugProcess, refType, setter) @@ -205,12 +205,12 @@ class KotlinFieldBreakpoint( } private fun createMethodBreakpoint(debugProcess: DebugProcessImpl, refType: ReferenceType, accessor: Method) { - val manager = debugProcess.getRequestsManager() + val manager = debugProcess.requestsManager val line = accessor.allLineLocations().firstOrNull() if (line != null) { val request = manager.createBreakpointRequest(this, line) - debugProcess.getRequestsManager().enableRequest(request) - if (LOG.isDebugEnabled()) { + debugProcess.requestsManager.enableRequest(request) + if (LOG.isDebugEnabled) { LOG.debug("Breakpoint request added") } } @@ -218,7 +218,7 @@ class KotlinFieldBreakpoint( var entryRequest: MethodEntryRequest? = findRequest(debugProcess, MethodEntryRequest::class.java, this) if (entryRequest == null) { entryRequest = manager.createMethodEntryRequest(this)!! - if (LOG.isDebugEnabled()) { + if (LOG.isDebugEnabled) { LOG.debug("Method entry request added (method = ${accessor.name()}; refType = ${refType.name()})") } } @@ -231,7 +231,7 @@ class KotlinFieldBreakpoint( } inline fun findRequest(debugProcess: DebugProcessImpl, requestClass: Class, requestor: Requestor): T? { - val requests = debugProcess.getRequestsManager().findRequests(requestor) + val requests = debugProcess.requestsManager.findRequests(requestor) for (eventRequest in requests) { if (eventRequest.javaClass == requestClass) { return eventRequest as T @@ -247,7 +247,7 @@ class KotlinFieldBreakpoint( return super.evaluateCondition(context, event) } - public fun matchesEvent(event: LocatableEvent): Boolean { + fun matchesEvent(event: LocatableEvent): Boolean { val method = event.location().method() // TODO check property type return method != null && method.name() in getMethodsName() @@ -320,26 +320,26 @@ class KotlinFieldBreakpoint( } fun setFieldName(fieldName: String) { - getProperties().myFieldName = fieldName + properties.myFieldName = fieldName } @TestOnly fun setWatchAccess(value: Boolean) { - getProperties().WATCH_ACCESS = value + properties.WATCH_ACCESS = value } @TestOnly fun setWatchModification(value: Boolean) { - getProperties().WATCH_MODIFICATION = value + properties.WATCH_MODIFICATION = value } @TestOnly fun setWatchInitialization(value: Boolean) { - getProperties().WATCH_INITIALIZATION = value + properties.WATCH_INITIALIZATION = value } override fun getDisabledIcon(isMuted: Boolean): Icon { - val master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this) + val master = DebuggerManagerEx.getInstanceEx(myProject).breakpointManager.findMasterBreakpoint(this) return when { isMuted && master == null -> AllIcons.Debugger.Db_muted_disabled_field_breakpoint isMuted && master != null -> AllIcons.Debugger.Db_muted_dep_field_breakpoint @@ -379,16 +379,16 @@ class KotlinFieldBreakpoint( override fun getCategory() = CATEGORY override fun getDisplayName(): String? { - if (!isValid()) { + if (!isValid) { return DebuggerBundle.message("status.breakpoint.invalid") } - val className = getClassName() + val className = className return if (className != null && !className.isEmpty()) className + "." + getFieldName() else getFieldName() } private fun getFieldName(): String { val declaration = getField() - return runReadAction { declaration?.getName() } ?: "unknown" + return runReadAction { declaration?.name } ?: "unknown" } override fun getEvaluationElement(): PsiElement? { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointPropertiesPanel.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointPropertiesPanel.kt index cd73247122a..2b0d399dcd7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointPropertiesPanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointPropertiesPanel.kt @@ -30,7 +30,7 @@ import javax.swing.JComponent import javax.swing.JPanel import kotlin.properties.Delegates -public class KotlinFieldBreakpointPropertiesPanel: XBreakpointCustomPropertiesPanel>() { +class KotlinFieldBreakpointPropertiesPanel: XBreakpointCustomPropertiesPanel>() { private var myWatchInitializationCheckBox: JCheckBox by Delegates.notNull() private var myWatchAccessCheckBox: JCheckBox by Delegates.notNull() private var myWatchModificationCheckBox: JCheckBox by Delegates.notNull() diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointType.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointType.kt index 6de6358382b..7912ae40d1e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointType.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpointType.kt @@ -44,7 +44,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtProperty import javax.swing.JComponent -public class KotlinFieldBreakpointType : JavaBreakpointType, XLineBreakpointType( +class KotlinFieldBreakpointType : JavaBreakpointType, XLineBreakpointType( "kotlin-field", KotlinBundle.message("debugger.field.watchpoints.tab.title") ) { override fun createJavaBreakpoint(project: Project, breakpoint: XBreakpoint): Breakpoint { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinPropertyBreakpointProperties.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinPropertyBreakpointProperties.kt index 54cd60104cc..c6004c8f410 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinPropertyBreakpointProperties.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinPropertyBreakpointProperties.kt @@ -19,13 +19,13 @@ package org.jetbrains.kotlin.idea.debugger.breakpoints import com.intellij.util.xmlb.annotations.Attribute import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties -public class KotlinPropertyBreakpointProperties( +class KotlinPropertyBreakpointProperties( @Attribute var myFieldName: String = "", @Attribute var myClassName: String = "" ): JavaBreakpointProperties() { - public var WATCH_MODIFICATION: Boolean = true - public var WATCH_ACCESS: Boolean = false - public var WATCH_INITIALIZATION: Boolean = false + var WATCH_MODIFICATION: Boolean = true + var WATCH_ACCESS: Boolean = false + var WATCH_INITIALIZATION: Boolean = false override fun getState() = this diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt index 0dd43c51741..8244add44ef 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt @@ -25,11 +25,11 @@ import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi.KtFunction import java.util.* -public fun isInsideInlineFunctionBody(visibleVariables: List): Boolean { +fun isInsideInlineFunctionBody(visibleVariables: List): Boolean { return visibleVariables.any { it.name().startsWith(JvmAbi.LOCAL_VARIABLE_NAME_PREFIX_INLINE_FUNCTION) } } -public fun numberOfInlinedFunctions(visibleVariables: List): Int { +fun numberOfInlinedFunctions(visibleVariables: List): Int { return visibleVariables.count { it.name().startsWith(JvmAbi.LOCAL_VARIABLE_NAME_PREFIX_INLINE_FUNCTION) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt index 8df9a371d4b..d84bf39581a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt @@ -42,7 +42,7 @@ class FrameVisitor(context: EvaluationContextImpl) { val OBJECT_TYPE = Type.getType(Any::class.java) } - public fun findValue(name: String, asmType: Type?, checkType: Boolean, failIfNotFound: Boolean): Value? { + fun findValue(name: String, asmType: Type?, checkType: Boolean, failIfNotFound: Boolean): Value? { if (frame == null) return null try { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt index 2ac918fcc7a..d845c465aee 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt @@ -133,8 +133,8 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() { override fun getEvaluatorBuilder() = KotlinEvaluationBuilder companion object { - public val LABEL_VARIABLE_VALUE_KEY: Key = Key.create("_label_variable_value_key_") - public val DEBUG_LABEL_SUFFIX: String = "_DebugLabel" + val LABEL_VARIABLE_VALUE_KEY: Key = Key.create("_label_variable_value_key_") + val DEBUG_LABEL_SUFFIX: String = "_DebugLabel" @TestOnly val DEBUG_FRAME_FOR_TESTS: Key = Key.create("DEBUG_FRAME_FOR_TESTS") fun getContextElement(elementAt: PsiElement?): KtElement? { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt index df080f8fbe2..126830ae7c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt @@ -52,11 +52,11 @@ class KotlinEvaluateExpressionCache(val project: Project) { evaluationContext: EvaluationContextImpl, create: (KtCodeFragment, SourcePosition) -> CompiledDataDescriptor ): CompiledDataDescriptor { - val evaluateExpressionCache = getInstance(codeFragment.getProject()) + val evaluateExpressionCache = getInstance(codeFragment.project) return synchronized(evaluateExpressionCache.cachedCompiledData) { - val cache = evaluateExpressionCache.cachedCompiledData.getValue()!! - val text = "${codeFragment.importsToString()}\n${codeFragment.getText()}" + val cache = evaluateExpressionCache.cachedCompiledData.value!! + val text = "${codeFragment.importsToString()}\n${codeFragment.text}" val answer = cache[text].firstOrNull { it.sourcePosition == sourcePosition || evaluateExpressionCache.canBeEvaluatedInThisContext(it, evaluationContext) @@ -64,7 +64,7 @@ class KotlinEvaluateExpressionCache(val project: Project) { if (answer != null) return@synchronized answer val newCompiledData = create(codeFragment, sourcePosition) - LOG.debug("Compile bytecode for ${codeFragment.getText()}") + LOG.debug("Compile bytecode for ${codeFragment.text}") cache.putValue(text, newCompiledData) return@synchronized newCompiledData @@ -80,7 +80,7 @@ class KotlinEvaluateExpressionCache(val project: Project) { if (value == null) return@all false val thisDescriptor = value.asmType.getClassDescriptor(project) - val superClassDescriptor = jetType.getConstructor().getDeclarationDescriptor() as? ClassDescriptor + val superClassDescriptor = jetType.constructor.declarationDescriptor as? ClassDescriptor return@all thisDescriptor != null && superClassDescriptor != null && runReadAction { DescriptorUtils.isSubclass(thisDescriptor, superClassDescriptor) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt index 6b7521fd888..46073f1ada6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.org.objectweb.asm.Type as AsmType -public abstract class KotlinRuntimeTypeEvaluator( +abstract class KotlinRuntimeTypeEvaluator( editor: Editor?, expression: KtExpression, context: DebuggerContextImpl, diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilingEvaluator.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilingEvaluator.kt index a8bf133f7dc..8b1906ff5ff 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilingEvaluator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilingEvaluator.kt @@ -25,7 +25,7 @@ import com.intellij.openapi.util.SystemInfo import com.sun.jdi.ClassLoaderReference import org.jetbrains.kotlin.idea.debugger.evaluate.CompilingEvaluatorUtils -public fun loadClasses(evaluationContext: EvaluationContextImpl, classes: Collection>) { +fun loadClasses(evaluationContext: EvaluationContextImpl, classes: Collection>) { val process = evaluationContext.debugProcess val classLoader: ClassLoaderReference diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt index c002c87c27e..e79580634a6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings private val KOTLIN_STDLIB_FILTER = "kotlin.*" -public fun addKotlinStdlibDebugFilterIfNeeded() { +fun addKotlinStdlibDebugFilterIfNeeded() { if (!KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED) { val settings = DebuggerSettings.getInstance()!! val newFilters = (settings.steppingFilters + ClassFilter(KOTLIN_STDLIB_FILTER)) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinDebuggerInternalClassesFilterProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinDebuggerInternalClassesFilterProvider.kt index ee2c895e203..6c8423cb445 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinDebuggerInternalClassesFilterProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinDebuggerInternalClassesFilterProvider.kt @@ -28,7 +28,7 @@ private val FILTERS = listOf( ClassFilter("kotlin.KotlinNullPointerException") ) -public class KotlinDebuggerInternalClassesFilterProvider : DebuggerClassFilterProvider { +class KotlinDebuggerInternalClassesFilterProvider : DebuggerClassFilterProvider { override fun getFilters(): List? { return if (KotlinDebuggerSettings.getInstance().DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES) FILTERS else listOf() } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt index 0772cde6074..376da1c41b0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.org.objectweb.asm.Opcodes import sun.tools.java.RuntimeConstants -public class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider { +class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider { override fun isSynthetic(typeComponent: TypeComponent?): Boolean { if (typeComponent !is Method) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt index 625bd003c87..26d7a6ccb7e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt @@ -34,7 +34,7 @@ import java.util.* import com.sun.jdi.Type as JdiType import org.jetbrains.org.objectweb.asm.Type as AsmType -public class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() { +class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() { override fun isApplicable(jdiType: Type?): Boolean { if (!super.isApplicable(jdiType)) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt index 28045743456..b1fb60ad1fe 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi.* -public class KotlinBasicStepMethodFilter( +class KotlinBasicStepMethodFilter( val resolvedElement: KtElement, val myCallingExpressionLines: Range ) : NamedMethodFilter { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt index d37c3b8dda6..b11eac95cf0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaMethodFilter.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.util.OperatorNameConventions -public class KotlinLambdaMethodFilter( +class KotlinLambdaMethodFilter( private val lambda: KtFunction, private val myCallingExpressionLines: Range, private val isInline: Boolean @@ -73,7 +73,7 @@ public class KotlinLambdaMethodFilter( override fun getCallingExpressionLines() = if (isInline) Range(0, 999) else myCallingExpressionLines companion object { - public fun isLambdaName(name: String?): Boolean { + fun isLambdaName(name: String?): Boolean { return name == OperatorNameConventions.INVOKE.asString() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt index 9d6e93e385c..bfb3b62fb3b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.util.OperatorNameConventions -public class KotlinLambdaSmartStepTarget( +class KotlinLambdaSmartStepTarget( label: String, highlightElement: KtFunction, lines: Range, diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt index cc44e2c6d12..bde298d9ef0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy import javax.swing.Icon -public class KotlinMethodSmartStepTarget( +class KotlinMethodSmartStepTarget( val resolvedElement: KtElement, label: String, highlightElement: PsiElement, diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt index 9dc892bc2b5..36102c9477f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getParentCall import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.inline.InlineUtil -public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() { +class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() { override fun isAvailable(position: SourcePosition?) = position?.file is KtFile diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index d376cf930af..6a4bb65eb9a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { +class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { override fun getStepOverCommand( suspendContext: SuspendContextImpl?, ignoreBreakpoints: Boolean, diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt index 7aa983894e0..cbc1592e11b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* -public class KotlinEnterHandler: EnterHandlerDelegateAdapter() { +class KotlinEnterHandler: EnterHandlerDelegateAdapter() { companion object { private val LOG = Logger.getInstance(KotlinEnterHandler::class.java) private val FORCE_INDENT_IN_LAMBDA_AFTER = TokenSet.create(KtTokens.ARROW, KtTokens.LBRACE) @@ -57,8 +57,8 @@ public class KotlinEnterHandler: EnterHandlerDelegateAdapter() { if (!CodeInsightSettings.getInstance()!!.SMART_INDENT_ON_ENTER) return EnterHandlerDelegate.Result.Continue - val document = editor.getDocument() - val text = document.getCharsSequence() + val document = editor.document + val text = document.charsSequence val caretOffset = caretOffsetRef.get()!!.toInt() if (caretOffset !in 0..text.length) return EnterHandlerDelegate.Result.Continue @@ -70,15 +70,15 @@ public class KotlinEnterHandler: EnterHandlerDelegateAdapter() { val elementBefore = CodeInsightUtils.getElementAtOffsetIgnoreWhitespaceAfter(file, caretOffset); val elementAfter = CodeInsightUtils.getElementAtOffsetIgnoreWhitespaceBefore(file, caretOffset); - val isAfterLBraceOrArrow = elementBefore != null && elementBefore.getNode()!!.getElementType() in FORCE_INDENT_IN_LAMBDA_AFTER - val isBeforeRBrace = elementAfter == null || elementAfter.getNode()!!.getElementType() == KtTokens.RBRACE + val isAfterLBraceOrArrow = elementBefore != null && elementBefore.node!!.elementType in FORCE_INDENT_IN_LAMBDA_AFTER + val isBeforeRBrace = elementAfter == null || elementAfter.node!!.elementType == KtTokens.RBRACE - if (isAfterLBraceOrArrow && isBeforeRBrace && (elementBefore!!.getParent() is KtFunctionLiteral)) { + if (isAfterLBraceOrArrow && isBeforeRBrace && (elementBefore!!.parent is KtFunctionLiteral)) { originalHandler?.execute(editor, dataContext) PsiDocumentManager.getInstance(file.getProject()).commitDocument(document) try { - CodeStyleManager.getInstance(file.getProject())!!.adjustLineIndent(file, editor.getCaretModel().getOffset()) + CodeStyleManager.getInstance(file.getProject())!!.adjustLineIndent(file, editor.caretModel.offset) } catch (e: IncorrectOperationException) { LOG.error(e); @@ -101,13 +101,13 @@ public class KotlinEnterHandler: EnterHandlerDelegateAdapter() { val psiAtOffset = psiFile.findElementAt(caretOffset) ?: return false val stringTemplate = psiAtOffset.getStrictParentOfType() ?: return false if (!stringTemplate.isSingleQuoted()) return false - val tokenType = psiAtOffset.getNode().getElementType() + val tokenType = psiAtOffset.node.elementType when (tokenType) { KtTokens.CLOSING_QUOTE, KtTokens.REGULAR_STRING_PART, KtTokens.ESCAPE_SEQUENCE, KtTokens.SHORT_TEMPLATE_ENTRY_START, KtTokens.LONG_TEMPLATE_ENTRY_START -> { - val doc = editor.getDocument() + val doc = editor.document var caretAdvance = 1 - if (stringTemplate.getParent() is KtDotQualifiedExpression) { + if (stringTemplate.parent is KtDotQualifiedExpression) { doc.insertString(stringTemplate.endOffset, ")") doc.insertString(stringTemplate.startOffset, "(") caretOffset++ diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinQuoteHandler.kt b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinQuoteHandler.kt index 35db1ea8445..c2da3aa5f39 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinQuoteHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinQuoteHandler.kt @@ -22,13 +22,13 @@ import com.intellij.openapi.editor.highlighter.HighlighterIterator import com.intellij.psi.tree.IElementType import org.jetbrains.kotlin.lexer.KtTokens -public class KotlinQuoteHandler : QuoteHandler { +class KotlinQuoteHandler : QuoteHandler { override fun isClosingQuote(iterator: HighlighterIterator, offset: Int): Boolean { - val tokenType = iterator.getTokenType() + val tokenType = iterator.tokenType if (tokenType == KtTokens.CHARACTER_LITERAL) { - val start = iterator.getStart() - val end = iterator.getEnd() + val start = iterator.start + val end = iterator.end return end - start >= 1 && offset == end - 1 } else if (tokenType == KtTokens.CLOSING_QUOTE) { @@ -38,10 +38,10 @@ public class KotlinQuoteHandler : QuoteHandler { } override fun isOpeningQuote(iterator: HighlighterIterator, offset: Int): Boolean { - val tokenType = iterator.getTokenType() + val tokenType = iterator.tokenType if (tokenType == KtTokens.OPEN_QUOTE) { - val start = iterator.getStart() + val start = iterator.start return offset == start } return false @@ -52,7 +52,7 @@ public class KotlinQuoteHandler : QuoteHandler { } override fun isInsideLiteral(iterator: HighlighterIterator): Boolean { - val tokenType = iterator.getTokenType() + val tokenType = iterator.tokenType return tokenType == KtTokens.REGULAR_STRING_PART || tokenType == KtTokens.OPEN_QUOTE || tokenType == KtTokens.CLOSING_QUOTE || diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinSmartEnterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinSmartEnterHandler.kt index 411263b0843..6563551863f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinSmartEnterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinSmartEnterHandler.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { +class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { init { addFixers( KotlinIfConditionFixer(), @@ -60,7 +60,7 @@ public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { while (atCaret != null) { when { atCaret.isKotlinStatement() == true -> return atCaret - atCaret.getParent() is KtFunctionLiteral -> return atCaret + atCaret.parent is KtFunctionLiteral -> return atCaret atCaret is KtDeclaration -> { val declaration = atCaret when { @@ -71,15 +71,15 @@ public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { } } - atCaret = atCaret.getParent() + atCaret = atCaret.parent } return null } override fun moveCaretInsideBracesIfAny(editor: Editor, file: PsiFile) { - var caretOffset = editor.getCaretModel().getOffset() - val chars = editor.getDocument().getCharsSequence() + var caretOffset = editor.caretModel.offset + val chars = editor.document.charsSequence if (CharArrayUtil.regionMatches(chars, caretOffset, "{}")) { caretOffset += 2 @@ -95,7 +95,7 @@ public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { if (CharArrayUtil.regionMatches(chars, caretOffset - "{}".length, "{}") || CharArrayUtil.regionMatches(chars, caretOffset - "{\n}".length, "{\n}")) { commit(editor) - val settings = CodeStyleSettingsManager.getSettings(file.getProject()) + val settings = CodeStyleSettingsManager.getSettings(file.project) val old = settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false val elt = file.findElementAt(caretOffset - 1)!!.getStrictParentOfType() @@ -103,48 +103,48 @@ public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { reformat(elt) } settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = old - editor.getCaretModel().moveToOffset(caretOffset - 1) + editor.caretModel.moveToOffset(caretOffset - 1) } } - public fun registerUnresolvedError(offset: Int) { + fun registerUnresolvedError(offset: Int) { if (myFirstErrorOffset > offset) { myFirstErrorOffset = offset } } private fun PsiElement.isKotlinStatement() = when { - getParent() is KtBlockExpression && getNode()?.getElementType() !in BRACES -> true - getParent()?.getNode()?.getElementType() in BRANCH_CONTAINERS && this !is KtBlockExpression -> true + parent is KtBlockExpression && node?.elementType !in BRACES -> true + parent?.node?.elementType in BRANCH_CONTAINERS && this !is KtBlockExpression -> true else -> false } class KotlinPlainEnterProcessor : SmartEnterProcessorWithFixers.FixEnterProcessor() { private fun getControlStatementBlock(caret: Int, element: PsiElement): KtExpression? { when (element) { - is KtDeclarationWithBody -> return element.getBodyExpression() + is KtDeclarationWithBody -> return element.bodyExpression is KtIfExpression -> { - if (element.getThen().isWithCaret(caret)) return element.getThen() - if (element.getElse().isWithCaret(caret)) return element.getElse() + if (element.then.isWithCaret(caret)) return element.then + if (element.`else`.isWithCaret(caret)) return element.`else` } - is KtLoopExpression -> return element.getBody() + is KtLoopExpression -> return element.body } return null } override fun doEnter(atCaret: PsiElement, file: PsiFile?, editor: Editor, modified: Boolean): Boolean { - val block = getControlStatementBlock(editor.getCaretModel().getOffset(), atCaret) as? KtBlockExpression + val block = getControlStatementBlock(editor.caretModel.offset, atCaret) as? KtBlockExpression if (block != null) { - val firstElement = block.getFirstChild()?.getNextSibling() + val firstElement = block.firstChild?.nextSibling val offset = if (firstElement != null) { - firstElement.getTextRange()!!.getStartOffset() - 1 + firstElement.textRange!!.startOffset - 1 } else { - block.getTextRange()!!.getEndOffset() + block.textRange!!.endOffset } - editor.getCaretModel().moveToOffset(offset) + editor.caretModel.moveToOffset(offset) } plainEnter(editor) @@ -155,4 +155,4 @@ public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { private val BRANCH_CONTAINERS = TokenSet.create(KtNodeTypes.THEN, KtNodeTypes.ELSE, KtNodeTypes.BODY) private val BRACES = TokenSet.create(KtTokens.RBRACE, KtTokens.LBRACE) -private fun KtParameter.isInLambdaExpression() = this.getParent()?.getParent() is KtFunctionLiteral +private fun KtParameter.isInLambdaExpression() = this.parent?.parent is KtFunctionLiteral diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinDoWhileFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinDoWhileFixer.kt index c6201ca1c3e..55282f713e0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinDoWhileFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinDoWhileFixer.kt @@ -23,15 +23,15 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtDoWhileExpression import org.jetbrains.kotlin.psi.KtBlockExpression -public class KotlinDoWhileFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinDoWhileFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) { if (psiElement !is KtDoWhileExpression) return - val doc = editor.getDocument() + val doc = editor.document val start = psiElement.range.start - val body = psiElement.getBody() + val body = psiElement.body - val whileKeyword = psiElement.getWhileKeyword() + val whileKeyword = psiElement.whileKeyword if (body == null) { if (whileKeyword == null) { doc.replaceString(start, start + "do".length, "do {} while()") @@ -48,9 +48,9 @@ public class KotlinDoWhileFixer : SmartEnterProcessorWithFixers.Fixer doc.insertString(psiElement.range.end, "while()") diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt index e555eaaa752..ec786701ea4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt @@ -19,12 +19,12 @@ package org.jetbrains.kotlin.idea.editor.fixers import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtForExpression -public class KotlinForConditionFixer: MissingConditionFixer() { +class KotlinForConditionFixer: MissingConditionFixer() { override val keyword = "for" override fun getElement(element: PsiElement?) = element as? KtForExpression override fun getCondition(element: KtForExpression) = - element.getLoopRange() ?: element.getLoopParameter() ?: element.getDestructuringParameter() - override fun getLeftParenthesis(element: KtForExpression) = element.getLeftParenthesis() - override fun getRightParenthesis(element: KtForExpression) = element.getRightParenthesis() - override fun getBody(element: KtForExpression) = element.getBody() + element.loopRange ?: element.loopParameter ?: element.destructuringParameter + override fun getLeftParenthesis(element: KtForExpression) = element.leftParenthesis + override fun getRightParenthesis(element: KtForExpression) = element.rightParenthesis + override fun getBody(element: KtForExpression) = element.body } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionDeclarationBodyFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionDeclarationBodyFixer.kt index 71901f1ae50..d83c85b6e6b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionDeclarationBodyFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionDeclarationBodyFixer.kt @@ -28,10 +28,10 @@ import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -public class KotlinFunctionDeclarationBodyFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinFunctionDeclarationBodyFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) { if (psiElement !is KtNamedFunction) return - if (psiElement.getBodyExpression() != null|| psiElement.getEqualsToken() != null) return + if (psiElement.bodyExpression != null || psiElement.equalsToken != null) return val parentDeclaration = psiElement.getStrictParentOfType() if (parentDeclaration is KtClassOrObject) { @@ -40,7 +40,7 @@ public class KotlinFunctionDeclarationBodyFixer : SmartEnterProcessorWithFixers. } } - val doc = editor.getDocument() + val doc = editor.document var endOffset = psiElement.range.end if (psiElement.getText()?.last() == ';') { diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionParametersFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionParametersFixer.kt index 4cb5cae0a08..9110bd1c06c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionParametersFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinFunctionParametersFixer.kt @@ -23,28 +23,28 @@ import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.psi.KtNamedFunction -public class KotlinFunctionParametersFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinFunctionParametersFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) { if (psiElement !is KtNamedFunction) return; - val parameterList = psiElement.getValueParameterList() + val parameterList = psiElement.valueParameterList if (parameterList == null) { - val identifier = psiElement.getNameIdentifier() + val identifier = psiElement.nameIdentifier if (identifier == null) return // Insert () after name or after type parameters list when it placed after name - val offset = Math.max(identifier.range.end, psiElement.getTypeParameterList()?.range?.end ?: psiElement.range.start) - editor.getDocument().insertString(offset, "()") + val offset = Math.max(identifier.range.end, psiElement.typeParameterList?.range?.end ?: psiElement.range.start) + editor.document.insertString(offset, "()") processor.registerUnresolvedError(offset + 1) } else { - val rParen = parameterList.getLastChild() + val rParen = parameterList.lastChild if (rParen == null) return - if (")" != rParen.getText()) { - val params = parameterList.getParameters() + if (")" != rParen.text) { + val params = parameterList.parameters val offset = if (params.isEmpty()) parameterList.range.start + 1 else params.last().range.end - editor.getDocument().insertString(offset, ")") + editor.document.insertString(offset, ")") } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinIfConditionFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinIfConditionFixer.kt index 47e0847ccbd..c5f1946e6d7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinIfConditionFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinIfConditionFixer.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.idea.editor.fixers import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtIfExpression -public class KotlinIfConditionFixer : MissingConditionFixer() { +class KotlinIfConditionFixer : MissingConditionFixer() { override val keyword = "if" override fun getElement(element: PsiElement?) = element as? KtIfExpression - override fun getCondition(element: KtIfExpression) = element.getCondition() - override fun getLeftParenthesis(element: KtIfExpression) = element.getLeftParenthesis() - override fun getRightParenthesis(element: KtIfExpression) = element.getRightParenthesis() - override fun getBody(element: KtIfExpression) = element.getThen() + override fun getCondition(element: KtIfExpression) = element.condition + override fun getLeftParenthesis(element: KtIfExpression) = element.leftParenthesis + override fun getRightParenthesis(element: KtIfExpression) = element.rightParenthesis + override fun getBody(element: KtIfExpression) = element.then } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingForOrWhileBodyFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingForOrWhileBodyFixer.kt index ed847e8a4c5..041f7271a89 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingForOrWhileBodyFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingForOrWhileBodyFixer.kt @@ -25,26 +25,26 @@ import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtLoopExpression import org.jetbrains.kotlin.psi.KtForExpression -public class KotlinMissingForOrWhileBodyFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinMissingForOrWhileBodyFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, element: PsiElement) { if (!(element is KtForExpression || element is KtWhileExpression)) return val loopExpression = element as KtLoopExpression - val doc = editor.getDocument() + val doc = editor.document - val body = loopExpression.getBody() + val body = loopExpression.body if (body is KtBlockExpression) return if (!loopExpression.isValidLoopCondition()) return if (body != null && body.startLine(doc) == loopExpression.startLine(doc)) return - val rParen = loopExpression.getRightParenthesis() + val rParen = loopExpression.rightParenthesis if (rParen == null) return doc.insertString(rParen.range.end, "{}") } - fun KtLoopExpression.isValidLoopCondition() = getLeftParenthesis() != null && getRightParenthesis() != null + fun KtLoopExpression.isValidLoopCondition() = leftParenthesis != null && rightParenthesis != null } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingIfBranchFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingIfBranchFixer.kt index c48e87d7730..ccd496107b6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingIfBranchFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingIfBranchFixer.kt @@ -23,30 +23,30 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtIfExpression import org.jetbrains.kotlin.psi.KtBlockExpression -public class KotlinMissingIfBranchFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinMissingIfBranchFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, element: PsiElement) { if (element !is KtIfExpression) return - val document = editor.getDocument() - val elseBranch = element.getElse() - val elseKeyword = element.getElseKeyword() + val document = editor.document + val elseBranch = element.`else` + val elseKeyword = element.elseKeyword if (elseKeyword != null) { - if (elseBranch == null || elseBranch !is KtBlockExpression && elseBranch.startLine(editor.getDocument()) > elseKeyword.startLine(editor.getDocument())) { + if (elseBranch == null || elseBranch !is KtBlockExpression && elseBranch.startLine(editor.document) > elseKeyword.startLine(editor.document)) { document.insertString(elseKeyword.range.end, "{}") return } } - val thenBranch = element.getThen() + val thenBranch = element.then if (thenBranch is KtBlockExpression) return - val rParen = element.getRightParenthesis() + val rParen = element.rightParenthesis if (rParen == null) return var transformingOneLiner = false - if (thenBranch != null && thenBranch.startLine(editor.getDocument()) == element.startLine(editor.getDocument())) { - if (element.getCondition() != null) return + if (thenBranch != null && thenBranch.startLine(editor.document) == element.startLine(editor.document)) { + if (element.condition != null) return transformingOneLiner = true } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingWhenBodyFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingWhenBodyFixer.kt index c3a56699aad..a120c7f09b2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingWhenBodyFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinMissingWhenBodyFixer.kt @@ -22,16 +22,16 @@ import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtWhenExpression -public class KotlinMissingWhenBodyFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinMissingWhenBodyFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, element: PsiElement) { if (element !is KtWhenExpression) return - val doc = editor.getDocument() + val doc = editor.document - val openBrace = element.getOpenBrace() - val closeBrace = element.getCloseBrace() + val openBrace = element.openBrace + val closeBrace = element.closeBrace - if (openBrace == null && closeBrace == null && element.getEntries().isEmpty()) { + if (openBrace == null && closeBrace == null && element.entries.isEmpty()) { val openBraceAfter = element.insertOpenBraceAfter() if (openBraceAfter != null) { doc.insertString(openBraceAfter.range.end, "{}") @@ -40,9 +40,9 @@ public class KotlinMissingWhenBodyFixer : SmartEnterProcessorWithFixers.Fixer getRightParenthesis() - getSubjectExpression() != null -> null - getLeftParenthesis() != null -> null - else -> getWhenKeyword() + rightParenthesis != null -> rightParenthesis + subjectExpression != null -> null + leftParenthesis != null -> null + else -> whenKeyword } } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhenSubjectCaretFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhenSubjectCaretFixer.kt index a220c89e17b..8a694d53bb7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhenSubjectCaretFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhenSubjectCaretFixer.kt @@ -22,13 +22,13 @@ import org.jetbrains.kotlin.idea.editor.KotlinSmartEnterHandler import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.psi.KtWhenExpression -public class KotlinWhenSubjectCaretFixer : SmartEnterProcessorWithFixers.Fixer() { +class KotlinWhenSubjectCaretFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, element: PsiElement) { if (element !is KtWhenExpression) return - val lParen = element.getLeftParenthesis() - val rParen = element.getRightParenthesis() - val subject = element.getSubjectExpression() + val lParen = element.leftParenthesis + val rParen = element.rightParenthesis + val subject = element.subjectExpression if (subject == null && lParen != null && rParen != null) { processor.registerUnresolvedError(lParen.range.end) diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhileConditionFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhileConditionFixer.kt index 652f951658c..8d59d69bb56 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhileConditionFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinWhileConditionFixer.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.idea.editor.fixers import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtWhileExpression -public class KotlinWhileConditionFixer: MissingConditionFixer() { +class KotlinWhileConditionFixer: MissingConditionFixer() { override val keyword = "while" override fun getElement(element: PsiElement?) = element as? KtWhileExpression - override fun getCondition(element: KtWhileExpression) = element.getCondition() - override fun getLeftParenthesis(element: KtWhileExpression) = element.getLeftParenthesis() - override fun getRightParenthesis(element: KtWhileExpression) = element.getRightParenthesis() - override fun getBody(element: KtWhileExpression) = element.getBody() + override fun getCondition(element: KtWhileExpression) = element.condition + override fun getLeftParenthesis(element: KtWhileExpression) = element.leftParenthesis + override fun getRightParenthesis(element: KtWhileExpression) = element.rightParenthesis + override fun getBody(element: KtWhileExpression) = element.body } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/MissingConditionFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/MissingConditionFixer.kt index 2944a7d6ab0..fb9ae96f322 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/MissingConditionFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/MissingConditionFixer.kt @@ -26,7 +26,7 @@ abstract class MissingConditionFixer() : SmartEnterProcessorWithF val workElement = getElement(element) if (workElement == null) return - val doc = editor.getDocument() + val doc = editor.document val lParen = getLeftParenthesis(workElement) val rParen = getRightParenthesis(workElement) val condition = getCondition(workElement) diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/fixersUtil.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/fixersUtil.kt index 1a9055562f8..21a7a4dd95f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/fixersUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/fixersUtil.kt @@ -20,9 +20,9 @@ import com.intellij.psi.PsiElement import com.intellij.openapi.util.TextRange import com.intellij.openapi.editor.Document -val PsiElement.range: TextRange get() = getTextRange()!! -val TextRange.start: Int get() = getStartOffset() -val TextRange.end: Int get() = getEndOffset() +val PsiElement.range: TextRange get() = textRange!! +val TextRange.start: Int get() = startOffset +val TextRange.end: Int get() = endOffset fun PsiElement.startLine(doc: Document): Int = doc.getLineNumber(range.start) -fun PsiElement?.isWithCaret(caret: Int) = this?.getTextRange()?.contains(caret) == true +fun PsiElement?.isWithCaret(caret: Int) = this?.textRange?.contains(caret) == true diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinCodeBlockSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinCodeBlockSelectioner.kt index 6fd5d0f6ac3..a7ae72e8c15 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinCodeBlockSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinCodeBlockSelectioner.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset /** * Originally from IDEA platform: CodeBlockOrInitializerSelectioner */ -public class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() { +class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() { override fun canSelect(e: PsiElement) = e is KtBlockExpression || e is KtWhenExpression @@ -47,14 +47,14 @@ public class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() { result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(start, end))) } - result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, e.getTextRange()!!)) + result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, e.textRange!!)) return result } private fun findBlockContentStart(block: PsiElement): Int { val element = block.allChildren - .dropWhile { it.getNode().getElementType() != KtTokens.LBRACE } // search for '{' + .dropWhile { it.node.elementType != KtTokens.LBRACE } // search for '{' .drop(1) // skip it .dropWhile { it is PsiWhiteSpace } // and skip all whitespaces .firstOrNull() ?: block @@ -66,7 +66,7 @@ public class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() { .toList() .asReversed() .asSequence() - .dropWhile { it.getNode().getElementType() != KtTokens.RBRACE } // search for '}' + .dropWhile { it.node.elementType != KtTokens.RBRACE } // search for '}' .drop(1) // skip it .dropWhile { it is PsiWhiteSpace } // and skip all whitespaces .firstOrNull() ?: block diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt index 71c7be2630f..6c91adb39c0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtDestructuringDeclaration import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class KotlinDeclarationSelectioner : ExtendWordSelectionHandlerBase() { +class KotlinDeclarationSelectioner : ExtendWordSelectionHandlerBase() { override fun canSelect(e: PsiElement) = e is KtDeclaration @@ -39,12 +39,12 @@ public class KotlinDeclarationSelectioner : ExtendWordSelectionHandlerBase() { } val result = ArrayList() - val firstChild = e.getFirstChild() + val firstChild = e.firstChild val firstNonComment = firstChild .siblings(forward = true, withItself = true) .first { it !is PsiComment && it !is PsiWhiteSpace } - val lastChild = e.getLastChild() + val lastChild = e.lastChild val lastNonComment = lastChild .siblings(forward = false, withItself = true) .first { it !is PsiComment && it !is PsiWhiteSpace } @@ -53,7 +53,7 @@ public class KotlinDeclarationSelectioner : ExtendWordSelectionHandlerBase() { result.addRange(editorText, TextRange(firstNonComment.startOffset, lastNonComment.endOffset)) } - result.addRange(editorText, e.getTextRange()) + result.addRange(editorText, e.textRange) return result } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDocCommentSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDocCommentSelectioner.kt index a612b1c4649..a4241f7c4eb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDocCommentSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDocCommentSelectioner.kt @@ -23,11 +23,11 @@ import com.intellij.psi.PsiElement import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase import org.jetbrains.kotlin.kdoc.psi.api.KDoc -public class KotlinDocCommentSelectioner : ExtendWordSelectionHandlerBase() { +class KotlinDocCommentSelectioner : ExtendWordSelectionHandlerBase() { override fun canSelect(e: PsiElement) = e is KDoc override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { - return ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, e.getTextRange()) + return ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, e.textRange) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinListSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinListSelectioner.kt index c6f98cb997b..6de0a1c8102 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinListSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinListSelectioner.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtValueArgumentList import org.jetbrains.kotlin.lexer.KtTokens import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase -public class KotlinListSelectioner : ExtendWordSelectionHandlerBase() { +class KotlinListSelectioner : ExtendWordSelectionHandlerBase() { companion object { fun canSelect(e: PsiElement) = e is KtParameterList || e is KtValueArgumentList || e is KtTypeParameterList || e is KtTypeArgumentList @@ -36,13 +36,13 @@ public class KotlinListSelectioner : ExtendWordSelectionHandlerBase() { override fun canSelect(e: PsiElement) = KotlinListSelectioner.canSelect(e) override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { - val node = e.getNode()!! + val node = e.node!! val startNode = node.findChildByType(TokenSet.create(KtTokens.LPAR, KtTokens.LT)) ?: return null val endNode = node.findChildByType(TokenSet.create(KtTokens.RPAR, KtTokens.GT)) ?: return null - val innerRange = TextRange(startNode.getStartOffset() + 1, endNode.getStartOffset()) + val innerRange = TextRange(startNode.startOffset + 1, endNode.startOffset) if (e is KtTypeArgumentList || e is KtTypeParameterList) { return listOf(innerRange, - TextRange(startNode.getStartOffset(), endNode.getStartOffset() + endNode.getTextLength())) + TextRange(startNode.startOffset, endNode.startOffset + endNode.textLength)) } return listOf(innerRange) } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStatementGroupSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStatementGroupSelectioner.kt index 9b9784cac24..c8dace7d6bc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStatementGroupSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStatementGroupSelectioner.kt @@ -31,34 +31,34 @@ import org.jetbrains.kotlin.psi.* /** * Originally from IDEA platform: StatementGroupSelectioner */ -public class KotlinStatementGroupSelectioner : ExtendWordSelectionHandlerBase() { +class KotlinStatementGroupSelectioner : ExtendWordSelectionHandlerBase() { override fun canSelect(e: PsiElement): Boolean { if (e !is KtExpression && e !is KtWhenEntry && e !is PsiComment) return false - val parent = e.getParent() + val parent = e.parent return parent is KtBlockExpression || parent is KtWhenExpression || parent is KtFunctionLiteral } override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { - val parent = e.getParent() + val parent = e.parent val startElement = e.siblings(forward = false, withItself = false) .firstOrNull { // find preceding '{' or blank line - it is LeafPsiElement && it.getElementType() == KtTokens.LBRACE || - it is PsiWhiteSpace && it.getText()!!.count { it == '\n' } > 1 + it is LeafPsiElement && it.elementType == KtTokens.LBRACE || + it is PsiWhiteSpace && it.getText()!!.count { it == '\n' } > 1 } ?.siblings(forward = true, withItself = false) ?.dropWhile { it is PsiWhiteSpace } // and take first non-whitespace element after it - ?.firstOrNull() ?: parent.getFirstChild()!! + ?.firstOrNull() ?: parent.firstChild!! val endElement = e.siblings(forward = true, withItself = false) .firstOrNull { // find next '}' or blank line - it is LeafPsiElement && it.getElementType() == KtTokens.RBRACE || - it is PsiWhiteSpace && it.getText()!!.count { it == '\n' } > 1 + it is LeafPsiElement && it.elementType == KtTokens.RBRACE || + it is PsiWhiteSpace && it.getText()!!.count { it == '\n' } > 1 } ?.siblings(forward = false, withItself = false) ?.dropWhile { it is PsiWhiteSpace } // and take first non-whitespace element before it - ?.firstOrNull() ?: parent.getLastChild()!! + ?.firstOrNull() ?: parent.lastChild!! - return ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(startElement.getTextRange()!!.getStartOffset(), endElement.getTextRange()!!.getEndOffset())) + return ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(startElement.textRange!!.startOffset, endElement.textRange!!.endOffset)) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStringLiteralSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStringLiteralSelectioner.kt index a19d10655c9..e9eed759d78 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStringLiteralSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinStringLiteralSelectioner.kt @@ -24,11 +24,11 @@ import org.jetbrains.kotlin.psi.KtStringTemplateExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class KotlinStringLiteralSelectioner : ExtendWordSelectionHandlerBase() { +class KotlinStringLiteralSelectioner : ExtendWordSelectionHandlerBase() { override fun canSelect(e: PsiElement) = e is KtStringTemplateExpression override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { - val entries = (e as KtStringTemplateExpression).getEntries() + val entries = (e as KtStringTemplateExpression).entries if (entries.isEmpty()) return null val start = entries.first().startOffset val end = entries.last().endOffset diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt index 3ca679f1985..854758aa455 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt @@ -23,15 +23,15 @@ import org.jetbrains.kotlin.psi.KtContainerNode import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.kdoc.parser.KDocElementTypes -public class KotlinWordSelectionFilter : Condition{ +class KotlinWordSelectionFilter : Condition{ override fun value(e: PsiElement): Boolean { - if (e.getLanguage() != KotlinLanguage.INSTANCE) return true + if (e.language != KotlinLanguage.INSTANCE) return true if (KotlinListSelectioner.canSelect(e)) return false if (e is KtContainerNode) return false - if (e.getParent().getFirstChild().getNextSibling() == null && e.getParent() !is KtContainerNode) return false // skip nodes with the same range as their parent + if (e.parent.firstChild.nextSibling == null && e.parent !is KtContainerNode) return false // skip nodes with the same range as their parent - return when (e.getNode().getElementType()) { + return when (e.node.elementType) { BLOCK, KDocElementTypes.KDOC_SECTION -> false else -> true } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinDeclarationGroupRuleProvider.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinDeclarationGroupRuleProvider.kt index 265345ff48b..f2ae44952b5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinDeclarationGroupRuleProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinDeclarationGroupRuleProvider.kt @@ -27,13 +27,13 @@ import org.jetbrains.kotlin.psi.KtFile import com.intellij.usages.impl.FileStructureGroupRuleProvider import com.intellij.openapi.project.Project -public class KotlinDeclarationGroupRuleProvider : FileStructureGroupRuleProvider { - public class KotlinDeclarationGroupingRule : UsageGroupingRule { +class KotlinDeclarationGroupRuleProvider : FileStructureGroupRuleProvider { + class KotlinDeclarationGroupingRule : UsageGroupingRule { override fun groupUsage(usage: Usage): UsageGroup? { - val element = (usage as? PsiElementUsage)?.getElement() + val element = (usage as? PsiElementUsage)?.element if (element == null) return null - val containingFile = element.getContainingFile() + val containingFile = element.containingFile if (containingFile !is KtFile) return null return PsiTreeUtil.getTopmostParentOfType(element, KtNamedDeclaration::class.java)?.let { container -> diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt index cd6041393d3..d7c2834fa3b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt @@ -31,8 +31,8 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils -public class KotlinElementDescriptionProvider : ElementDescriptionProvider { - public override fun getElementDescription(element: PsiElement, location: ElementDescriptionLocation): String? { +class KotlinElementDescriptionProvider : ElementDescriptionProvider { + override fun getElementDescription(element: PsiElement, location: ElementDescriptionLocation): String? { val targetElement = element.unwrapped fun elementKind() = when (targetElement) { @@ -40,7 +40,7 @@ public class KotlinElementDescriptionProvider : ElementDescriptionProvider { is KtObjectDeclaration -> "object" is KtNamedFunction -> "function" is KtSecondaryConstructor -> "constructor" - is KtProperty -> if (targetElement.isLocal()) "variable" else "property" + is KtProperty -> if (targetElement.isLocal) "variable" else "property" is KtTypeParameter -> "type parameter" is KtParameter -> "parameter" is KtDestructuringDeclarationEntry -> "variable" @@ -50,7 +50,7 @@ public class KotlinElementDescriptionProvider : ElementDescriptionProvider { fun targetDescriptor(): DeclarationDescriptor? { val descriptor = (targetElement as KtDeclaration).descriptor ?: return null if (descriptor is ConstructorDescriptor) { - return descriptor.getContainingDeclaration() + return descriptor.containingDeclaration } return descriptor } @@ -67,7 +67,7 @@ public class KotlinElementDescriptionProvider : ElementDescriptionProvider { DescriptorUtils.getFqName(descriptor).asString() } else { - descriptor.getName().asString() + descriptor.name.asString() } "$kind ${CommonRefactoringUtil.htmlEmphasize(desc)}" @@ -75,7 +75,7 @@ public class KotlinElementDescriptionProvider : ElementDescriptionProvider { is HighlightUsagesDescriptionLocation -> { val kind = elementKind() ?: return null val descriptor = targetDescriptor() ?: return null - "$kind ${descriptor.getName().asString()}" + "$kind ${descriptor.name.asString()}" } else -> null } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt index c3b54d16629..820df8c40bf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt @@ -39,15 +39,15 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.isOverridable import org.jetbrains.kotlin.psi.psiUtil.parameterIndex -public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactory() { +class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactory() { val javaHandlerFactory = JavaFindUsagesHandlerFactory(project) - public val findFunctionOptions: KotlinFunctionFindUsagesOptions = KotlinFunctionFindUsagesOptions(project) + val findFunctionOptions: KotlinFunctionFindUsagesOptions = KotlinFunctionFindUsagesOptions(project) val findPropertyOptions = KotlinPropertyFindUsagesOptions(project) val findClassOptions = KotlinClassFindUsagesOptions(project) val defaultOptions = FindUsagesOptions(project) - public override fun canFindUsages(element: PsiElement): Boolean = + override fun canFindUsages(element: PsiElement): Boolean = element is KtClassOrObject || element is KtNamedFunction || element is KtProperty || @@ -55,11 +55,11 @@ public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandle element is KtTypeParameter || element is KtConstructor<*> - public fun createFindUsagesHandlerNoQuestions(element: PsiElement): FindUsagesHandler { + fun createFindUsagesHandlerNoQuestions(element: PsiElement): FindUsagesHandler { return createFindUsagesHandler(element, forHighlightUsages = false, canAsk = false) } - public override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler { + override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler { return createFindUsagesHandler(element, forHighlightUsages, canAsk = !forHighlightUsages) } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinImportFilteringRule.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinImportFilteringRule.kt index 371efaa5092..ad439b76f2e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinImportFilteringRule.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinImportFilteringRule.kt @@ -22,10 +22,10 @@ import com.intellij.usages.rules.PsiElementUsage import org.jetbrains.kotlin.psi.KtImportDirective import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType -public class KotlinImportFilteringRule : ImportFilteringRule() { - public override fun isVisible(usage: Usage): Boolean { +class KotlinImportFilteringRule : ImportFilteringRule() { + override fun isVisible(usage: Usage): Boolean { if (usage is PsiElementUsage) { - return usage.getElement()?.getNonStrictParentOfType() == null + return usage.element?.getNonStrictParentOfType() == null } return true diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt index 9a846f7e005..ad7882ead0a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt @@ -20,11 +20,11 @@ import com.intellij.psi.PsiReference import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -public class KotlinReferenceUsageInfo(reference: PsiReference) : UsageInfo(reference) { +class KotlinReferenceUsageInfo(reference: PsiReference) : UsageInfo(reference) { private val referenceType = reference.javaClass override fun getReference(): PsiReference? { - val element = getElement() ?: return null - return element.getReferences().singleOrNull { it.javaClass == referenceType } + val element = element ?: return null + return element.references.singleOrNull { it.javaClass == referenceType } } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypeProvider.kt index 38b2c1eb307..d0944aa51bc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypeProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypeProvider.kt @@ -23,12 +23,12 @@ import com.intellij.usages.impl.rules.UsageTypeProviderEx import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.findUsages.UsageTypeEnum.* -public object KotlinUsageTypeProvider : UsageTypeProviderEx { - public override fun getUsageType(element: PsiElement?): UsageType? { +object KotlinUsageTypeProvider : UsageTypeProviderEx { + override fun getUsageType(element: PsiElement?): UsageType? { return getUsageType(element, UsageTarget.EMPTY_ARRAY) } - public override fun getUsageType(element: PsiElement?, targets: Array): UsageType? { + override fun getUsageType(element: PsiElement?, targets: Array): UsageType? { val usageType = UsageTypeUtils.getUsageType(element) if (usageType == null) return null return convertEnumToUsageType(usageType) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/findUsagesOptions.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/findUsagesOptions.kt index 597cf7029db..d713e335eb4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/findUsagesOptions.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/findUsagesOptions.kt @@ -22,25 +22,25 @@ import com.intellij.find.findUsages.JavaMethodFindUsagesOptions import com.intellij.find.findUsages.JavaVariableFindUsagesOptions import com.intellij.openapi.project.Project -public class KotlinClassFindUsagesOptions(project: Project) : JavaClassFindUsagesOptions(project) { - public var searchConstructorUsages: Boolean = true +class KotlinClassFindUsagesOptions(project: Project) : JavaClassFindUsagesOptions(project) { + var searchConstructorUsages: Boolean = true - public override fun equals(o: Any?): Boolean { + override fun equals(o: Any?): Boolean { return super.equals(o) && o is KotlinClassFindUsagesOptions && o.searchConstructorUsages == searchConstructorUsages } - public override fun hashCode(): Int { + override fun hashCode(): Int { return 31 * super.hashCode() + if (searchConstructorUsages) 1 else 0 } } -public interface KotlinCallableFindUsagesOptions { - public var searchOverrides: Boolean +interface KotlinCallableFindUsagesOptions { + var searchOverrides: Boolean fun toJavaOptions(project: Project): FindUsagesOptions? } -public class KotlinFunctionFindUsagesOptions(project: Project): KotlinCallableFindUsagesOptions, JavaMethodFindUsagesOptions(project) { +class KotlinFunctionFindUsagesOptions(project: Project): KotlinCallableFindUsagesOptions, JavaMethodFindUsagesOptions(project) { override var searchOverrides: Boolean get() = isOverridingMethods set(value: Boolean) { @@ -64,7 +64,7 @@ public class KotlinFunctionFindUsagesOptions(project: Project): KotlinCallableFi } } -public class KotlinPropertyFindUsagesOptions(project: Project): KotlinCallableFindUsagesOptions, JavaVariableFindUsagesOptions(project) { +class KotlinPropertyFindUsagesOptions(project: Project): KotlinCallableFindUsagesOptions, JavaVariableFindUsagesOptions(project) { override var searchOverrides: Boolean = false override fun toJavaOptions(project: Project): JavaVariableFindUsagesOptions { diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt index 572f41cc7e3..83b344fdf96 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt @@ -56,16 +56,16 @@ class DelegatingFindMemberUsagesHandler( } override fun getFindUsagesDialog(isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean): AbstractFindUsagesDialog { - return getHandlerAndOptions(getPsiElement(), null)?.handler?.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab) + return getHandlerAndOptions(psiElement, null)?.handler?.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab) ?: super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab) } override fun getPrimaryElements(): Array { - return kotlinHandler.getPrimaryElements() + return kotlinHandler.primaryElements } override fun getSecondaryElements(): Array { - return kotlinHandler.getSecondaryElements() + return kotlinHandler.secondaryElements } override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt index fb04c421114..014551bff6b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt @@ -56,15 +56,15 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver import java.util.* -public class KotlinFindClassUsagesHandler( +class KotlinFindClassUsagesHandler( ktClass: KtClassOrObject, factory: KotlinFindUsagesHandlerFactory ) : KotlinFindUsagesHandler(ktClass, factory) { - public override fun getFindUsagesDialog( + override fun getFindUsagesDialog( isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean ): AbstractFindUsagesDialog { return KotlinFindClassUsagesDialog(getElement(), - getProject(), + project, factory.findClassOptions, toShowInNewTab, mustOpenInNewTab, @@ -72,7 +72,7 @@ public class KotlinFindClassUsagesHandler( this) } - protected override fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { + override fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { val kotlinOptions = options as KotlinClassFindUsagesOptions fun processInheritors(): Boolean { @@ -80,11 +80,11 @@ public class KotlinFindClassUsagesHandler( return request.searchInheritors().forEach( PsiElementProcessorAdapter( object : PsiElementProcessor { - public override fun execute(element: PsiClass): Boolean { - val isInterface = element.isInterface() + override fun execute(element: PsiClass): Boolean { + val isInterface = element.isInterface return when { isInterface && options.isDerivedInterfaces || !isInterface && options.isDerivedClasses -> - KotlinFindUsagesHandler.processUsage(processor, element.getNavigationElement()) + KotlinFindUsagesHandler.processUsage(processor, element.navigationElement) else -> true } } @@ -112,10 +112,10 @@ public class KotlinFindClassUsagesHandler( if (kotlinOptions.searchConstructorUsages) { val result = runReadAction { - val constructors = classOrObject.toLightClass()?.getConstructors() ?: PsiMethod.EMPTY_ARRAY + val constructors = classOrObject.toLightClass()?.constructors ?: PsiMethod.EMPTY_ARRAY constructors.filterIsInstance().all { constructor -> - constructor.processDelegationCallConstructorUsages(constructor.getUseScope().intersectWith(options.searchScope)) { - it.getCalleeExpression()?.mainReference?.let { referenceProcessor.process(it) } ?: false + constructor.processDelegationCallConstructorUsages(constructor.useScope.intersectWith(options.searchScope)) { + it.calleeExpression?.mainReference?.let { referenceProcessor.process(it) } ?: false } } } @@ -164,9 +164,9 @@ public class KotlinFindClassUsagesHandler( val bindingContext = element.analyze() val resolvedCall = bindingContext[BindingContext.CALL, element]?.getResolvedCall(bindingContext) ?: return - if ((resolvedCall.getDispatchReceiver() as? ImplicitClassReceiver)?.declarationDescriptor == companionObjectDescriptor - || (resolvedCall.getExtensionReceiver() as? ImplicitClassReceiver)?.declarationDescriptor == companionObjectDescriptor) { - element.getReferences().forEach { + if ((resolvedCall.dispatchReceiver as? ImplicitClassReceiver)?.declarationDescriptor == companionObjectDescriptor + || (resolvedCall.extensionReceiver as? ImplicitClassReceiver)?.declarationDescriptor == companionObjectDescriptor) { + element.references.forEach { if (!stop && !processor.process(it)) { stop = true } @@ -190,7 +190,7 @@ public class KotlinFindClassUsagesHandler( return true } - protected override fun getStringsToSearch(element: PsiElement): Collection { + override fun getStringsToSearch(element: PsiElement): Collection { val psiClass = when (element) { is PsiClass -> element is KtClassOrObject -> LightClassUtil.getPsiClass(getElement()) @@ -200,11 +200,11 @@ public class KotlinFindClassUsagesHandler( return JavaFindUsagesHelper.getElementNames(psiClass) } - protected override fun isSearchForTextOccurencesAvailable(psiElement: PsiElement, isSingleFile: Boolean): Boolean { + override fun isSearchForTextOccurencesAvailable(psiElement: PsiElement, isSingleFile: Boolean): Boolean { return !isSingleFile } - public override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { + override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { return factory.findClassOptions } } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt index 3f3f9edf83a..650c6c30328 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt @@ -51,7 +51,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.resolve.findOriginalTopMostOverriddenDescriptors import org.jetbrains.kotlin.resolve.source.getPsi -public abstract class KotlinFindMemberUsagesHandler +abstract class KotlinFindMemberUsagesHandler protected constructor(declaration: T, elementsToSearch: Collection, factory: KotlinFindUsagesHandlerFactory) : KotlinFindUsagesHandler(declaration, elementsToSearch, factory) { @@ -65,7 +65,7 @@ public abstract class KotlinFindMemberUsagesHandler val options = factory.findFunctionOptions val lightMethod = getElement().toLightMethods().firstOrNull() if (lightMethod != null) { - return KotlinFindFunctionUsagesDialog(lightMethod, getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) + return KotlinFindFunctionUsagesDialog(lightMethod, project, options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) } return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab) @@ -90,7 +90,7 @@ public abstract class KotlinFindMemberUsagesHandler override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions = factory.findPropertyOptions override fun getFindUsagesDialog(isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean): AbstractFindUsagesDialog { - return KotlinFindPropertyUsagesDialog(getElement(), getProject(), factory.findPropertyOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) + return KotlinFindPropertyUsagesDialog(getElement(), project, factory.findPropertyOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) } override fun applyQueryFilters(element: PsiElement, options: FindUsagesOptions, query: Query): Query { @@ -147,7 +147,7 @@ public abstract class KotlinFindMemberUsagesHandler if (kotlinOptions.searchOverrides) { for (method in HierarchySearchRequest(element, options.searchScope, true).searchOverriders()) { - if (!KotlinFindUsagesHandler.processUsage(uniqueProcessor, method.getNavigationElement())) break + if (!KotlinFindUsagesHandler.processUsage(uniqueProcessor, method.navigationElement)) break } } @@ -180,7 +180,7 @@ public abstract class KotlinFindMemberUsagesHandler companion object { - public fun getInstance(declaration: KtNamedDeclaration, + fun getInstance(declaration: KtNamedDeclaration, elementsToSearch: Collection = emptyList(), factory: KotlinFindUsagesHandlerFactory): KotlinFindMemberUsagesHandler { return if (declaration is KtFunction) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt index ec8ede44e46..4c160c5de9e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt @@ -32,22 +32,21 @@ import org.jetbrains.kotlin.idea.findUsages.KotlinReferenceUsageInfo import org.jetbrains.kotlin.idea.util.application.runReadAction import java.util.* -public abstract class KotlinFindUsagesHandler(psiElement: T, +abstract class KotlinFindUsagesHandler(psiElement: T, private val elementsToSearch: Collection, - public val factory: KotlinFindUsagesHandlerFactory) + val factory: KotlinFindUsagesHandlerFactory) : FindUsagesHandler(psiElement) { - @Suppress("UNCHECKED_CAST") - public fun getElement(): T { - return getPsiElement() as T + @Suppress("UNCHECKED_CAST") fun getElement(): T { + return psiElement as T } - public constructor(psiElement: T, factory: KotlinFindUsagesHandlerFactory) : this(psiElement, emptyList(), factory) { + constructor(psiElement: T, factory: KotlinFindUsagesHandlerFactory) : this(psiElement, emptyList(), factory) { } override fun getPrimaryElements(): Array { return if (elementsToSearch.isEmpty()) - arrayOf(getPsiElement()) + arrayOf(psiElement) else elementsToSearch.toTypedArray() } @@ -74,12 +73,12 @@ public abstract class KotlinFindUsagesHandler(psiElement: T, override fun findReferencesToHighlight(target: PsiElement, searchScope: SearchScope): Collection { val results = Collections.synchronizedList(arrayListOf()) - val options = getFindUsagesOptions().clone() + val options = findUsagesOptions.clone() options.searchScope = searchScope val scopeContainingFile = (searchScope as? LocalSearchScope)?.scope?.get(0)?.containingFile searchReferences(target, object : Processor { override fun process(info: UsageInfo): Boolean { - val reference = info.getReference() + val reference = info.reference if (reference != null) { if (scopeContainingFile != null && reference.element.containingFile != scopeContainingFile) { LOG.error("findReferencesToHighight() found a reference from a different file: $reference") diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt index 680176fb597..21d8f773ec4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt @@ -27,23 +27,23 @@ import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinTypeParameterFindUsagesDialog import org.jetbrains.kotlin.psi.KtNamedDeclaration -public class KotlinTypeParameterFindUsagesHandler( +class KotlinTypeParameterFindUsagesHandler( element: KtNamedDeclaration, factory: KotlinFindUsagesHandlerFactory ) : KotlinFindUsagesHandler(element, factory) { - public override fun getFindUsagesDialog( + override fun getFindUsagesDialog( isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean ): AbstractFindUsagesDialog { return KotlinTypeParameterFindUsagesDialog( - getElement(), getProject(), getFindUsagesOptions(), toShowInNewTab, mustOpenInNewTab, isSingleFile, this + getElement(), project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, this ) } - protected override fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { + override fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { return ReferencesSearch.search(element, options.searchScope).all { KotlinFindUsagesHandler.processUsage(processor, it ) } } - public override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { + override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { return factory.defaultOptions } } diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/ImportSettingsPanel.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/ImportSettingsPanel.kt index 8574b8cb18c..f6030fa97ea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/ImportSettingsPanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/ImportSettingsPanel.kt @@ -74,7 +74,7 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane private val nameCountToUseStarImportForMembersSelector = NameCountToUseStarImportSelector("Java Statics and Enum Members") init { - setLayout(BorderLayout()) + layout = BorderLayout() add(JBScrollPane(JPanel(GridBagLayout()).apply { val constraints = GridBagConstraints().apply { weightx = 1.0 @@ -101,19 +101,19 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane nameCountToUseStarImportSelector.value = settings.NAME_COUNT_TO_USE_STAR_IMPORT nameCountToUseStarImportForMembersSelector.value = settings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS - cbImportNestedClasses.setSelected(settings.IMPORT_NESTED_CLASSES) + cbImportNestedClasses.isSelected = settings.IMPORT_NESTED_CLASSES starImportPackageEntryTable.copyFrom(settings.PACKAGES_TO_USE_STAR_IMPORTS) - (starImportPackageTable.getModel() as AbstractTableModel).fireTableDataChanged() - if (starImportPackageTable.getRowCount() > 0) { - starImportPackageTable.getSelectionModel().setSelectionInterval(0, 0) + (starImportPackageTable.model as AbstractTableModel).fireTableDataChanged() + if (starImportPackageTable.rowCount > 0) { + starImportPackageTable.selectionModel.setSelectionInterval(0, 0) } } fun apply(settings: KotlinCodeStyleSettings, dropEmptyPackages: Boolean = true) { settings.NAME_COUNT_TO_USE_STAR_IMPORT = nameCountToUseStarImportSelector.value settings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS = nameCountToUseStarImportForMembersSelector.value - settings.IMPORT_NESTED_CLASSES = cbImportNestedClasses.isSelected() + settings.IMPORT_NESTED_CLASSES = cbImportNestedClasses.isSelected if (dropEmptyPackages) { starImportPackageEntryTable.removeEmptyPackages() @@ -126,7 +126,7 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane apply(tempSettings, dropEmptyPackages = false) val root = Element("fake") tempSettings.writeExternal(root, settings) - return root.getChildren().isNotEmpty() + return root.children.isNotEmpty() } private class NameCountToUseStarImportSelector(title: String) : OptionGroup(title) { @@ -154,7 +154,7 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane }, true) fun updateEnabled() { - starImportLimitField.setEnabled(rbUseStarImportsIfAtLeast.isSelected()) + starImportLimitField.isEnabled = rbUseStarImportsIfAtLeast.isSelected } rbUseStarImportsIfAtLeast.addChangeListener { updateEnabled() } updateEnabled() diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt index 2000302381a..b1828a3ede7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt @@ -65,9 +65,9 @@ class KotlinSpacingBuilder(val codeStyleSettings: CodeStyleSettings) { fun inPosition(parent: IElementType? = null, left: IElementType? = null, right: IElementType? = null): CustomSpacingBuilder { conditions.add { p, l, r -> - (parent == null || p.getNode()!!.getElementType() == parent) && - (left == null || l.getNode()!!.getElementType() == left) && - (right == null || r.getNode()!!.getElementType() == right) + (parent == null || p.node!!.elementType == parent) && + (left == null || l.node!!.elementType == left) && + (right == null || r.node!!.elementType == right) } return this } @@ -75,7 +75,7 @@ class KotlinSpacingBuilder(val codeStyleSettings: CodeStyleSettings) { fun lineBreakIfLineBreakInParent(numSpacesOtherwise: Int, allowBlankLines: Boolean = true) { newRule { p, l, r -> - Spacing.createDependentLFSpacing(numSpacesOtherwise, numSpacesOtherwise, p.getTextRange(), + Spacing.createDependentLFSpacing(numSpacesOtherwise, numSpacesOtherwise, p.textRange, codeStyleSettings.KEEP_LINE_BREAKS, if (allowBlankLines) codeStyleSettings.KEEP_BLANK_LINES_IN_CODE else 0) } @@ -89,7 +89,7 @@ class KotlinSpacingBuilder(val codeStyleSettings: CodeStyleSettings) { minimumLineFeeds = numberOfLineFeedsOtherwise, keepLineBreaks = codeStyleSettings.KEEP_LINE_BREAKS, keepBlankLines = codeStyleSettings.KEEP_BLANK_LINES_IN_DECLARATIONS, - dependency = left.getTextRange(), rule = dependentSpacingRule) + dependency = left.textRange, rule = dependentSpacingRule) } } @@ -118,8 +118,8 @@ class KotlinSpacingBuilder(val codeStyleSettings: CodeStyleSettings) { if (spacing != null) { // TODO: it's a severe hack but I don't know how to implement it in other way - if (child1.getNode().getElementType() == KtTokens.EOL_COMMENT && spacing.toString().contains("minLineFeeds=0")) { - val isBeforeBlock = child2.getNode().getElementType() == KtNodeTypes.BLOCK || child2.getNode().getFirstChildNode()?.getElementType() == KtNodeTypes.BLOCK + if (child1.node.elementType == KtTokens.EOL_COMMENT && spacing.toString().contains("minLineFeeds=0")) { + val isBeforeBlock = child2.node.elementType == KtNodeTypes.BLOCK || child2.node.firstChildNode?.elementType == KtNodeTypes.BLOCK val keepBlankLines = if (isBeforeBlock) 0 else codeStyleSettings.KEEP_BLANK_LINES_IN_CODE return Spacing.createSpacing(0, 0, 1, true, keepBlankLines) } diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/SyntheticKotlinBlock.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/SyntheticKotlinBlock.kt index 6717fa5443a..ee065a79fdd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/SyntheticKotlinBlock.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/SyntheticKotlinBlock.kt @@ -27,7 +27,7 @@ import com.intellij.lang.ASTNode import com.intellij.psi.formatter.common.AbstractBlock import com.intellij.formatting.ASTBlock -public class SyntheticKotlinBlock( +class SyntheticKotlinBlock( private val node: ASTNode, private val subBlocks: MutableList, private val alignment: Alignment?, @@ -37,8 +37,8 @@ public class SyntheticKotlinBlock( ) : ASTBlock { private val textRange = TextRange( - subBlocks.first().getTextRange().getStartOffset(), - subBlocks.last().getTextRange().getEndOffset()) + subBlocks.first().textRange.startOffset, + subBlocks.last().textRange.endOffset) override fun getTextRange(): TextRange = textRange override fun getSubBlocks() = subBlocks @@ -46,11 +46,11 @@ public class SyntheticKotlinBlock( override fun getIndent() = indent override fun getAlignment() = alignment override fun getChildAttributes(newChildIndex: Int) = ChildAttributes(getIndent(), null) - override fun isIncomplete() = getSubBlocks().last().isIncomplete() + override fun isIncomplete() = getSubBlocks().last().isIncomplete override fun isLeaf() = false override fun getNode() = node override fun getSpacing(child1: Block?, child2: Block): Spacing? = - spacingBuilder.getSpacing(KotlinSpacingBuilder.SpacingNodeBlock(node.getTreeParent()!!), child1, child2) + spacingBuilder.getSpacing(KotlinSpacingBuilder.SpacingNodeBlock(node.treeParent!!), child1, child2) override fun toString(): String { @@ -60,7 +60,7 @@ public class SyntheticKotlinBlock( loop@ while (treeNode == null) when (child) { is AbstractBlock -> { - treeNode = child.getNode() + treeNode = child.node } is SyntheticKotlinBlock -> { child = child.getSubBlocks().first() @@ -70,15 +70,15 @@ public class SyntheticKotlinBlock( val textRange = getTextRange() if (treeNode != null) { - val psi = treeNode.getPsi() + val psi = treeNode.psi if (psi != null) { - val file = psi.getContainingFile() + val file = psi.containingFile if (file != null) { - return file.getText()!!.subSequence(textRange.getStartOffset(), textRange.getEndOffset()).toString() + " " + textRange + return file.text!!.subSequence(textRange.startOffset, textRange.endOffset).toString() + " " + textRange } } } - return javaClass.getName() + ": " + textRange + return javaClass.name + ": " + textRange } } diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/WrappingStrategy.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/WrappingStrategy.kt index 93c7282c720..f749ce9407f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/WrappingStrategy.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/WrappingStrategy.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.formatter import com.intellij.formatting.Wrap import com.intellij.psi.tree.IElementType -public interface WrappingStrategy { +interface WrappingStrategy { fun getWrap(childElementType: IElementType): Wrap? object NoWrapping: WrappingStrategy { diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 7151f50e0b4..c3df0ce1baf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -36,11 +36,11 @@ import org.jetbrains.kotlin.psi.KtClass val MODIFIERS_LIST_ENTRIES = TokenSet.orSet(TokenSet.create(ANNOTATION_ENTRY, ANNOTATION), MODIFIER_KEYWORDS) fun SpacingBuilder.beforeInside(element: IElementType, tokenSet: TokenSet, spacingFun: RuleBuilder.() -> Unit) { - tokenSet.getTypes().forEach { inType -> beforeInside(element, inType).spacingFun() } + tokenSet.types.forEach { inType -> beforeInside(element, inType).spacingFun() } } fun SpacingBuilder.afterInside(element: IElementType, tokenSet: TokenSet, spacingFun: RuleBuilder.() -> Unit) { - tokenSet.getTypes().forEach { inType -> afterInside(element, inType).spacingFun() } + tokenSet.types.forEach { inType -> afterInside(element, inType).spacingFun() } } fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { @@ -72,7 +72,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { val parameterWithDocCommentRule = { parent: ASTBlock, left: ASTBlock, right: ASTBlock -> - if (right.getNode().getFirstChildNode().getElementType() == KtTokens.DOC_COMMENT) { + if (right.node.firstChildNode.elementType == KtTokens.DOC_COMMENT) { Spacing.createSpacing(0, 0, 1, true, settings.KEEP_BLANK_LINES_IN_DECLARATIONS) } else { @@ -172,7 +172,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { // class A private() - one space before modifier custom { inPosition(right = PRIMARY_CONSTRUCTOR).customRule { p, l, r -> - val spacesCount = if (r.getNode().findLeafElementAt(0)?.getElementType() != LPAR) 1 else 0 + val spacesCount = if (r.node.findLeafElementAt(0)?.elementType != LPAR) 1 else 0 Spacing.createSpacing(spacesCount, spacesCount, 0, true, 0) } } @@ -238,36 +238,36 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { inPosition(parent = parent, right = keyword).customRule { parent, left, right -> - val previousLeaf = FormatterUtil.getPreviousNonWhitespaceLeaf(right.getNode()) + val previousLeaf = FormatterUtil.getPreviousNonWhitespaceLeaf(right.node) val leftBlock = if ( previousLeaf != null && - previousLeaf.getElementType() == RBRACE && - previousLeaf.getTreeParent()?.getElementType() == BLOCK) { - previousLeaf.getTreeParent()!! + previousLeaf.elementType == RBRACE && + previousLeaf.treeParent?.elementType == BLOCK) { + previousLeaf.treeParent!! } else null - val removeLineBreaks = leftBlock != null && afterBlockFilter(right.getNode()?.getTreeParent()!!, leftBlock) + val removeLineBreaks = leftBlock != null && afterBlockFilter(right.node?.treeParent!!, leftBlock) Spacing.createSpacing(1, 1, 0, !removeLineBreaks, 0) } } } ruleForKeywordOnNewLine(jetCommonSettings.ELSE_ON_NEW_LINE, keyword = ELSE_KEYWORD, parent = IF) { keywordParent, block -> - block.getTreeParent()?.getElementType() == THEN && block.getTreeParent()?.getTreeParent() == keywordParent + block.treeParent?.elementType == THEN && block.treeParent?.treeParent == keywordParent } ruleForKeywordOnNewLine(jetCommonSettings.WHILE_ON_NEW_LINE, keyword = WHILE_KEYWORD, parent = DO_WHILE) { keywordParent, block -> - block.getTreeParent()?.getElementType() == BODY && block.getTreeParent()?.getTreeParent() == keywordParent + block.treeParent?.elementType == BODY && block.treeParent?.treeParent == keywordParent } ruleForKeywordOnNewLine(jetCommonSettings.CATCH_ON_NEW_LINE, keyword = CATCH, parent = TRY) ruleForKeywordOnNewLine(jetCommonSettings.FINALLY_ON_NEW_LINE, keyword = FINALLY, parent = TRY) fun spacingForLeftBrace(block: ASTNode?, blockType: IElementType = BLOCK): Spacing? { - if (block != null && block.getElementType() == blockType) { + if (block != null && block.elementType == blockType) { val leftBrace = block.findChildByType(LBRACE) if (leftBrace != null) { val previousLeaf = FormatterUtil.getPreviousNonWhitespaceLeaf(leftBrace) - val isAfterEolComment = previousLeaf != null && (previousLeaf.getElementType() == EOL_COMMENT) + val isAfterEolComment = previousLeaf != null && (previousLeaf.elementType == EOL_COMMENT) val keepLineBreaks = jetSettings.LBRACE_ON_NEXT_LINE || isAfterEolComment val minimumLF = if (jetSettings.LBRACE_ON_NEXT_LINE) 1 else 0 return Spacing.createSpacing(1, 1, minimumLF, keepLineBreaks, 0) @@ -278,12 +278,12 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { fun leftBraceRule(blockType: IElementType = BLOCK) = { parent: ASTBlock, left: ASTBlock, right: ASTBlock -> - spacingForLeftBrace(right.getNode(), blockType) + spacingForLeftBrace(right.node, blockType) } val leftBraceRuleIfBlockIsWrapped = { parent: ASTBlock, left: ASTBlock, right: ASTBlock -> - spacingForLeftBrace(right.getNode()!!.getFirstChildNode()) + spacingForLeftBrace(right.node!!.firstChildNode) } inPosition(parent = IF, right = THEN).customRule(leftBraceRuleIfBlockIsWrapped) @@ -307,7 +307,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { inPosition(parent = WHEN_ENTRY, right = BLOCK).customRule(leftBraceRule()) inPosition(parent = WHEN, right = LBRACE).customRule { parent, left, right -> - spacingForLeftBrace(block = parent.getNode(), blockType = WHEN) + spacingForLeftBrace(block = parent.node, blockType = WHEN) } val spacesInSimpleFunction = if (jetSettings.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD) 1 else 0 @@ -334,12 +334,12 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder { left = LBRACE) .customRule { parent, left, right -> - val rightNode = right.getNode()!! - val rightType = rightNode.getElementType() + val rightNode = right.node!! + val rightType = rightNode.elementType var numSpaces = spacesInSimpleFunction if (rightType == VALUE_PARAMETER_LIST) { - val firstParamListNode = rightNode.getFirstChildNode() - if (firstParamListNode != null && firstParamListNode.getElementType() == LPAR) { + val firstParamListNode = rightNode.firstChildNode + if (firstParamListNode != null && firstParamListNode.elementType == LPAR) { // Don't put space for situation {(a: Int) -> a } numSpaces = 0 } diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt index 1e315cba396..9a6403c42d6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt @@ -24,7 +24,7 @@ import com.intellij.openapi.roots.ui.configuration.ModulesProvider import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.resolve.TargetPlatform -public class KotlinModuleBuilder( +class KotlinModuleBuilder( val targetPlatform: TargetPlatform, val builderName: String, val builderDescription: String) : JavaModuleBuilder() { override fun getBuilderId() = "kotlin.module.builder" override fun getName() = builderName diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt index 0d84e349786..b7a6af65126 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt @@ -23,9 +23,9 @@ import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.js.resolve.JsPlatform import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -public class KotlinTemplatesFactory : ProjectTemplatesFactory() { +class KotlinTemplatesFactory : ProjectTemplatesFactory() { companion object { - public val KOTLIN_GROUP_NAME: String = "Kotlin" + val KOTLIN_GROUP_NAME: String = "Kotlin" } override fun getGroups() = arrayOf(KOTLIN_GROUP_NAME) diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyBrowser.kt b/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyBrowser.kt index 02200d3be28..441f5587320 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyBrowser.kt +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyBrowser.kt @@ -52,7 +52,7 @@ class KotlinOverrideHierarchyBrowser( val builder = myBuilders.get(myCurrentViewType) if (builder == null) return null - return (builder.getTreeStructure() as KotlinOverrideTreeStructure).javaTreeStructures.get(0).getBaseMethod() + return (builder.treeStructure as KotlinOverrideTreeStructure).javaTreeStructures.get(0).baseMethod } override fun getContentDisplayName(typeName: String, element: PsiElement): String? { diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyProvider.kt b/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyProvider.kt index 29b318736ba..ff535f4138d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideHierarchyProvider.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypesAndPredicate -public class KotlinOverrideHierarchyProvider: HierarchyProvider { +class KotlinOverrideHierarchyProvider: HierarchyProvider { override fun getTarget(dataContext: DataContext): PsiElement? { return CommonDataKeys.PROJECT.getData(dataContext)?.let { project -> getOverrideHierarchyElement(HierarchyUtils.getCurrentElement(dataContext, project)) @@ -37,7 +37,7 @@ public class KotlinOverrideHierarchyProvider: HierarchyProvider { } override fun createHierarchyBrowser(target: PsiElement): HierarchyBrowser = - KotlinOverrideHierarchyBrowser(target.getProject(), target) + KotlinOverrideHierarchyBrowser(target.project, target) override fun browserActivated(hierarchyBrowser: HierarchyBrowser) { (hierarchyBrowser as HierarchyBrowserBaseEx).changeView(MethodHierarchyBrowserBase.METHOD_TYPE) diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideTreeStructure.kt b/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideTreeStructure.kt index ff37a324f30..35ef1e486a5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideTreeStructure.kt +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/overrides/KotlinOverrideTreeStructure.kt @@ -30,7 +30,7 @@ class KotlinOverrideTreeStructure(project: Project, val element: PsiElement) : H val javaTreeStructures = element.toLightMethods().map { method -> MethodHierarchyTreeStructure(project, method) } init { - setBaseElement(javaTreeStructures.first().getBaseDescriptor()!!) + setBaseElement(javaTreeStructures.first().baseDescriptor!!) } override fun buildChildren(descriptor: HierarchyNodeDescriptor): Array { diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/ErrorDuringFileAnalyzeNotificationProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/ErrorDuringFileAnalyzeNotificationProvider.kt index 951b2957396..f2359c3e34f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/ErrorDuringFileAnalyzeNotificationProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/ErrorDuringFileAnalyzeNotificationProvider.kt @@ -36,18 +36,18 @@ fun updateHighlightingResult(file: KtFile, hasErrors: Boolean) { if (hasErrors != file.getUserData(HAS_ERRORS_IN_HIGHLIHTING_KEY)) { file.putUserData(HAS_ERRORS_IN_HIGHLIHTING_KEY, hasErrors) - val vFile = file.getVirtualFile() + val vFile = file.virtualFile if (vFile != null) { - EditorNotifications.getInstance(file.getProject())?.updateNotifications(vFile) + EditorNotifications.getInstance(file.project)?.updateNotifications(vFile) } } } -public class ErrorDuringFileAnalyzeNotificationProvider(val project: Project) : EditorNotifications.Provider() { +class ErrorDuringFileAnalyzeNotificationProvider(val project: Project) : EditorNotifications.Provider() { private class HighlightingErrorNotificationPanel : EditorNotificationPanel() { init { setText("Kotlin internal error occurred in this file. Highlighting may be inadequate.") - myLabel.setIcon(AllIcons.General.Error) + myLabel.icon = AllIcons.General.Error createActionLabel("Open Event Log", ActivateToolWindowAction.getActionIdForToolWindow(EventLog.LOG_TOOL_WINDOW_ID)) } } @@ -55,7 +55,7 @@ public class ErrorDuringFileAnalyzeNotificationProvider(val project: Project) : override fun getKey() = ERROR_HIGHLIGHT_PANEL_KEY override fun createNotificationPanel(file: VirtualFile, fileEditor: FileEditor): EditorNotificationPanel? { - if (file.getFileType() != KotlinFileType.INSTANCE) { + if (file.fileType != KotlinFileType.INSTANCE) { return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt index 37bd0fee85b..b1be1a45ad1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt @@ -31,7 +31,7 @@ import java.lang.reflect.Field import java.lang.reflect.Modifier import java.util.HashMap -public class KotlinColorSettingsPage : ColorSettingsPage { +class KotlinColorSettingsPage : ColorSettingsPage { override fun getIcon() = KotlinIcons.SMALL_LOGO override fun getHighlighter(): SyntaxHighlighter = KotlinHighlighter() @@ -93,10 +93,10 @@ var globalCount override fun getAdditionalHighlightingTagToDescriptorMap(): Map { val map = HashMap() - for (field in KotlinHighlightingColors::class.java.getFields()) { - if (Modifier.isStatic(field.getModifiers())) { + for (field in KotlinHighlightingColors::class.java.fields) { + if (Modifier.isStatic(field.modifiers)) { try { - map.put(field.getName(), field.get(null) as TextAttributesKey) + map.put(field.name, field.get(null) as TextAttributesKey) } catch (e: IllegalAccessException) { assert(false) diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt index 5a6332918d9..6ea7ac06d29 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt @@ -35,13 +35,13 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.resolve.inline.InlineUtil -public class KotlinHighlightExitPointsHandlerFactory: HighlightUsagesHandlerFactoryBase() { +class KotlinHighlightExitPointsHandlerFactory: HighlightUsagesHandlerFactoryBase() { companion object { private val RETURN_AND_THROW = TokenSet.create(KtTokens.RETURN_KEYWORD, KtTokens.THROW_KEYWORD) } override fun createHighlightUsagesHandler(editor: Editor, file: PsiFile, target: PsiElement): HighlightUsagesHandlerBase<*>? { - if (target is LeafPsiElement && (target.getElementType() in RETURN_AND_THROW)) { + if (target is LeafPsiElement && (target.elementType in RETURN_AND_THROW)) { val returnOrThrow = PsiTreeUtil.getParentOfType( target, KtReturnExpression::class.java, diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt index 2a952ec9674..fd14519d3c0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.util.OperatorNameConventions import java.util.HashSet -public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { +class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { override fun getLineMarkerInfo(element: PsiElement) = null override fun collectSlowLineMarkers(elements: MutableList, result: MutableCollection>) { @@ -79,7 +79,7 @@ public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { val resolveName = getCallNameFromPsi(element) ?: return false val enclosingFunction = getEnclosingFunction(element, false) ?: return false - if (enclosingFunction.getName() != resolveName.asString()) return false + if (enclosingFunction.name != resolveName.asString()) return false // Check that there were no not-inlined lambdas on the way to enclosing function if (enclosingFunction != getEnclosingFunction(element, true)) return false @@ -90,7 +90,7 @@ public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { val call = bindingContext[BindingContext.CALL, element] ?: return false val resolvedCall = bindingContext[BindingContext.RESOLVED_CALL, call] ?: return false - if (resolvedCall.getCandidateDescriptor().getOriginal() != enclosingFunctionDescriptor) return false + if (resolvedCall.candidateDescriptor.original != enclosingFunctionDescriptor) return false fun isDifferentReceiver(receiver: Receiver?): Boolean { if (receiver !is ReceiverValue) return false @@ -99,25 +99,25 @@ public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { return when (receiverOwner) { is SimpleFunctionDescriptor -> receiverOwner != enclosingFunctionDescriptor - is ClassDescriptor -> receiverOwner != enclosingFunctionDescriptor.getContainingDeclaration() + is ClassDescriptor -> receiverOwner != enclosingFunctionDescriptor.containingDeclaration else -> throw IllegalStateException("Unexpected receiver owner: $receiverOwner") } } - if (isDifferentReceiver(resolvedCall.getExtensionReceiver())) return false - if (isDifferentReceiver(resolvedCall.getDispatchReceiver())) return false + if (isDifferentReceiver(resolvedCall.extensionReceiver)) return false + if (isDifferentReceiver(resolvedCall.dispatchReceiver)) return false return true } private class RecursiveMethodCallMarkerInfo(callElement: KtElement) : LineMarkerInfo( - callElement, - callElement.getTextRange(), - AllIcons.Gutter.RecursiveMethod, - Pass.UPDATE_OVERRIDEN_MARKERS, - { "Recursive call" }, - null, - GutterIconRenderer.Alignment.RIGHT + callElement, + callElement.textRange, + AllIcons.Gutter.RecursiveMethod, + Pass.UPDATE_OVERRIDEN_MARKERS, + { "Recursive call" }, + null, + GutterIconRenderer.Alignment.RIGHT ) { override fun createGutterRenderer(): GutterIconRenderer? { @@ -130,7 +130,7 @@ public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider { } private fun PsiElement.getLineNumber(): Int { - return PsiDocumentManager.getInstance(getProject()).getDocument(getContainingFile())!!.getLineNumber(getTextOffset()) + return PsiDocumentManager.getInstance(project).getDocument(containingFile)!!.getLineNumber(textOffset) } private fun getCallNameFromPsi(element: KtElement): Name? { @@ -140,7 +140,7 @@ private fun getCallNameFromPsi(element: KtElement): Name? { when (elementParent) { is KtCallExpression -> return Name.identifier(element.getText()) is KtOperationExpression -> { - val operationReference = elementParent.getOperationReference() + val operationReference = elementParent.operationReference if (element == operationReference) { val node = operationReference.getReferencedNameElementType() return if (node is KtToken) { diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt index 0f210027f4e..336d1563a7e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.psi.KtNamedFunction -public class KotlinRunLineMarkerContributor : RunLineMarkerContributor() { +class KotlinRunLineMarkerContributor : RunLineMarkerContributor() { override fun getInfo(element: PsiElement?): RunLineMarkerContributor.Info? { val function = element?.parent as? KtNamedFunction if (function == null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/JavaPsiUtils.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/JavaPsiUtils.kt index 17d7e0ca465..98e8359d0e7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/JavaPsiUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/JavaPsiUtils.kt @@ -32,8 +32,8 @@ fun collectContainingClasses(methods: Collection): Set { val classes = HashSet() for (method in methods) { ProgressManager.checkCanceled() - val parentClass = method.getContainingClass() - if (parentClass != null && CommonClassNames.JAVA_LANG_OBJECT != parentClass.getQualifiedName()) { + val parentClass = method.containingClass + if (parentClass != null && CommonClassNames.JAVA_LANG_OBJECT != parentClass.qualifiedName) { classes.add(parentClass) } } @@ -46,13 +46,13 @@ internal fun getPsiClass(element: PsiElement?): PsiClass? { element == null -> null element is PsiClass -> element element is KtClass -> LightClassUtil.getPsiClass(element) - element.getParent() is KtClass -> LightClassUtil.getPsiClass(element.getParent() as KtClass) + element.parent is KtClass -> LightClassUtil.getPsiClass(element.parent as KtClass) else -> null } } internal fun getPsiMethod(element: PsiElement?): PsiMethod? { - val parent = element?.getParent() + val parent = element?.parent return when { element == null -> null element is PsiMethod -> element diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt index 0e865382cf2..baed6b0ceb5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt @@ -40,7 +40,7 @@ import java.awt.event.MouseEvent import java.util.* import javax.swing.Icon -public class KotlinLineMarkerProvider : LineMarkerProvider { +class KotlinLineMarkerProvider : LineMarkerProvider { override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo? { // all Kotlin markers are added in slow marker pass return null @@ -50,7 +50,7 @@ public class KotlinLineMarkerProvider : LineMarkerProvider { if (elements.isEmpty()) return val first = elements.first() - if (DumbService.getInstance(first.getProject()).isDumb() || !ProjectRootsUtil.isInProjectOrLibSource(first)) return + if (DumbService.getInstance(first.project).isDumb || !ProjectRootsUtil.isInProjectOrLibSource(first)) return val functions = HashSet() val properties = HashSet() @@ -100,15 +100,15 @@ private val OVERRIDDEN_FUNCTION = MarkerType( }) private val OVERRIDDEN_PROPERTY = MarkerType( - { it?.let { getOverriddenPropertyTooltip(it.getParent() as KtProperty) } }, + { it?.let { getOverriddenPropertyTooltip(it.parent as KtProperty) } }, object : LineMarkerNavigator() { override fun browse(e: MouseEvent?, element: PsiElement?) { - element?.let { navigateToPropertyOverriddenDeclarations(e, it.getParent() as KtProperty) } + element?.let { navigateToPropertyOverriddenDeclarations(e, it.parent as KtProperty) } } }) private fun isImplementsAndNotOverrides(descriptor: CallableMemberDescriptor, overriddenMembers: Collection): Boolean { - return descriptor.getModality() != Modality.ABSTRACT && overriddenMembers.all { it.getModality() == Modality.ABSTRACT } + return descriptor.modality != Modality.ABSTRACT && overriddenMembers.all { it.modality == Modality.ABSTRACT } } private fun collectSuperDeclarationMarkers(declaration: KtDeclaration, result: MutableCollection>) { @@ -125,7 +125,7 @@ private fun collectSuperDeclarationMarkers(declaration: KtDeclaration, result: M // clearing the whole BindingTrace. val marker = LineMarkerInfo( declaration, - declaration.getTextOffset(), + declaration.textOffset, if (implements) IMPLEMENTING_MARK else OVERRIDING_MARK, Pass.UPDATE_OVERRIDEN_MARKERS, SuperDeclarationMarkerTooltip, @@ -145,15 +145,15 @@ private fun collectInheritedClassMarker(element: KtClass, result: MutableCollect if (ClassInheritorsSearch.search(lightClass, false).findFirst() == null) return - val anchor = element.getNameIdentifier() ?: element + val anchor = element.nameIdentifier ?: element result.add(LineMarkerInfo( anchor, - anchor.getTextOffset(), + anchor.textOffset, if (isTrait) IMPLEMENTED_MARK else OVERRIDDEN_MARK, Pass.UPDATE_OVERRIDEN_MARKERS, - SUBCLASSED_CLASS.getTooltip(), - SUBCLASSED_CLASS.getNavigationHandler() + SUBCLASSED_CLASS.tooltip, + SUBCLASSED_CLASS.navigationHandler )) } @@ -173,15 +173,15 @@ private fun collectOverriddenPropertyAccessors(properties: Collection, r for (function in getOverriddenDeclarations(mappingToJava, classes)) { ProgressManager.checkCanceled() - val anchor = function.getNameIdentifier() ?: function + val anchor = function.nameIdentifier ?: function result.add(LineMarkerInfo( anchor, - anchor.getTextOffset(), + anchor.textOffset, if (isImplemented(function)) IMPLEMENTED_MARK else OVERRIDDEN_MARK, - Pass.UPDATE_OVERRIDEN_MARKERS, OVERRIDDEN_FUNCTION.getTooltip(), - OVERRIDDEN_FUNCTION.getNavigationHandler(), + Pass.UPDATE_OVERRIDEN_MARKERS, OVERRIDDEN_FUNCTION.tooltip, + OVERRIDDEN_FUNCTION.navigationHandler, GutterIconRenderer.Alignment.RIGHT )) } diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenFunctionMarker.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenFunctionMarker.kt index 1224539ff4d..62c76cfb916 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenFunctionMarker.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenFunctionMarker.kt @@ -73,19 +73,19 @@ internal fun getOverriddenDeclarations(mappingToJava: MutableMap(5) OverridingMethodsSearch.search(method, true).forEach(PsiElementProcessorAdapter(processor)) val isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT) - if (processor.isOverflow()) { + if (processor.isOverflow) { return if (isAbstract) DaemonBundle.message("method.is.implemented.too.many") else DaemonBundle.message("method.is.overridden.too.many") } - val comparator = MethodCellRenderer(false).getComparator() + val comparator = MethodCellRenderer(false).comparator - val overridingJavaMethods = processor.getCollection().filter { !it.isMethodWithDeclarationInOtherClass() }.sortedWith(comparator) + val overridingJavaMethods = processor.collection.filter { !it.isMethodWithDeclarationInOtherClass() }.sortedWith(comparator) if (overridingJavaMethods.isEmpty()) return null val start = if (isAbstract) DaemonBundle.message("method.is.implemented.header") else DaemonBundle.message("method.is.overriden.header") @@ -93,9 +93,9 @@ public fun getOverriddenMethodTooltip(method: PsiMethod): String? { return GutterIconTooltipHelper.composeText(overridingJavaMethods, start, "    {1}") } -public fun navigateToOverriddenMethod(e: MouseEvent?, method: PsiMethod) { - if (DumbService.isDumb(method.getProject())) { - DumbService.getInstance(method.getProject())?.showDumbModeNotification("Navigation to overriding classes is not possible during index update") +fun navigateToOverriddenMethod(e: MouseEvent?, method: PsiMethod) { + if (DumbService.isDumb(method.project)) { + DumbService.getInstance(method.project)?.showDumbModeNotification("Navigation to overriding classes is not possible during index update") return } @@ -104,11 +104,11 @@ public fun navigateToOverriddenMethod(e: MouseEvent?, method: PsiMethod) { { OverridingMethodsSearch.search(method, true).forEach(PsiElementProcessorAdapter(processor)) }, - "Searching for overriding declarations", true, method.getProject(), e?.getComponent() as JComponent?)) { + "Searching for overriding declarations", true, method.project, e?.component as JComponent?)) { return } - var overridingJavaMethods = processor.getCollection().filter { !it.isMethodWithDeclarationInOtherClass() } + var overridingJavaMethods = processor.collection.filter { !it.isMethodWithDeclarationInOtherClass() } if (overridingJavaMethods.isEmpty()) return val showMethodNames = !PsiUtil.allMethodsHaveSameSignature(overridingJavaMethods.toTypedArray()) @@ -121,7 +121,7 @@ public fun navigateToOverriddenMethod(e: MouseEvent?, method: PsiMethod) { e, overridingJavaMethods.toTypedArray(), methodsUpdater.getCaption(overridingJavaMethods.size), - "Overriding declarations of " + method.getName(), + "Overriding declarations of " + method.name, renderer, methodsUpdater) } @@ -129,19 +129,19 @@ public fun navigateToOverriddenMethod(e: MouseEvent?, method: PsiMethod) { private class OverridingMethodsUpdater( private val myMethod: PsiMethod, private val myRenderer: PsiElementListCellRenderer) : - ListBackgroundUpdaterTask(myMethod.getProject(), "Searching for overriding methods") { + ListBackgroundUpdaterTask(myMethod.project, "Searching for overriding methods") { override fun getCaption(size: Int): String { return if (myMethod.hasModifierProperty(PsiModifier.ABSTRACT)) - DaemonBundle.message("navigation.title.implementation.method", myMethod.getName(), size)!! + DaemonBundle.message("navigation.title.implementation.method", myMethod.name, size)!! else - DaemonBundle.message("navigation.title.overrider.method", myMethod.getName(), size)!! + DaemonBundle.message("navigation.title.overrider.method", myMethod.name, size)!! } override fun run(indicator: ProgressIndicator) { super.run(indicator) OverridingMethodsSearch.search(myMethod, true).forEach(object : CommonProcessors.CollectProcessor() { override fun process(psiMethod: PsiMethod?): Boolean { - if (!updateComponent(psiMethod, myRenderer.getComparator())) { + if (!updateComponent(psiMethod, myRenderer.comparator)) { indicator.cancel() } indicator.checkCanceled() diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenPropertyMarker.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenPropertyMarker.kt index 72c5dd76874..793e5378ef6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenPropertyMarker.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/OverridenPropertyMarker.kt @@ -47,24 +47,24 @@ fun getOverriddenPropertyTooltip(property: KtProperty): String? { val consumer = AdapterProcessor( CommonProcessors.UniqueProcessor(PsiElementProcessorAdapter(overriddenInClassesProcessor)), - Function { method: PsiMethod? -> method?.getContainingClass() } + Function { method: PsiMethod? -> method?.containingClass } ) for (method in LightClassUtil.getLightClassPropertyMethods(property)) { - if (!overriddenInClassesProcessor.isOverflow()) { + if (!overriddenInClassesProcessor.isOverflow) { OverridingMethodsSearch.search(method, true).forEach(consumer) } } val isImplemented = isImplemented(property) - if (overriddenInClassesProcessor.isOverflow()) { + if (overriddenInClassesProcessor.isOverflow) { return if (isImplemented) KotlinBundle.message("property.is.implemented.too.many") else KotlinBundle.message("property.is.overridden.too.many") } - val collectedClasses = overriddenInClassesProcessor.getCollection() + val collectedClasses = overriddenInClassesProcessor.collection if (collectedClasses.isEmpty()) return null val start = if (isImplemented) @@ -77,7 +77,7 @@ fun getOverriddenPropertyTooltip(property: KtProperty): String? { } fun navigateToPropertyOverriddenDeclarations(e: MouseEvent?, property: KtProperty) { - val project = property.getProject() + val project = property.project if (DumbService.isDumb(project)) { DumbService.getInstance(project)?.showDumbModeNotification("Navigation to overriding classes is not possible during index update") @@ -99,26 +99,26 @@ fun navigateToPropertyOverriddenDeclarations(e: MouseEvent?, property: KtPropert MarkerType.SEARCHING_FOR_OVERRIDING_METHODS, /* can be canceled */ true, project, - e?.getComponent() as JComponent?)) { + e?.component as JComponent?)) { return } val renderer = DefaultPsiElementCellRenderer() - val navigatingOverrides = elementProcessor.getResults() + val navigatingOverrides = elementProcessor.results .sortedWith(renderer.comparator) .filterIsInstance() PsiElementListNavigator.openTargets(e, navigatingOverrides.toTypedArray(), - KotlinBundle.message("navigation.title.overriding.property", property.getName()), - KotlinBundle.message("navigation.findUsages.title.overriding.property", property.getName()), renderer) + KotlinBundle.message("navigation.title.overriding.property", property.name), + KotlinBundle.message("navigation.findUsages.title.overriding.property", property.name), renderer) } -public fun isImplemented(declaration: KtNamedDeclaration): Boolean { +fun isImplemented(declaration: KtNamedDeclaration): Boolean { if (declaration.hasModifier(KtTokens.ABSTRACT_KEYWORD)) return true - var parent = declaration.getParent() + var parent = declaration.parent parent = if (parent is KtClassBody) parent.getParent() else parent if (parent !is KtClass) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/SuperDeclarationMarker.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/SuperDeclarationMarker.kt index 7770e4091d3..eccdc9f3b97 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/SuperDeclarationMarker.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/SuperDeclarationMarker.kt @@ -44,7 +44,7 @@ object SuperDeclarationMarkerTooltip: Function { val (elementDescriptor, overriddenDescriptors) = resolveDeclarationWithParents(ktDeclaration!!) if (overriddenDescriptors.isEmpty()) return "" - val isAbstract = elementDescriptor!!.getModality() == Modality.ABSTRACT + val isAbstract = elementDescriptor!!.modality == Modality.ABSTRACT val renderer = DescriptorRenderer.withOptions { textFormat = RenderingFormat.HTML @@ -54,10 +54,10 @@ object SuperDeclarationMarkerTooltip: Function { } val containingStrings = overriddenDescriptors.map { - val declaration = it.getContainingDeclaration() + val declaration = it.containingDeclaration val memberKind = if (it is PropertyAccessorDescriptor || it is PropertyDescriptor) "property" else "function" - val isBaseAbstract = it.getModality() == Modality.ABSTRACT + val isBaseAbstract = it.modality == Modality.ABSTRACT "${if (!isAbstract && isBaseAbstract) "Implements" else "Overrides"} $memberKind in '${renderer.render(declaration)}'" } @@ -65,11 +65,10 @@ object SuperDeclarationMarkerTooltip: Function { } } -public class SuperDeclarationMarkerNavigationHandler : GutterIconNavigationHandler { +class SuperDeclarationMarkerNavigationHandler : GutterIconNavigationHandler { private var testNavigableElements: List? = null - @TestOnly - public fun getNavigationElements(): List { + @TestOnly fun getNavigationElements(): List { val navigationResult = testNavigableElements!! testNavigableElements = null return navigationResult @@ -83,7 +82,7 @@ public class SuperDeclarationMarkerNavigationHandler : GutterIconNavigationHandl val superDeclarations = ArrayList() for (overriddenMember in overriddenDescriptors) { - val declarations = DescriptorToSourceUtilsIde.getAllDeclarations(element.getProject(), overriddenMember) + val declarations = DescriptorToSourceUtilsIde.getAllDeclarations(element.project, overriddenMember) for (declaration in declarations) { if (declaration is NavigatablePsiElement) { superDeclarations.add(declaration) @@ -91,8 +90,8 @@ public class SuperDeclarationMarkerNavigationHandler : GutterIconNavigationHandl } } - if (!ApplicationManager.getApplication()!!.isUnitTestMode()) { - val elementName = elementDescriptor!!.getName() + if (!ApplicationManager.getApplication()!!.isUnitTestMode) { + val elementName = elementDescriptor!!.name PsiElementListNavigator.openTargets( e, @@ -108,11 +107,11 @@ public class SuperDeclarationMarkerNavigationHandler : GutterIconNavigationHandl } } -public data class ResolveWithParentsResult( +data class ResolveWithParentsResult( val descriptor: CallableMemberDescriptor?, val overriddenDescriptors: Collection) -public fun resolveDeclarationWithParents(element: KtDeclaration): ResolveWithParentsResult { +fun resolveDeclarationWithParents(element: KtDeclaration): ResolveWithParentsResult { val descriptor = element.resolveToDescriptorIfAny() if (descriptor !is CallableMemberDescriptor) return ResolveWithParentsResult(null, listOf()) diff --git a/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt b/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt index 6ea20ee12e5..db71ea61f75 100644 --- a/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope import org.jetbrains.kotlin.resolve.scopes.utils.* import java.util.* -public class KotlinImportOptimizer() : ImportOptimizer { +class KotlinImportOptimizer() : ImportOptimizer { override fun supports(file: PsiFile?) = file is KtFile @@ -52,7 +52,7 @@ public class KotlinImportOptimizer() : ImportOptimizer { } private class OptimizeProcess(private val file: KtFile) { - public fun execute() { + fun execute() { val oldImports = file.importDirectives if (oldImports.isEmpty()) return @@ -70,7 +70,7 @@ public class KotlinImportOptimizer() : ImportOptimizer { private val _descriptors = HashSet() private val currentPackageName = file.packageFqName - public val descriptors: Set + val descriptors: Set get() = _descriptors override fun visitElement(element: PsiElement) { @@ -145,13 +145,13 @@ public class KotlinImportOptimizer() : ImportOptimizer { } companion object { - public fun collectDescriptorsToImport(file: KtFile): Set { + fun collectDescriptorsToImport(file: KtFile): Set { val visitor = CollectUsedDescriptorsVisitor(file) file.accept(visitor) return visitor.descriptors } - public fun prepareOptimizedImports( + fun prepareOptimizedImports( file: KtFile, descriptorsToImport: Collection ): List? { @@ -263,7 +263,7 @@ public class KotlinImportOptimizer() : ImportOptimizer { return aliasImports } - public fun replaceImports(file: KtFile, imports: List) { + fun replaceImports(file: KtFile, imports: List) { val importList = file.importList!! val oldImports = importList.imports val psiFactory = KtPsiFactory(file.project) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/AddKotlinLibQuickFix.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/AddKotlinLibQuickFix.kt index 490978eccde..0a48ad46dfd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/AddKotlinLibQuickFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/AddKotlinLibQuickFix.kt @@ -52,7 +52,7 @@ import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.io.File -public class AddReflectionQuickFix(element: KtElement) : AddKotlinLibQuickFix(element) { +class AddReflectionQuickFix(element: KtElement) : AddKotlinLibQuickFix(element) { override fun getText() = KotlinBundle.message("add.reflection.to.classpath") override fun getFamilyName() = text @@ -67,7 +67,7 @@ public class AddReflectionQuickFix(element: KtElement) : AddKotlinLibQuickFix(el } } -public class AddTestLibQuickFix(element: KtElement) : AddKotlinLibQuickFix(element) { +class AddTestLibQuickFix(element: KtElement) : AddKotlinLibQuickFix(element) { override fun getText() = KotlinBundle.message("add.test.to.classpath") override fun getFamilyName() = text @@ -120,7 +120,7 @@ public class AddTestLibQuickFix(element: KtElement) : AddKotlinLibQuickFix(eleme } } -public abstract class AddKotlinLibQuickFix(element: KtElement) : KotlinQuickFixAction(element) { +abstract class AddKotlinLibQuickFix(element: KtElement) : KotlinQuickFixAction(element) { protected abstract fun libraryPath(): String protected abstract fun getLibFile(): File protected abstract fun hasLibJarInLibrary(library: Library): Boolean diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt index 770d7e7d615..398d977cd15 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt @@ -53,7 +53,7 @@ import org.jetbrains.kotlin.resolve.scopes.collectSyntheticExtensionProperties import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { +class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { val file = session.file as? KtFile ?: return PsiElementVisitor.EMPTY_VISITOR val resolutionFacade = file.getResolutionFacade() diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt index 77a1111a384..527f819e257 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspectionTool { +class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspectionTool { // required to simplify the inspection registration in tests override fun getDisplayName(): String = "Usage of redundant or deprecated syntax or deprecated symbols" @@ -54,7 +54,7 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe throw ProcessCanceledException(analysisResult.error) } - val diagnostics = analysisResult.bindingContext.getDiagnostics() + val diagnostics = analysisResult.bindingContext.diagnostics val problemDescriptors = arrayListOf() @@ -79,7 +79,7 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe return problemDescriptors.toTypedArray() } - private fun Diagnostic.isCleanup() = getFactory() in cleanupDiagnosticsFactories || isObsoleteLabel() + private fun Diagnostic.isCleanup() = factory in cleanupDiagnosticsFactories || isObsoleteLabel() private val cleanupDiagnosticsFactories = setOf( Errors.MISSING_CONSTRUCTOR_KEYWORD, @@ -103,7 +103,7 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe ) private fun Diagnostic.isObsoleteLabel(): Boolean { - val annotationEntry = getPsiElement().getNonStrictParentOfType() ?: return false + val annotationEntry = psiElement.getNonStrictParentOfType() ?: return false return ReplaceObsoleteLabelSyntaxFix.looksLikeObsoleteLabel(annotationEntry) } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/OldStdlibApiInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/OldStdlibApiInspection.kt index cdff160a6ad..4e1afe6f452 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/OldStdlibApiInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/OldStdlibApiInspection.kt @@ -72,7 +72,7 @@ class OldStdlibApiInspection : AbstractKotlinInspection(), CleanupLocalInspectio } } -public class OldStdlibApiFix(val newElementCallback: (Project, GlobalSearchScope) -> PsiElement?) : LocalQuickFix { +class OldStdlibApiFix(val newElementCallback: (Project, GlobalSearchScope) -> PsiElement?) : LocalQuickFix { override fun getName(): String = "Replace with new qualified name" override fun getFamilyName(): String = name diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt index 821adca0425..660384c6dc6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.utils.addToStdlib.check import org.jetbrains.kotlin.utils.addToStdlib.singletonList -public class RedundantSamConstructorInspection : AbstractKotlinInspection() { +class RedundantSamConstructorInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { return object : KtVisitorVoid() { private fun createQuickFix(expression: KtCallExpression): LocalQuickFix { @@ -106,7 +106,7 @@ public class RedundantSamConstructorInspection : AbstractKotlinInspection() { } companion object { - public fun replaceSamConstructorCall(callExpression: KtCallExpression): KtExpression { + fun replaceSamConstructorCall(callExpression: KtCallExpression): KtExpression { val functionalArgument = callExpression.samConstructorValueArgument()?.getArgumentExpression() ?: throw AssertionError("SAM-constructor should have a FunctionLiteralExpression as single argument: ${callExpression.getElementTextWithContext()}") return callExpression.getQualifiedExpressionForSelectorOrThis().replace(functionalArgument) as KtExpression @@ -150,7 +150,7 @@ public class RedundantSamConstructorInspection : AbstractKotlinInspection() { override fun getValueArguments() = newArguments } - public fun samConstructorCallsToBeConverted(functionCall: KtCallExpression): List { + fun samConstructorCallsToBeConverted(functionCall: KtCallExpression): List { return samConstructorArgumentsToBeConverted(functionCall).map { it.toCallExpression()!! } } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantVisibilityModifierInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantVisibilityModifierInspection.kt index 9f6cec56887..f54299667fe 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantVisibilityModifierInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantVisibilityModifierInspection.kt @@ -42,7 +42,7 @@ class RedundantVisibilityModifierInspection : AbstractKotlinInspection(), Cleanu class RemoveVisibilityModifierFix : LocalQuickFix { override fun getName(): String = "Remove redundant visibility modifier" - override fun getFamilyName(): String = getName() + override fun getFamilyName(): String = name override fun applyFix(project: Project, descriptor: ProblemDescriptor) { descriptor.psiElement.delete() diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt index 530fe20c4db..96754d92736 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -public class UnusedReceiverParameterInspection : AbstractKotlinInspection() { +class UnusedReceiverParameterInspection : AbstractKotlinInspection() { override val suppressionKey: String get() = "unused" override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 2c6ef13d9f6..23003f1d8f4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -60,11 +60,11 @@ import java.awt.Insets import javax.swing.JComponent import javax.swing.JPanel -public class UnusedSymbolInspection : AbstractKotlinInspection() { +class UnusedSymbolInspection : AbstractKotlinInspection() { companion object { private val javaInspection = UnusedDeclarationInspection() - public fun isEntryPoint(declaration: KtNamedDeclaration): Boolean { + fun isEntryPoint(declaration: KtNamedDeclaration): Boolean { val lightElement: PsiElement? = when (declaration) { is KtClassOrObject -> declaration.toLightClass() is KtNamedFunction, is KtSecondaryConstructor -> LightClassUtil.getLightClassMethod(declaration as KtFunction) @@ -74,7 +74,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { val entryPointsManager = EntryPointsManager.getInstance(declaration.getProject()) as EntryPointsManagerBase return checkAnnotatedUsingPatterns( descriptor, - entryPointsManager.getAdditionalAnnotations() + entryPointsManager.ADDITIONAL_ANNOTATIONS + entryPointsManager.additionalAnnotations + entryPointsManager.ADDITIONAL_ANNOTATIONS ) } else -> return false @@ -86,21 +86,21 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { val ownerObject = getNonStrictParentOfType() if (ownerObject is KtObjectDeclaration && ownerObject.isCompanion()) { val lightClass = ownerObject.getNonStrictParentOfType()?.toLightClass() ?: return false - return lightClass.getFields().any { it.getName() == getName() && HighlightUtil.isSerializationImplicitlyUsedField(it) } + return lightClass.fields.any { it.name == name && HighlightUtil.isSerializationImplicitlyUsedField(it) } } return false } private fun KtObjectDeclaration.hasSerializationImplicitlyUsedField(): Boolean { - return getDeclarations().any { it is KtProperty && it.isSerializationImplicitlyUsedField() } + return declarations.any { it is KtProperty && it.isSerializationImplicitlyUsedField() } } // variation of IDEA's AnnotationUtil.checkAnnotatedUsingPatterns() private fun checkAnnotatedUsingPatterns(annotated: Annotated, annotationPatterns: Collection): Boolean { - val annotationsPresent = annotated.getAnnotations() - .map { it.getType() } - .filter { !it.isError() } - .mapNotNull { it.getConstructor().getDeclarationDescriptor()?.let { DescriptorUtils.getFqName(it).asString() } } + val annotationsPresent = annotated.annotations + .map { it.type } + .filter { !it.isError } + .mapNotNull { it.constructor.declarationDescriptor?.let { DescriptorUtils.getFqName(it).asString() } } if (annotationsPresent.isEmpty()) return false @@ -124,12 +124,12 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { return object : KtVisitorVoid() { private fun createQuickFix(declaration: KtNamedDeclaration): LocalQuickFix { return object : LocalQuickFix { - override fun getName() = QuickFixBundle.message("safe.delete.text", declaration.getName()) + override fun getName() = QuickFixBundle.message("safe.delete.text", declaration.name) override fun getFamilyName() = "Safe delete" override fun applyFix(project: Project, descriptor: ProblemDescriptor) { - if (!FileModificationService.getInstance().prepareFileForWrite(declaration.getContainingFile())) return + if (!FileModificationService.getInstance().prepareFileForWrite(declaration.containingFile)) return SafeDeleteHandler.invoke(project, arrayOf(declaration), false) } } @@ -149,11 +149,11 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { // Simple PSI-based checks val isCompanionObject = declaration is KtObjectDeclaration && declaration.isCompanion() - if (declaration.getName() == null) return + if (declaration.name == null) return if (declaration is KtEnumEntry) return if (declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) return - if (declaration is KtProperty && declaration.isLocal()) return - if (declaration is KtParameter && (declaration.getParent()?.getParent() !is KtPrimaryConstructor || !declaration.hasValOrVar())) return + if (declaration is KtProperty && declaration.isLocal) return + if (declaration is KtParameter && (declaration.getParent()?.parent !is KtPrimaryConstructor || !declaration.hasValOrVar())) return if (declaration is KtNamedFunction && isConventionalName(declaration)) return // More expensive, resolve-based checks @@ -168,17 +168,17 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { if (hasNonTrivialUsages(declaration)) return if (declaration is KtClassOrObject && classOrObjectHasTextUsages(declaration)) return - val (inspectionTarget, textRange) = if (isCompanionObject && declaration.getNameIdentifier() == null) { + val (inspectionTarget, textRange) = if (isCompanionObject && declaration.nameIdentifier == null) { val objectKeyword = (declaration as KtObjectDeclaration).getObjectKeyword() - Pair(declaration, TextRange(0, objectKeyword.getStartOffsetInParent() + objectKeyword.getTextLength())) + Pair(declaration, TextRange(0, objectKeyword.startOffsetInParent + objectKeyword.textLength)) } else { - Pair(declaration.getNameIdentifier()!!, null) + Pair(declaration.nameIdentifier!!, null) } - val problemDescriptor = holder.getManager().createProblemDescriptor( + val problemDescriptor = holder.manager.createProblemDescriptor( inspectionTarget, textRange, - KotlinBundle.message(messageKey, declaration.getName()), + KotlinBundle.message(messageKey, declaration.name), ProblemHighlightType.LIKE_UNUSED_SYMBOL, true, createQuickFix(declaration) @@ -195,12 +195,12 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { var hasTextUsages = false // Finding text usages - if (classOrObject.getUseScope() is GlobalSearchScope) { - val findClassUsagesHandler = KotlinFindClassUsagesHandler(classOrObject, KotlinFindUsagesHandlerFactory(classOrObject.getProject())) + if (classOrObject.useScope is GlobalSearchScope) { + val findClassUsagesHandler = KotlinFindClassUsagesHandler(classOrObject, KotlinFindUsagesHandlerFactory(classOrObject.project)) findClassUsagesHandler.processUsagesInText( classOrObject, { hasTextUsages = true; false }, - GlobalSearchScope.projectScope(classOrObject.getProject()) + GlobalSearchScope.projectScope(classOrObject.project) ) } @@ -208,18 +208,18 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { } private fun isConventionalName(namedDeclaration: KtNamedDeclaration): Boolean { - val name = namedDeclaration.getNameAsName() + val name = namedDeclaration.nameAsName return name!!.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorNameConventions.INVOKE } private fun hasNonTrivialUsages(declaration: KtNamedDeclaration): Boolean { - val psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(declaration.getProject()) + val psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(declaration.project) - val useScope = declaration.getUseScope() + val useScope = declaration.useScope if (useScope is GlobalSearchScope) { var zeroOccurrences = true - for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) { + for (name in listOf(declaration.name) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) { assert(name != null) { "Name is null for " + declaration.getElementTextWithContext() } when (psiSearchHelper.isCheapEnoughToSearch(name!!, useScope, null, null)) { ZERO_OCCURRENCES -> {} // go on, check other names @@ -248,7 +248,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { private fun hasReferences(declaration: KtNamedDeclaration, useScope: SearchScope): Boolean { return !ReferencesSearch.search(declaration, useScope).forEach(Processor { assert(it != null, { "Found reference is null, was looking for: " + declaration.getElementTextWithContext() }) - declaration.isAncestor(it.getElement()) || + declaration.isAncestor(it.element) || it.element.parent is KtValueArgumentName || it.element.getParentOfType(false) != null }) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddBracesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddBracesIntention.kt index 8e96818f020..eb485dec0d9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddBracesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddBracesIntention.kt @@ -21,7 +21,7 @@ import com.intellij.psi.PsiWhiteSpace import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class AddBracesIntention : SelfTargetingIntention(KtExpression::class.java, "Add braces") { +class AddBracesIntention : SelfTargetingIntention(KtExpression::class.java, "Add braces") { override fun isApplicableTo(element: KtExpression, caretOffset: Int): Boolean { val expression = element.getTargetExpression(caretOffset) ?: return false if (expression is KtBlockExpression) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt index 38d443e918e..20b5de67507 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class AddForLoopIndicesIntention : SelfTargetingRangeIntention(KtForExpression::class.java, "Add indices to 'for' loop"), LowPriorityAction { +class AddForLoopIndicesIntention : SelfTargetingRangeIntention(KtForExpression::class.java, "Add indices to 'for' loop"), LowPriorityAction { private val WITH_INDEX_NAME = "withIndex" private val WITH_INDEX_FQ_NAMES = listOf("collections", "sequences", "text", "ranges").map { "kotlin.$it.$WITH_INDEX_NAME" }.toSet() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt index 702ce33a5b1..af99183d9e7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatchStatus import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class AddNameToArgumentIntention +class AddNameToArgumentIntention : SelfTargetingIntention(KtValueArgument::class.java, "Add name to argument"), LowPriorityAction { override fun isApplicableTo(element: KtValueArgument, caretOffset: Int): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt index bb591c5d4f0..76a5b10f40f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.psi.psiUtil.visibilityModifier import org.jetbrains.kotlin.resolve.BindingContext -public open class ChangeVisibilityModifierIntention protected constructor( +open class ChangeVisibilityModifierIntention protected constructor( val modifier: KtModifierKeywordToken ) : SelfTargetingRangeIntention(KtDeclaration::class.java, "Make ${modifier.value}") { @@ -111,9 +111,9 @@ public open class ChangeVisibilityModifierIntention protected constructor( } } - public class Public : ChangeVisibilityModifierIntention(KtTokens.PUBLIC_KEYWORD), HighPriorityAction + class Public : ChangeVisibilityModifierIntention(KtTokens.PUBLIC_KEYWORD), HighPriorityAction - public class Private : ChangeVisibilityModifierIntention(KtTokens.PRIVATE_KEYWORD), HighPriorityAction { + class Private : ChangeVisibilityModifierIntention(KtTokens.PRIVATE_KEYWORD), HighPriorityAction { override fun applicabilityRange(element: KtDeclaration): TextRange? { return if (canBePrivate(element)) super.applicabilityRange(element) else null } @@ -124,7 +124,7 @@ public open class ChangeVisibilityModifierIntention protected constructor( } } - public class Protected : ChangeVisibilityModifierIntention(KtTokens.PROTECTED_KEYWORD) { + class Protected : ChangeVisibilityModifierIntention(KtTokens.PROTECTED_KEYWORD) { override fun applicabilityRange(element: KtDeclaration): TextRange? { return if (canBeProtected(element)) super.applicabilityRange(element) else null } @@ -138,5 +138,5 @@ public open class ChangeVisibilityModifierIntention protected constructor( } } - public class Internal : ChangeVisibilityModifierIntention(KtTokens.INTERNAL_KEYWORD) + class Internal : ChangeVisibilityModifierIntention(KtTokens.INTERNAL_KEYWORD) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt index d8fdf1c9292..dfe3b405f48 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt @@ -25,7 +25,7 @@ import com.intellij.codeInsight.template.impl.TemplateManagerImpl import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil //TODO: move it somewhere else and reuse -public abstract class ChooseValueExpression( +abstract class ChooseValueExpression( lookupItems: Collection, protected val defaultItem: T, private val advertisementText: String? = null @@ -57,7 +57,7 @@ public abstract class ChooseValueExpression( override fun getAdvertisingText() = advertisementText } -public class ChooseStringExpression( +class ChooseStringExpression( suggestions: Collection, default: String = suggestions.first(), advertisementText: String? = null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt index cf32d22c96c..58abcea9bd4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.addToStdlib.check -public class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention(KtCallExpression::class.java, "Replace 'assert' with 'if' statement"), LowPriorityAction { +class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention(KtCallExpression::class.java, "Replace 'assert' with 'if' statement"), LowPriorityAction { override fun isApplicableTo(element: KtCallExpression, caretOffset: Int): Boolean { val callee = element.calleeExpression ?: return false if (!callee.textRange.containsOffset(caretOffset)) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertForEachToForLoopIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertForEachToForLoopIntention.kt index ec16f9e07c8..ec3110c7baf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertForEachToForLoopIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertForEachToForLoopIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver -public class ConvertForEachToForLoopIntention : SelfTargetingOffsetIndependentIntention(KtSimpleNameExpression::class.java, "Replace with a 'for' loop") { +class ConvertForEachToForLoopIntention : SelfTargetingOffsetIndependentIntention(KtSimpleNameExpression::class.java, "Replace with a 'for' loop") { private val FOR_EACH_NAME = "forEach" private val FOR_EACH_FQ_NAMES = listOf("collections", "sequences", "text", "ranges").map { "kotlin.$it.$FOR_EACH_NAME" }.toSet() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt index aacfdd1d25c..63f0f73986b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt @@ -56,7 +56,7 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.types.typeUtil.supertypes import java.util.* -public class ConvertFunctionToPropertyIntention : SelfTargetingIntention(KtNamedFunction::class.java, "Convert function to property"), LowPriorityAction { +class ConvertFunctionToPropertyIntention : SelfTargetingIntention(KtNamedFunction::class.java, "Convert function to property"), LowPriorityAction { private var KtNamedFunction.typeFqNameToAdd: String? by UserDataProperty(Key.create("TYPE_FQ_NAME_TO_ADD")) private inner class Converter( diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertIfWithThrowToAssertIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertIfWithThrowToAssertIntention.kt index c91860cb2e1..8febe906cc2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertIfWithThrowToAssertIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertIfWithThrowToAssertIntention.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -public class ConvertIfWithThrowToAssertIntention : SelfTargetingOffsetIndependentIntention(KtIfExpression::class.java, "Replace 'if' with 'assert' statement") { +class ConvertIfWithThrowToAssertIntention : SelfTargetingOffsetIndependentIntention(KtIfExpression::class.java, "Replace 'if' with 'assert' statement") { override fun isApplicableTo(element: KtIfExpression): Boolean { if (element.`else` != null) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedBooleanSequenceIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedBooleanSequenceIntention.kt index 35977f09553..720ef7fd617 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedBooleanSequenceIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedBooleanSequenceIntention.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import java.util.* -public class ConvertNegatedBooleanSequenceIntention : SelfTargetingOffsetIndependentIntention( +class ConvertNegatedBooleanSequenceIntention : SelfTargetingOffsetIndependentIntention( KtBinaryExpression::class.java, "Replace negated sequence with DeMorgan equivalent" ) { override fun isApplicableTo(element: KtBinaryExpression): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt index 817a3b17406..9d6f3c36d16 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import java.util.* -public class ConvertNegatedExpressionWithDemorgansLawIntention : SelfTargetingOffsetIndependentIntention(KtPrefixExpression::class.java, "DeMorgan Law") { +class ConvertNegatedExpressionWithDemorgansLawIntention : SelfTargetingOffsetIndependentIntention(KtPrefixExpression::class.java, "DeMorgan Law") { override fun isApplicableTo(element: KtPrefixExpression): Boolean { val prefixOperator = element.operationReference.getReferencedNameElementType() if (prefixOperator != KtTokens.EXCL) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertParameterToReceiverIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertParameterToReceiverIntention.kt index 518a89100e6..f047f3fa1bc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertParameterToReceiverIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertParameterToReceiverIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.BindingContext -public class ConvertParameterToReceiverIntention : SelfTargetingIntention(KtParameter::class.java, "Convert parameter to receiver") { +class ConvertParameterToReceiverIntention : SelfTargetingIntention(KtParameter::class.java, "Convert parameter to receiver") { override fun isApplicableTo(element: KtParameter, caretOffset: Int): Boolean { val identifier = element.nameIdentifier ?: return false if (!identifier.textRange.containsOffset(caretOffset)) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt index f9bad3bf3d8..55a4d9e7f4a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt @@ -50,7 +50,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.utils.findFunction import java.util.* -public class ConvertPropertyToFunctionIntention : SelfTargetingIntention(KtProperty::class.java, "Convert property to function"), LowPriorityAction { +class ConvertPropertyToFunctionIntention : SelfTargetingIntention(KtProperty::class.java, "Convert property to function"), LowPriorityAction { private inner class Converter( project: Project, descriptor: CallableDescriptor diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt index f1d02178296..a837a547638 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.resolve.BindingContext -public class ConvertReceiverToParameterIntention : SelfTargetingOffsetIndependentIntention(KtTypeReference::class.java, "Convert receiver to parameter"), LowPriorityAction { +class ConvertReceiverToParameterIntention : SelfTargetingOffsetIndependentIntention(KtTypeReference::class.java, "Convert receiver to parameter"), LowPriorityAction { override fun isApplicableTo(element: KtTypeReference): Boolean { return (element.parent as? KtNamedFunction)?.receiverTypeReference == element } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt index e0dc87803f7..2ee6ddb89ad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.KotlinType -public class ConvertToBlockBodyIntention : SelfTargetingIntention( +class ConvertToBlockBodyIntention : SelfTargetingIntention( KtDeclarationWithBody::class.java, "Convert to block body" ), LowPriorityAction { override fun isApplicableTo(element: KtDeclarationWithBody, caretOffset: Int): Boolean { @@ -52,7 +52,7 @@ public class ConvertToBlockBodyIntention : SelfTargetingIntention(KtStringTemplateExpression::class.java, "Convert template to concatenated string"), LowPriorityAction { +class ConvertToConcatenatedStringIntention : SelfTargetingOffsetIndependentIntention(KtStringTemplateExpression::class.java, "Convert template to concatenated string"), LowPriorityAction { override fun isApplicableTo(element: KtStringTemplateExpression): Boolean { if (element.lastChild.node.elementType != KtTokens.CLOSING_QUOTE) return false // not available for unclosed literal return element.entries.any { it is KtStringTemplateEntryWithExpression } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt index 2cc7cdfdb81..af081849082 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.utils.addToStdlib.check -public class ConvertToExpressionBodyIntention : SelfTargetingOffsetIndependentIntention( +class ConvertToExpressionBodyIntention : SelfTargetingOffsetIndependentIntention( KtDeclarationWithBody::class.java, "Convert to expression body" ) { override fun isApplicableTo(element: KtDeclarationWithBody): Boolean { @@ -51,7 +51,7 @@ public class ConvertToExpressionBodyIntention : SelfTargetingOffsetIndependentIn } } - public fun applyTo(declaration: KtDeclarationWithBody, canDeleteTypeRef: Boolean) { + fun applyTo(declaration: KtDeclarationWithBody, canDeleteTypeRef: Boolean) { val deleteTypeHandler: (KtCallableDeclaration) -> Unit = { it.deleteChildRange(it.colon!!, it.typeReference!!) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToForEachFunctionCallIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToForEachFunctionCallIntention.kt index 89ce9281668..653d2dcd3fe 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToForEachFunctionCallIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToForEachFunctionCallIntention.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.createExpressionByPattern import org.jetbrains.kotlin.psi.psiUtil.contentRange import org.jetbrains.kotlin.psi.psiUtil.endOffset -public class ConvertToForEachFunctionCallIntention : SelfTargetingIntention(KtForExpression::class.java, "Replace with a 'forEach' function call") { +class ConvertToForEachFunctionCallIntention : SelfTargetingIntention(KtForExpression::class.java, "Replace with a 'forEach' function call") { override fun isApplicableTo(element: KtForExpression, caretOffset: Int): Boolean { val rParen = element.rightParenthesis ?: return false if (caretOffset > rParen.endOffset) return false // available only on the loop header, not in the body diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt index 0370c9ad51a..87a8d9b361f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt @@ -27,12 +27,12 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator -public class ConvertToStringTemplateInspection : IntentionBasedInspection( +class ConvertToStringTemplateInspection : IntentionBasedInspection( ConvertToStringTemplateIntention(), { ConvertToStringTemplateIntention().shouldSuggestToConvert(it) } ) -public class ConvertToStringTemplateIntention : SelfTargetingOffsetIndependentIntention(KtBinaryExpression::class.java, "Convert concatenation to template") { +class ConvertToStringTemplateIntention : SelfTargetingOffsetIndependentIntention(KtBinaryExpression::class.java, "Convert concatenation to template") { override fun isApplicableTo(element: KtBinaryExpression): Boolean { if (!isApplicableToNoParentCheck(element)) return false @@ -46,11 +46,11 @@ public class ConvertToStringTemplateIntention : SelfTargetingOffsetIndependentIn applyTo(element) } - public fun applyTo(element: KtBinaryExpression): KtStringTemplateExpression { + fun applyTo(element: KtBinaryExpression): KtStringTemplateExpression { return element.replaced(buildReplacement(element)) } - public fun shouldSuggestToConvert(expression: KtBinaryExpression): Boolean { + fun shouldSuggestToConvert(expression: KtBinaryExpression): Boolean { val entries = buildReplacement(expression).entries return entries.none { it is KtBlockStringTemplateEntry } && !entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt index 139fef814b6..0a390d622c8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt @@ -42,9 +42,9 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.types.typeUtil.isUnit import java.util.* -public class DeprecatedCallableAddReplaceWithInspection : IntentionBasedInspection(DeprecatedCallableAddReplaceWithIntention()) +class DeprecatedCallableAddReplaceWithInspection : IntentionBasedInspection(DeprecatedCallableAddReplaceWithIntention()) -public class DeprecatedCallableAddReplaceWithIntention : SelfTargetingRangeIntention( +class DeprecatedCallableAddReplaceWithIntention : SelfTargetingRangeIntention( KtCallableDeclaration::class.java, "Add 'replaceWith' argument to specify replacement pattern", "Add 'replaceWith' argument to 'Deprecated' annotation" ) { private class ReplaceWith(val expression: String, vararg val imports: String) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt index 65f0d4a71f2..39a2cf49532 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt @@ -34,9 +34,9 @@ import org.jetbrains.kotlin.types.typeUtil.isNothing import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.* -public class IfNullToElvisInspection : IntentionBasedInspection(IfNullToElvisIntention()) +class IfNullToElvisInspection : IntentionBasedInspection(IfNullToElvisIntention()) -public class IfNullToElvisIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' with elvis operator"){ +class IfNullToElvisIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' with elvis operator"){ override fun applicabilityRange(element: KtIfExpression): TextRange? { val data = calcData(element) ?: return null @@ -52,7 +52,7 @@ public class IfNullToElvisIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace infix call with ordinary call") { +class InfixCallToOrdinaryIntention : SelfTargetingIntention(KtBinaryExpression::class.java, "Replace infix call with ordinary call") { override fun isApplicableTo(element: KtBinaryExpression, caretOffset: Int): Boolean { if (element.operationToken != KtTokens.IDENTIFIER || element.left == null || element.right == null) return false return element.operationReference.textRange.containsOffset(caretOffset) @@ -31,7 +31,7 @@ public class InfixCallToOrdinaryIntention : SelfTargetingIntention " $2:'{}'" diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/InsertCurlyBracesToTemplateIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/InsertCurlyBracesToTemplateIntention.kt index af9ee776568..68715a9c416 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/InsertCurlyBracesToTemplateIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/InsertCurlyBracesToTemplateIntention.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtSimpleNameStringTemplateEntry -public class InsertCurlyBracesToTemplateIntention : SelfTargetingOffsetIndependentIntention ( +class InsertCurlyBracesToTemplateIntention : SelfTargetingOffsetIndependentIntention ( KtSimpleNameStringTemplateEntry::class.java, "Insert curly braces around variable"), LowPriorityAction { override fun isApplicableTo(element: KtSimpleNameStringTemplateEntry): Boolean = true diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt index 04793ced37b..82cae25bf9b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.types.ErrorUtils -public class InsertExplicitTypeArgumentsIntention : SelfTargetingRangeIntention(KtCallExpression::class.java, "Add explicit type arguments"), LowPriorityAction { +class InsertExplicitTypeArgumentsIntention : SelfTargetingRangeIntention(KtCallExpression::class.java, "Add explicit type arguments"), LowPriorityAction { override fun applicabilityRange(element: KtCallExpression): TextRange? { return if (isApplicableTo(element, element.analyze())) element.calleeExpression!!.textRange else null } @@ -44,7 +44,7 @@ public class InsertExplicitTypeArgumentsIntention : SelfTargetingRangeIntention< } companion object { - public fun isApplicableTo(element: KtCallExpression, bindingContext: BindingContext): Boolean { + fun isApplicableTo(element: KtCallExpression, bindingContext: BindingContext): Boolean { if (!element.typeArguments.isEmpty()) return false if (element.calleeExpression == null) return false @@ -53,7 +53,7 @@ public class InsertExplicitTypeArgumentsIntention : SelfTargetingRangeIntention< return typeArgs.isNotEmpty() && typeArgs.values.none { ErrorUtils.containsErrorType(it) } } - public fun createTypeArguments(element: KtCallExpression, bindingContext: BindingContext): KtTypeArgumentList? { + fun createTypeArguments(element: KtCallExpression, bindingContext: BindingContext): KtTypeArgumentList? { val resolvedCall = element.getResolvedCall(bindingContext) ?: return null val args = resolvedCall.typeArguments diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt index e3b91ede31c..ed438b70bd9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import org.jetbrains.kotlin.utils.addToStdlib.lastIsInstanceOrNull -public class InvertIfConditionIntention : SelfTargetingIntention(KtIfExpression::class.java, "Invert 'if' condition") { +class InvertIfConditionIntention : SelfTargetingIntention(KtIfExpression::class.java, "Invert 'if' condition") { override fun isApplicableTo(element: KtIfExpression, caretOffset: Int): Boolean { if (!element.ifKeyword.textRange.containsOffset(caretOffset)) return false return element.condition != null && element.then != null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt index 5c8c9c200cf..2b9925e9f52 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addToStdlib.singletonList -public class IterateExpressionIntention : SelfTargetingIntention(KtExpression::class.java, "Iterate over collection"), HighPriorityAction { +class IterateExpressionIntention : SelfTargetingIntention(KtExpression::class.java, "Iterate over collection"), HighPriorityAction { override fun isApplicableTo(element: KtExpression, caretOffset: Int): Boolean { if (element.parent !is KtBlockExpression) return false val range = element.textRange diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveAssignmentToInitializerIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveAssignmentToInitializerIntention.kt index 308cc19d47c..8201cba18d3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveAssignmentToInitializerIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveAssignmentToInitializerIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -public class MoveAssignmentToInitializerIntention : +class MoveAssignmentToInitializerIntention : SelfTargetingIntention(KtBinaryExpression::class.java, "Move assignment to initializer") { override fun isApplicableTo(element: KtBinaryExpression, caretOffset: Int): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaInsideParenthesesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaInsideParenthesesIntention.kt index 3605a2902b7..b0bcbd9185d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaInsideParenthesesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaInsideParenthesesIntention.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.core.moveInsideParentheses import org.jetbrains.kotlin.psi.KtLambdaArgument import org.jetbrains.kotlin.psi.psiUtil.containsInside -public class MoveLambdaInsideParenthesesIntention : SelfTargetingIntention(KtLambdaArgument::class.java, "Move lambda argument into parentheses"), LowPriorityAction { +class MoveLambdaInsideParenthesesIntention : SelfTargetingIntention(KtLambdaArgument::class.java, "Move lambda argument into parentheses"), LowPriorityAction { override fun isApplicableTo(element: KtLambdaArgument, caretOffset: Int): Boolean { val body = element.getLambdaExpression().bodyExpression ?: return true return !body.textRange.containsInside(caretOffset) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt index 0d03ad494a4..c05c3a60a5b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.unpackFunctionLiteral import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class MoveLambdaOutsideParenthesesIntention : SelfTargetingIntention(KtCallExpression::class.java, "Move lambda argument out of parentheses") { +class MoveLambdaOutsideParenthesesIntention : SelfTargetingIntention(KtCallExpression::class.java, "Move lambda argument out of parentheses") { override fun isApplicableTo(element: KtCallExpression, caretOffset: Int): Boolean { if (element.lambdaArguments.isNotEmpty()) return false val argument = element.valueArguments.lastOrNull() ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReconstructTypeInCastOrIsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReconstructTypeInCastOrIsIntention.kt index 99f522a647b..5764996bb11 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReconstructTypeInCastOrIsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReconstructTypeInCastOrIsIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.KotlinType -public class ReconstructTypeInCastOrIsIntention : SelfTargetingOffsetIndependentIntention(KtTypeReference::class.java, "Replace by reconstructed type"), LowPriorityAction { +class ReconstructTypeInCastOrIsIntention : SelfTargetingOffsetIndependentIntention(KtTypeReference::class.java, "Replace by reconstructed type"), LowPriorityAction { override fun isApplicableTo(element: KtTypeReference): Boolean { // Only user types (like Foo) are interesting val typeElement = element.typeElement as? KtUserType ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt index cba5fe1eae8..3341e64216d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class RemoveArgumentNameIntention +class RemoveArgumentNameIntention : SelfTargetingRangeIntention(KtValueArgument::class.java, "Remove argument name") { override fun applicabilityRange(element: KtValueArgument): TextRange? { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt index a1949abb032..d41e9a46df6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt @@ -21,7 +21,7 @@ import com.intellij.psi.PsiComment import com.intellij.psi.PsiWhiteSpace import org.jetbrains.kotlin.psi.* -public class RemoveBracesIntention : SelfTargetingIntention(KtBlockExpression::class.java, "Remove braces") { +class RemoveBracesIntention : SelfTargetingIntention(KtBlockExpression::class.java, "Remove braces") { override fun isApplicableTo(element: KtBlockExpression, caretOffset: Int): Boolean { if (element.statements.size != 1) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveCurlyBracesFromTemplateIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveCurlyBracesFromTemplateIntention.kt index 24d956ef276..7c94258389b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveCurlyBracesFromTemplateIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveCurlyBracesFromTemplateIntention.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtStringTemplateEntryWithExpression import org.jetbrains.kotlin.psi.psiUtil.canPlaceAfterSimpleNameEntry -public class RemoveCurlyBracesFromTemplateInspection : IntentionBasedInspection(RemoveCurlyBracesFromTemplateIntention()) +class RemoveCurlyBracesFromTemplateInspection : IntentionBasedInspection(RemoveCurlyBracesFromTemplateIntention()) -public class RemoveCurlyBracesFromTemplateIntention : SelfTargetingOffsetIndependentIntention(KtBlockStringTemplateEntry::class.java, "Remove curly braces") { +class RemoveCurlyBracesFromTemplateIntention : SelfTargetingOffsetIndependentIntention(KtBlockStringTemplateEntry::class.java, "Remove curly braces") { override fun isApplicableTo(element: KtBlockStringTemplateEntry): Boolean { if (element.expression !is KtNameReferenceExpression) return false return canPlaceAfterSimpleNameEntry(element.nextSibling) @@ -37,7 +37,7 @@ public class RemoveCurlyBracesFromTemplateIntention : SelfTargetingOffsetIndepen applyTo(element) } - public fun applyTo(element: KtBlockStringTemplateEntry): KtStringTemplateEntryWithExpression { + fun applyTo(element: KtBlockStringTemplateEntry): KtStringTemplateEntryWithExpression { val name = (element.expression as KtNameReferenceExpression).getReferencedName() val newEntry = KtPsiFactory(element).createSimpleNameStringTemplateEntry(name) return element.replaced(newEntry) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitLambdaParameterTypesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitLambdaParameterTypesIntention.kt index 1ea6166afa3..d7d4b62a277 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitLambdaParameterTypesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitLambdaParameterTypesIntention.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.psi.KtLambdaExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.endOffset -public class RemoveExplicitLambdaParameterTypesIntention : SelfTargetingIntention(KtLambdaExpression::class.java, "Remove explicit lambda parameter types (may break code)") { +class RemoveExplicitLambdaParameterTypesIntention : SelfTargetingIntention(KtLambdaExpression::class.java, "Remove explicit lambda parameter types (may break code)") { override fun isApplicableTo(element: KtLambdaExpression, caretOffset: Int): Boolean { if (element.valueParameters.none { it.typeReference != null }) return false val arrow = element.functionLiteral.arrow ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt index 795d8629dc2..4e1b871766d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt @@ -39,12 +39,12 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.TypeUtils -public class RemoveExplicitSuperQualifierInspection : IntentionBasedInspection(RemoveExplicitSuperQualifierIntention()), CleanupLocalInspectionTool { +class RemoveExplicitSuperQualifierInspection : IntentionBasedInspection(RemoveExplicitSuperQualifierIntention()), CleanupLocalInspectionTool { override val problemHighlightType: ProblemHighlightType get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL } -public class RemoveExplicitSuperQualifierIntention : SelfTargetingRangeIntention(KtSuperExpression::class.java, "Remove explicit supertype qualification") { +class RemoveExplicitSuperQualifierIntention : SelfTargetingRangeIntention(KtSuperExpression::class.java, "Remove explicit supertype qualification") { override fun applicabilityRange(element: KtSuperExpression): TextRange? { if (element.superTypeQualifier == null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt index 8bfa5939eb3..7f3d9f5df06 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt @@ -34,14 +34,14 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -public class RemoveExplicitTypeArgumentsInspection : IntentionBasedInspection(RemoveExplicitTypeArgumentsIntention()) { +class RemoveExplicitTypeArgumentsInspection : IntentionBasedInspection(RemoveExplicitTypeArgumentsIntention()) { override val problemHighlightType: ProblemHighlightType get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL } -public class RemoveExplicitTypeArgumentsIntention : SelfTargetingOffsetIndependentIntention(KtTypeArgumentList::class.java, "Remove explicit type arguments") { +class RemoveExplicitTypeArgumentsIntention : SelfTargetingOffsetIndependentIntention(KtTypeArgumentList::class.java, "Remove explicit type arguments") { companion object { - public fun isApplicableTo(element: KtTypeArgumentList, approximateFlexible: Boolean): Boolean { + fun isApplicableTo(element: KtTypeArgumentList, approximateFlexible: Boolean): Boolean { val callExpression = element.parent as? KtCallExpression ?: return false if (callExpression.typeArguments.isEmpty()) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt index a4b8222cbac..100c301c290 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.psi.* -public class RemoveExplicitTypeIntention : SelfTargetingIntention(KtCallableDeclaration::class.java, "Remove explicit type specification") { +class RemoveExplicitTypeIntention : SelfTargetingIntention(KtCallableDeclaration::class.java, "Remove explicit type specification") { override fun isApplicableTo(element: KtCallableDeclaration, caretOffset: Int): Boolean { if (element.containingFile is KtCodeFragment) return false if (element.typeReference == null) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt index 1a84079fd4a..08b76dabb21 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class RemoveForLoopIndicesInspection : IntentionBasedInspection( +class RemoveForLoopIndicesInspection : IntentionBasedInspection( listOf(IntentionBasedInspection.IntentionData(RemoveForLoopIndicesIntention())), "Index is not used in the loop body", KtForExpression::class.java @@ -40,7 +40,7 @@ public class RemoveForLoopIndicesInspection : IntentionBasedInspection(KtForExpression::class.java, "Remove indices in 'for' loop") { +class RemoveForLoopIndicesIntention : SelfTargetingRangeIntention(KtForExpression::class.java, "Remove indices in 'for' loop") { private val WITH_INDEX_NAME = "withIndex" private val WITH_INDEX_FQ_NAMES = listOf("collections", "sequences", "text", "ranges").map { "kotlin.$it.$WITH_INDEX_NAME" }.toSet() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt index e36dfac7cac..ea1bf506828 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.psi.KtParenthesizedExpression import org.jetbrains.kotlin.psi.KtPsiUtil -public class RemoveUnnecessaryParenthesesIntention : SelfTargetingRangeIntention(KtParenthesizedExpression::class.java, "Remove unnecessary parentheses") { +class RemoveUnnecessaryParenthesesIntention : SelfTargetingRangeIntention(KtParenthesizedExpression::class.java, "Remove unnecessary parentheses") { override fun applicabilityRange(element: KtParenthesizedExpression): TextRange? { element.expression ?: return null if (!KtPsiUtil.areParenthesesUseless(element)) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt index c9f63b26f87..07605316939 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBaseIntentionAction() { +class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBaseIntentionAction() { override fun getFamilyName() = "Replace explicit lambda parameter with 'it'" override fun isAvailable(project: Project, editor: Editor, element: PsiElement): Boolean { @@ -80,7 +80,7 @@ public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBa false, false ) { - public override fun performRefactoring(usages: Array) { + override fun performRefactoring(usages: Array) { super.performRefactoring(usages) functionLiteral.deleteChildRange(functionLiteral.valueParameterList, functionLiteral.arrow!!) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt index de9508e7965..b5639e77166 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtNameReferenceExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -public class ReplaceItWithExplicitFunctionLiteralParamIntention() : SelfTargetingOffsetIndependentIntention ( +class ReplaceItWithExplicitFunctionLiteralParamIntention() : SelfTargetingOffsetIndependentIntention ( KtNameReferenceExpression::class.java, "Replace 'it' with explicit parameter" ), LowPriorityAction { override fun isApplicableTo(element: KtNameReferenceExpression) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt index bce29871daf..a0087ffb4ab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt @@ -29,9 +29,9 @@ import org.jetbrains.kotlin.psi.KtNameReferenceExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.resolve.BindingContext -public class ReplaceWithOperatorAssignmentInspection : IntentionBasedInspection(ReplaceWithOperatorAssignmentIntention()) +class ReplaceWithOperatorAssignmentInspection : IntentionBasedInspection(ReplaceWithOperatorAssignmentIntention()) -public class ReplaceWithOperatorAssignmentIntention : SelfTargetingOffsetIndependentIntention(KtBinaryExpression::class.java, "Replace with operator-assignment") { +class ReplaceWithOperatorAssignmentIntention : SelfTargetingOffsetIndependentIntention(KtBinaryExpression::class.java, "Replace with operator-assignment") { override fun isApplicableTo(element: KtBinaryExpression): Boolean { if (element.operationToken != KtTokens.EQ) return false val left = element.left as? KtNameReferenceExpression ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOrdinaryAssignmentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOrdinaryAssignmentIntention.kt index e880e1fac55..eeb3bf5ae99 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOrdinaryAssignmentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOrdinaryAssignmentIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtNameReferenceExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.createExpressionByPattern -public class ReplaceWithOrdinaryAssignmentIntention : SelfTargetingIntention(KtBinaryExpression::class.java, "Replace with ordinary assignment"), LowPriorityAction { +class ReplaceWithOrdinaryAssignmentIntention : SelfTargetingIntention(KtBinaryExpression::class.java, "Replace with ordinary assignment"), LowPriorityAction { override fun isApplicableTo(element: KtBinaryExpression, caretOffset: Int): Boolean { if (element.operationToken !in KtTokens.AUGMENTED_ASSIGNMENTS) return false if (element.left !is KtNameReferenceExpression) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt index 4523640020f..dd5b1d3c2ae 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils import org.jetbrains.kotlin.resolve.DelegatingBindingTrace -public class SimplifyBooleanWithConstantsInspection : IntentionBasedInspection(SimplifyBooleanWithConstantsIntention()) +class SimplifyBooleanWithConstantsInspection : IntentionBasedInspection(SimplifyBooleanWithConstantsIntention()) -public class SimplifyBooleanWithConstantsIntention : SelfTargetingOffsetIndependentIntention(KtBinaryExpression::class.java, "Simplify boolean expression") { +class SimplifyBooleanWithConstantsIntention : SelfTargetingOffsetIndependentIntention(KtBinaryExpression::class.java, "Simplify boolean expression") { override fun isApplicableTo(element: KtBinaryExpression): Boolean { val topBinary = PsiTreeUtil.getTopmostParentOfType(element, KtBinaryExpression::class.java) ?: element diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt index 51947f55da8..f8d403af7b7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt @@ -24,9 +24,9 @@ import org.jetbrains.kotlin.lexer.KtSingleValueToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -public class SimplifyNegatedBinaryExpressionInspection : IntentionBasedInspection(SimplifyNegatedBinaryExpressionIntention()) +class SimplifyNegatedBinaryExpressionInspection : IntentionBasedInspection(SimplifyNegatedBinaryExpressionIntention()) -public class SimplifyNegatedBinaryExpressionIntention : SelfTargetingRangeIntention(KtPrefixExpression::class.java, "Simplify negated binary expression") { +class SimplifyNegatedBinaryExpressionIntention : SelfTargetingRangeIntention(KtPrefixExpression::class.java, "Simplify negated binary expression") { private fun IElementType.negate(): KtSingleValueToken? = when (this) { KtTokens.IN_KEYWORD -> KtTokens.NOT_IN @@ -51,7 +51,7 @@ public class SimplifyNegatedBinaryExpressionIntention : SelfTargetingRangeIntent return if (isApplicableTo(element)) element.operationReference.textRange else null } - public fun isApplicableTo(element: KtPrefixExpression): Boolean { + fun isApplicableTo(element: KtPrefixExpression): Boolean { if (element.operationToken != KtTokens.EXCL) return false val expression = KtPsiUtil.deparenthesize(element.baseExpression) as? KtOperationExpression ?: return false @@ -72,7 +72,7 @@ public class SimplifyNegatedBinaryExpressionIntention : SelfTargetingRangeIntent applyTo(element) } - public fun applyTo(element: KtPrefixExpression) { + fun applyTo(element: KtPrefixExpression) { val expression = KtPsiUtil.deparenthesize(element.baseExpression)!! val operation = (expression as KtOperationExpression).operationReference.getReferencedNameElementType().negate()!!.value diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyExplicitLambdaSignatureIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyExplicitLambdaSignatureIntention.kt index 7a1e640a146..7a721cb2a0b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyExplicitLambdaSignatureIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyExplicitLambdaSignatureIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.resolve.BindingContext -public class SpecifyExplicitLambdaSignatureIntention : SelfTargetingIntention(KtLambdaExpression::class.java, "Specify explicit lambda signature"), LowPriorityAction { +class SpecifyExplicitLambdaSignatureIntention : SelfTargetingIntention(KtLambdaExpression::class.java, "Specify explicit lambda signature"), LowPriorityAction { override fun isApplicableTo(element: KtLambdaExpression, caretOffset: Int): Boolean { val arrow = element.functionLiteral.arrow diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt index c715237fc08..ab01b53ca62 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.utils.SmartSet import org.jetbrains.kotlin.utils.addToStdlib.singletonList -public class SpecifyTypeExplicitlyIntention : SelfTargetingIntention(KtCallableDeclaration::class.java, "Specify type explicitly"), LowPriorityAction { +class SpecifyTypeExplicitlyIntention : SelfTargetingIntention(KtCallableDeclaration::class.java, "Specify type explicitly"), LowPriorityAction { override fun isApplicableTo(element: KtCallableDeclaration, caretOffset: Int): Boolean { if (element.containingFile is KtCodeFragment) return false if (element is KtFunctionLiteral) return false // TODO: should JetFunctionLiteral be JetCallableDeclaration at all? @@ -58,13 +58,13 @@ public class SpecifyTypeExplicitlyIntention : SelfTargetingIntention(KtExpression::class.java, "Split if into 2 if's") { +class SplitIfIntention : SelfTargetingIntention(KtExpression::class.java, "Split if into 2 if's") { override fun isApplicableTo(element: KtExpression, caretOffset: Int): Boolean { return when (element) { is KtOperationReferenceExpression -> isOperatorValid(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt index e4b3032e93a..6430b0341d8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.createExpressionByPattern import org.jetbrains.kotlin.idea.core.copied import org.jetbrains.kotlin.types.expressions.OperatorConventions -public class SwapBinaryExpressionIntention : SelfTargetingIntention(KtBinaryExpression::class.java, "Flip binary expression"), LowPriorityAction { +class SwapBinaryExpressionIntention : SelfTargetingIntention(KtBinaryExpression::class.java, "Flip binary expression"), LowPriorityAction { companion object { private val SUPPORTED_OPERATIONS = setOf(PLUS, MUL, OROR, ANDAND, EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ, GT, LT, GTEQ, LTEQ) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ToInfixCallIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ToInfixCallIntention.kt index e73d82d07dd..c83dafb4e76 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ToInfixCallIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ToInfixCallIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class ToInfixCallIntention : SelfTargetingIntention(KtCallExpression::class.java, "Replace with infix function call") { +class ToInfixCallIntention : SelfTargetingIntention(KtCallExpression::class.java, "Replace with infix function call") { override fun isApplicableTo(element: KtCallExpression, caretOffset: Int): Boolean { val calleeExpr = element.calleeExpression as? KtNameReferenceExpression ?: return false if (!calleeExpr.textRange.containsOffset(caretOffset)) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index ca8587f340c..e3836f48b49 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -65,7 +65,7 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention applyTo(element, detectPropertyNameToUse(element)!!) } - public fun applyTo(element: KtCallExpression, propertyName: Name): KtExpression { + fun applyTo(element: KtCallExpression, propertyName: Name): KtExpression { val arguments = element.valueArguments return when (arguments.size) { 0 -> replaceWithPropertyGet(element, propertyName) @@ -74,7 +74,7 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention } } - public fun detectPropertyNameToUse(callExpression: KtCallExpression): Name? { + fun detectPropertyNameToUse(callExpression: KtCallExpression): Name? { if (callExpression.getQualifiedExpressionForSelector()?.receiverExpression is KtSuperExpression) return null // cannot call extensions on "super" val callee = callExpression.calleeExpression as? KtNameReferenceExpression ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt index 3a8e7b41f79..509417f02da 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt @@ -125,7 +125,7 @@ fun KtQualifiedExpression.isReceiverExpressionWithValue(): Boolean { return analyze().getType(receiver) != null } -public fun KtExpression.negate(): KtExpression { +fun KtExpression.negate(): KtExpression { val specialNegation = specialNegation() if (specialNegation != null) return specialNegation return KtPsiFactory(this).createExpressionByPattern("!$0", this) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt index c282151907f..bbe66cebed8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis import org.jetbrains.kotlin.utils.addToStdlib.check object BranchedFoldingUtils { - public fun getFoldableBranchedAssignment(branch: KtExpression?): KtBinaryExpression? { + fun getFoldableBranchedAssignment(branch: KtExpression?): KtBinaryExpression? { fun checkAssignment(expression: KtBinaryExpression): Boolean { if (expression.operationToken !in KtTokens.ALL_ASSIGNMENTS) return false @@ -39,11 +39,11 @@ object BranchedFoldingUtils { return (branch?.lastBlockStatementOrThis() as? KtBinaryExpression)?.check(::checkAssignment) } - public fun getFoldableBranchedReturn(branch: KtExpression?): KtReturnExpression? { + fun getFoldableBranchedReturn(branch: KtExpression?): KtReturnExpression? { return (branch?.lastBlockStatementOrThis() as? KtReturnExpression)?.check { it.returnedExpression != null } } - public fun checkAssignmentsMatch(a1: KtBinaryExpression, a2: KtBinaryExpression): Boolean { + fun checkAssignmentsMatch(a1: KtBinaryExpression, a2: KtBinaryExpression): Boolean { return a1.left?.text == a2.left?.text && a1.operationToken == a2.operationToken } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedUnfoldingUtils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedUnfoldingUtils.kt index 16ed422b8ed..499abcee38e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedUnfoldingUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedUnfoldingUtils.kt @@ -21,8 +21,8 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.idea.core.copied import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis -public object BranchedUnfoldingUtils { - public fun unfoldAssignmentToIf(assignment: KtBinaryExpression, editor: Editor) { +object BranchedUnfoldingUtils { + fun unfoldAssignmentToIf(assignment: KtBinaryExpression, editor: Editor) { val op = assignment.operationReference.text val left = assignment.left!! val ifExpression = assignment.right as KtIfExpression @@ -41,7 +41,7 @@ public object BranchedUnfoldingUtils { editor.caretModel.moveToOffset(resultIf.textOffset) } - public fun unfoldAssignmentToWhen(assignment: KtBinaryExpression, editor: Editor) { + fun unfoldAssignmentToWhen(assignment: KtBinaryExpression, editor: Editor) { val op = assignment.operationReference.text val left = assignment.left!! val whenExpression = assignment.right as KtWhenExpression diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/branchedTransformationUtils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/branchedTransformationUtils.kt index bcee51fd5b7..ef04932939a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/branchedTransformationUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/branchedTransformationUtils.kt @@ -47,7 +47,7 @@ fun KtWhenCondition.toExpression(subject: KtExpression?): KtExpression { } } -public fun KtWhenExpression.getSubjectToIntroduce(): KtExpression? { +fun KtWhenExpression.getSubjectToIntroduce(): KtExpression? { if (subjectExpression != null) return null var lastCandidate: KtExpression? = null @@ -97,7 +97,7 @@ private fun KtExpression?.getWhenConditionSubjectCandidate(): KtExpression? { } } -public fun KtWhenExpression.introduceSubject(): KtWhenExpression { +fun KtWhenExpression.introduceSubject(): KtWhenExpression { val subject = getSubjectToIntroduce()!! val whenExpression = KtPsiFactory(this).buildExpression { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/DoubleBangToIfThenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/DoubleBangToIfThenIntention.kt index 83ac8829a57..37f1918836f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/DoubleBangToIfThenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/DoubleBangToIfThenIntention.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtPsiUtil import org.jetbrains.kotlin.psi.KtThrowExpression import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement -public class DoubleBangToIfThenIntention : SelfTargetingRangeIntention(KtPostfixExpression::class.java, "Replace '!!' expression with 'if' expression"), LowPriorityAction { +class DoubleBangToIfThenIntention : SelfTargetingRangeIntention(KtPostfixExpression::class.java, "Replace '!!' expression with 'if' expression"), LowPriorityAction { override fun applicabilityRange(element: KtPostfixExpression): TextRange? { return if (element.operationToken == KtTokens.EXCLEXCL && element.baseExpression != null) element.operationReference.textRange diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt index f863a71a9fb..782c3b7a491 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtWhenExpression import org.jetbrains.kotlin.psi.buildExpression import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class EliminateWhenSubjectIntention : SelfTargetingIntention(KtWhenExpression::class.java, "Eliminate argument of 'when'"), LowPriorityAction { +class EliminateWhenSubjectIntention : SelfTargetingIntention(KtWhenExpression::class.java, "Eliminate argument of 'when'"), LowPriorityAction { override fun isApplicableTo(element: KtWhenExpression, caretOffset: Int): Boolean { if (element.subjectExpression !is KtNameReferenceExpression) return false val lBrace = element.openBrace ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/ElvisToIfThenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/ElvisToIfThenIntention.kt index 06469b1f6c6..31195fa0c56 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/ElvisToIfThenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/ElvisToIfThenIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtPsiUtil -public class ElvisToIfThenIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace elvis expression with 'if' expression"), LowPriorityAction { +class ElvisToIfThenIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace elvis expression with 'if' expression"), LowPriorityAction { override fun applicabilityRange(element: KtBinaryExpression): TextRange? { return if (element.operationToken == KtTokens.ELVIS && element.left != null && element.right != null) element.operationReference.textRange diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FlattenWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FlattenWhenIntention.kt index 4e2c39c27c1..b920e689aeb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FlattenWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FlattenWhenIntention.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class FlattenWhenIntention : SelfTargetingIntention(KtWhenExpression::class.java, "Flatten 'when' expression") { +class FlattenWhenIntention : SelfTargetingIntention(KtWhenExpression::class.java, "Flatten 'when' expression") { override fun isApplicableTo(element: KtWhenExpression, caretOffset: Int): Boolean { val subject = element.subjectExpression if (subject != null && subject !is KtNameReferenceExpression) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToAssignmentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToAssignmentIntention.kt index 36a0294c921..e1bc0593f40 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToAssignmentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToAssignmentIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtIfExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.createExpressionByPattern -public class FoldIfToAssignmentIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with assignment") { +class FoldIfToAssignmentIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with assignment") { override fun applicabilityRange(element: KtIfExpression): TextRange? { val thenAssignment = BranchedFoldingUtils.getFoldableBranchedAssignment(element.then) ?: return null val elseAssignment = BranchedFoldingUtils.getFoldableBranchedAssignment(element.`else`) ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.kt index a05dabd6f98..1a928e94350 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnAsymmetricallyIntention.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFoldingUtils import org.jetbrains.kotlin.psi.* -public class FoldIfToReturnAsymmetricallyIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with return") { +class FoldIfToReturnAsymmetricallyIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with return") { override fun applicabilityRange(element: KtIfExpression): TextRange? { if (BranchedFoldingUtils.getFoldableBranchedReturn(element.then) == null || element.`else` != null) { return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnIntention.kt index 03a03328373..ca2cdae72a8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldIfToReturnIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtIfExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.createExpressionByPattern -public class FoldIfToReturnIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with return") { +class FoldIfToReturnIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with return") { override fun applicabilityRange(element: KtIfExpression): TextRange? { if (BranchedFoldingUtils.getFoldableBranchedReturn(element.then) == null) return null if (BranchedFoldingUtils.getFoldableBranchedReturn(element.`else`) == null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToAssignmentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToAssignmentIntention.kt index 2e6ca969b6d..5ed4d4813e6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToAssignmentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToAssignmentIntention.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFold import org.jetbrains.kotlin.psi.* import java.util.* -public class FoldWhenToAssignmentIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Replace 'when' expression with assignment") { +class FoldWhenToAssignmentIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Replace 'when' expression with assignment") { override fun applicabilityRange(element: KtWhenExpression): TextRange? { if (!KtPsiUtil.checkWhenExpressionHasSingleElse(element)) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToReturnIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToReturnIntention.kt index ddedca905c6..319ca88716d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToReturnIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/FoldWhenToReturnIntention.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFoldingUtils import org.jetbrains.kotlin.psi.* -public class FoldWhenToReturnIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Replace 'when' expression with return") { +class FoldWhenToReturnIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Replace 'when' expression with return") { override fun applicabilityRange(element: KtWhenExpression): TextRange? { if (!KtPsiUtil.checkWhenExpressionHasSingleElse(element)) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToDoubleBangIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToDoubleBangIntention.kt index ef15771e8be..534f49d118c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToDoubleBangIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToDoubleBangIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement -public class IfThenToDoubleBangIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with '!!' expression") { +class IfThenToDoubleBangIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' expression with '!!' expression") { override fun applicabilityRange(element: KtIfExpression): TextRange? { val condition = element.condition as? KtBinaryExpression ?: return null val thenClause = element.then ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt index 4fb3476c4fb..5debf9bb893 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.idea.core.replaced -public class IfThenToElvisInspection : IntentionBasedInspection(IfThenToElvisIntention()) +class IfThenToElvisInspection : IntentionBasedInspection(IfThenToElvisIntention()) -public class IfThenToElvisIntention : SelfTargetingOffsetIndependentIntention(KtIfExpression::class.java, "Replace 'if' expression with elvis expression") { +class IfThenToElvisIntention : SelfTargetingOffsetIndependentIntention(KtIfExpression::class.java, "Replace 'if' expression with elvis expression") { override fun isApplicableTo(element: KtIfExpression): Boolean { val condition = element.condition as? KtBinaryExpression ?: return false @@ -61,7 +61,7 @@ public class IfThenToElvisIntention : SelfTargetingOffsetIndependentIntention(IfThenToSafeAccessIntention()) +class IfThenToSafeAccessInspection : IntentionBasedInspection(IfThenToSafeAccessIntention()) -public class IfThenToSafeAccessIntention : SelfTargetingOffsetIndependentIntention(KtIfExpression::class.java, "Replace 'if' expression with safe access expression") { +class IfThenToSafeAccessIntention : SelfTargetingOffsetIndependentIntention(KtIfExpression::class.java, "Replace 'if' expression with safe access expression") { override fun isApplicableTo(element: KtIfExpression): Boolean { val condition = element.condition as? KtBinaryExpression ?: return false @@ -55,7 +55,7 @@ public class IfThenToSafeAccessIntention : SelfTargetingOffsetIndependentIntenti safeAccessExpr.inlineReceiverIfApplicableWithPrompt(editor) } - public fun applyTo(element: KtIfExpression): KtSafeQualifiedExpression { + fun applyTo(element: KtIfExpression): KtSafeQualifiedExpression { val condition = element.condition as KtBinaryExpression val receiverExpression = condition.expressionComparedToNull()!! diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt index 0f88d989659..754adbd6096 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import java.util.* -public class IfToWhenIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' with 'when'") { +class IfToWhenIntention : SelfTargetingRangeIntention(KtIfExpression::class.java, "Replace 'if' with 'when'") { override fun applicabilityRange(element: KtIfExpression): TextRange? { if (element.then == null) return null return element.ifKeyword.textRange diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt index 5b76c1d5748..6076cb3ff3d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt @@ -24,9 +24,9 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.getSubjectTo import org.jetbrains.kotlin.idea.intentions.branchedTransformations.introduceSubject import org.jetbrains.kotlin.psi.KtWhenExpression -public class IntroduceWhenSubjectInspection : IntentionBasedInspection(IntroduceWhenSubjectIntention()) +class IntroduceWhenSubjectInspection : IntentionBasedInspection(IntroduceWhenSubjectIntention()) -public class IntroduceWhenSubjectIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Introduce argument to 'when'") { +class IntroduceWhenSubjectIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Introduce argument to 'when'") { override fun applicabilityRange(element: KtWhenExpression): TextRange? { val subject = element.getSubjectToIntroduce() ?: return null text = "Introduce '${subject.text}' as argument to 'when'" diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/MergeWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/MergeWhenIntention.kt index 7308ea0fa38..65f50d1b169 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/MergeWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/MergeWhenIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* -public class MergeWhenIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Merge with next 'when'", "Merge 'when' expressions") { +class MergeWhenIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Merge with next 'when'", "Merge 'when' expressions") { override fun applicabilityRange(element: KtWhenExpression): TextRange? { val next = PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace::class.java) as? KtWhenExpression ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt index 65b3d3b640d..600c2530d4e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isStableVari import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement -public class SafeAccessToIfThenIntention : SelfTargetingRangeIntention(KtSafeQualifiedExpression::class.java, "Replace safe access expression with 'if' expression"), LowPriorityAction { +class SafeAccessToIfThenIntention : SelfTargetingRangeIntention(KtSafeQualifiedExpression::class.java, "Replace safe access expression with 'if' expression"), LowPriorityAction { override fun applicabilityRange(element: KtSafeQualifiedExpression): TextRange? { if (element.selectorExpression == null) return null return element.operationTokenNode.textRange diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.kt index 62b95ffcdd5..08803299c24 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToIfIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtIfExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class UnfoldAssignmentToIfIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace assignment with 'if' expression"), LowPriorityAction { +class UnfoldAssignmentToIfIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace assignment with 'if' expression"), LowPriorityAction { override fun applicabilityRange(element: KtBinaryExpression): TextRange? { if (element.operationToken !in KtTokens.ALL_ASSIGNMENTS) return null if (element.left == null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.kt index f7ce1787923..d5a0b792ef3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldAssignmentToWhenIntention.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtWhenExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class UnfoldAssignmentToWhenIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace assignment with 'when' expression" ), LowPriorityAction { +class UnfoldAssignmentToWhenIntention : SelfTargetingRangeIntention(KtBinaryExpression::class.java, "Replace assignment with 'when' expression" ), LowPriorityAction { override fun applicabilityRange(element: KtBinaryExpression): TextRange? { if (element.operationToken !in KtTokens.ALL_ASSIGNMENTS) return null if (element.left == null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToIfIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToIfIntention.kt index 293733c218f..47571b1aad3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToIfIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToIfIntention.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class UnfoldPropertyToIfIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Replace property initializer with 'if' expression"), LowPriorityAction { +class UnfoldPropertyToIfIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Replace property initializer with 'if' expression"), LowPriorityAction { override fun applicabilityRange(element: KtProperty): TextRange? { if (!element.isLocal) return null val initializer = element.initializer as? KtIfExpression ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToWhenIntention.kt index c57ea36c094..58382e1414a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldPropertyToWhenIntention.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtWhenExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class UnfoldPropertyToWhenIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Replace property initializer with 'when' expression"), LowPriorityAction { +class UnfoldPropertyToWhenIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Replace property initializer with 'when' expression"), LowPriorityAction { override fun applicabilityRange(element: KtProperty): TextRange? { if (!element.isLocal) return null val initializer = element.initializer as? KtWhenExpression ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToIfIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToIfIntention.kt index 847672b5545..b934b8c18e2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToIfIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToIfIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class UnfoldReturnToIfIntention : SelfTargetingRangeIntention(KtReturnExpression::class.java, "Replace return with 'if' expression"), LowPriorityAction { +class UnfoldReturnToIfIntention : SelfTargetingRangeIntention(KtReturnExpression::class.java, "Replace return with 'if' expression"), LowPriorityAction { override fun applicabilityRange(element: KtReturnExpression): TextRange? { val ifExpression = element.returnedExpression as? KtIfExpression ?: return null return TextRange(element.startOffset, ifExpression.ifKeyword.endOffset) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToWhenIntention.kt index 5293db14b1e..3ffc506a964 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/UnfoldReturnToWhenIntention.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class UnfoldReturnToWhenIntention : SelfTargetingRangeIntention(KtReturnExpression::class.java, "Replace return with 'when' expression"), LowPriorityAction { +class UnfoldReturnToWhenIntention : SelfTargetingRangeIntention(KtReturnExpression::class.java, "Replace return with 'when' expression"), LowPriorityAction { override fun applicabilityRange(element: KtReturnExpression): TextRange? { val whenExpr = element.returnedExpression as? KtWhenExpression ?: return null if (!KtPsiUtil.checkWhenExpressionHasSingleElse(whenExpr)) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/WhenToIfIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/WhenToIfIntention.kt index e905b9dc4cc..2b6ab84719f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/WhenToIfIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/WhenToIfIntention.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.combineWhenConditions import org.jetbrains.kotlin.psi.* -public class WhenToIfIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Replace 'when' with 'if'"), LowPriorityAction { +class WhenToIfIntention : SelfTargetingRangeIntention(KtWhenExpression::class.java, "Replace 'when' with 'if'"), LowPriorityAction { override fun applicabilityRange(element: KtWhenExpression): TextRange? { val entries = element.entries if (entries.isEmpty()) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithBinaryOperatorIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithBinaryOperatorIntention.kt index 1786e793392..64d194d5068 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithBinaryOperatorIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithBinaryOperatorIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.expressions.OperatorConventions -public class ReplaceCallWithBinaryOperatorIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace call with binary operator"), HighPriorityAction { +class ReplaceCallWithBinaryOperatorIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace call with binary operator"), HighPriorityAction { override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? { val operation = operation(element.calleeName) ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithUnaryOperatorIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithUnaryOperatorIntention.kt index 5cbd45307a6..9d2c7954a5d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithUnaryOperatorIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceCallWithUnaryOperatorIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.createExpressionByPattern import org.jetbrains.kotlin.types.expressions.OperatorConventions -public class ReplaceCallWithUnaryOperatorIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace call with unary operator"), HighPriorityAction { +class ReplaceCallWithUnaryOperatorIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace call with unary operator"), HighPriorityAction { override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? { val operation = operation(element.calleeName) ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceContainsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceContainsIntention.kt index 7ea3d3381df..efd23c85dd6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceContainsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceContainsIntention.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.util.OperatorNameConventions -public class ReplaceContainsIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace 'contains' call with 'in' operator"), HighPriorityAction { +class ReplaceContainsIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace 'contains' call with 'in' operator"), HighPriorityAction { override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? { if (element.calleeName != OperatorNameConventions.CONTAINS.asString()) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt index 0a882b707f4..5737765b846 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.util.isValidOperator -public class ReplaceGetOrSetInspection : IntentionBasedInspection( +class ReplaceGetOrSetInspection : IntentionBasedInspection( ReplaceGetOrSetIntention(), ReplaceGetOrSetInspection.additionalChecker ) { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceInvokeIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceInvokeIntention.kt index 7b03cfc32e1..57a5bc656d2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceInvokeIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceInvokeIntention.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtDotQualifiedExpression import org.jetbrains.kotlin.util.OperatorNameConventions -public class ReplaceInvokeIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace 'invoke' with direct call"), HighPriorityAction { +class ReplaceInvokeIntention : SelfTargetingRangeIntention(KtDotQualifiedExpression::class.java, "Replace 'invoke' with direct call"), HighPriorityAction { override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? { if (element.calleeName != OperatorNameConventions.INVOKE.asString()) return null return element.callExpression!!.calleeExpression!!.textRange diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt index 79722d4ec41..05a94cb055a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.quickfix.moveCaret import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -public class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention(KtCallableDeclaration::class.java, "Convert member to extension"), LowPriorityAction { +class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention(KtCallableDeclaration::class.java, "Convert member to extension"), LowPriorityAction { override fun applicabilityRange(element: KtCallableDeclaration): TextRange? { val classBody = element.parent as? KtClassBody ?: return null if (classBody.parent !is KtClass) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/SplitPropertyDeclarationIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/SplitPropertyDeclarationIntention.kt index 26dab4027bf..715f9d69d25 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/SplitPropertyDeclarationIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/SplitPropertyDeclarationIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.idea.intentions.splitPropertyDeclaration import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class SplitPropertyDeclarationIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Split property declaration"), LowPriorityAction { +class SplitPropertyDeclarationIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Split property declaration"), LowPriorityAction { override fun applicabilityRange(element: KtProperty): TextRange? { if (!element.isLocal) return null val initializer = element.initializer ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt b/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt index aded621a5f8..6edd3eced12 100644 --- a/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt +++ b/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt @@ -39,7 +39,7 @@ import java.text.SimpleDateFormat import java.util.* import java.util.zip.ZipOutputStream -public class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging Kotlin incremental compilation") { +class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging Kotlin incremental compilation") { companion object { val BACKUP_DIR_NAME = ".backup" val PATCHES_TO_CREATE = 5 @@ -51,8 +51,8 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb } override fun actionPerformed(e: AnActionEvent) { - val project = e.getProject()!! - val projectBaseDir = File(project.getBaseDir()!!.getPath()) + val project = e.project!! + val projectBaseDir = File(project.baseDir!!.path) val backupDir = File(FileUtil.createTempDirectory("makeBackup", null), BACKUP_DIR_NAME) ProgressManager.getInstance().run( @@ -71,24 +71,24 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb private fun createPatches(backupDir: File, project: Project, indicator: ProgressIndicator) { runReadAction { val localHistoryImpl = LocalHistoryImpl.getInstanceImpl()!! - val gateway = localHistoryImpl.getGateway()!! - val localHistoryFacade = localHistoryImpl.getFacade() + val gateway = localHistoryImpl.gateway!! + val localHistoryFacade = localHistoryImpl.facade - val revisionsCollector = RevisionsCollector(localHistoryFacade, gateway.createTransientRootEntry(), project.getBaseDir()!!.getPath(), project.getLocationHash(), null) + val revisionsCollector = RevisionsCollector(localHistoryFacade, gateway.createTransientRootEntry(), project.baseDir!!.path, project.locationHash, null) var patchesCreated = 0 val patchesDir = File(backupDir, "patches") patchesDir.mkdirs() - val revisions = revisionsCollector.getResult()!! + val revisions = revisionsCollector.result!! for (rev in revisions) { - val label = rev.getLabel() + val label = rev.label if (label != null && label.startsWith(HISTORY_LABEL_PREFIX)) { val patchFile = File(patchesDir, label.removePrefix(HISTORY_LABEL_PREFIX) + ".patch") - indicator.setText("Creating patch $patchFile") - indicator.setFraction(PATCHES_FRACTION * patchesCreated / PATCHES_TO_CREATE) + indicator.text = "Creating patch $patchFile" + indicator.fraction = PATCHES_FRACTION * patchesCreated / PATCHES_TO_CREATE val differences = revisions[0].getDifferencesWith(rev)!! val changes = differences.map { @@ -96,7 +96,7 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb Change(d.getLeftContentRevision(gateway), d.getRightContentRevision(gateway)) } - PatchCreator.create(project, changes, patchFile.getPath(), false, null) + PatchCreator.create(project, changes, patchFile.path, false, null) if (++patchesCreated >= PATCHES_TO_CREATE) { break @@ -107,13 +107,13 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb } private fun copyLogs(backupDir: File, indicator: ProgressIndicator) { - indicator.setText("Copying logs") - indicator.setFraction(PATCHES_FRACTION) + indicator.text = "Copying logs" + indicator.fraction = PATCHES_FRACTION val logsDir = File(backupDir, "logs") FileUtil.copyDir(File(PathManager.getLogPath()), logsDir) - indicator.setFraction(PATCHES_FRACTION + LOGS_FRACTION) + indicator.fraction = PATCHES_FRACTION + LOGS_FRACTION } private fun copyProjectSystemDir(backupDir: File, project: Project, indicator: ProgressIndicator) { @@ -132,16 +132,16 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb val files = ArrayList>() // files and relative paths var totalBytes = 0L - for (dir in listOf(projectDir, backupDir.getParentFile()!!)) { + for (dir in listOf(projectDir, backupDir.parentFile!!)) { FileUtil.processFilesRecursively( dir, /*processor*/ { - if (it!!.isFile() - && !it.getName().endsWith(".hprof") - && !(it.getName().startsWith("make_backup_") && it.getName().endsWith(".zip")) + if (it!!.isFile + && !it.name.endsWith(".hprof") + && !(it.name.startsWith("make_backup_") && it.name.endsWith(".zip")) ) { - indicator.setText("Scanning project dir: $it") + indicator.text = "Scanning project dir: $it" files.add(Pair(it, FileUtil.getRelativePath(dir, it)!!)) totalBytes += it.length() @@ -149,7 +149,7 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb true }, /*directoryFilter*/ { - val name = it!!.getName() + val name = it!!.name name != ".git" && name != "out" } ) @@ -165,8 +165,8 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb zos.use { for ((file, relativePath) in files) { - indicator.setText("Adding file to backup: $relativePath") - indicator.setFraction(PATCHES_FRACTION + LOGS_FRACTION + processedBytes.toDouble() / totalBytes * ZIP_FRACTION) + indicator.text = "Adding file to backup: $relativePath" + indicator.fraction = PATCHES_FRACTION + LOGS_FRACTION + processedBytes.toDouble() / totalBytes * ZIP_FRACTION ZipUtil.addFileToZip(zos, file, relativePath, null, null) @@ -179,7 +179,7 @@ public class CreateIncrementalCompilationBackup: AnAction("Create backup for deb WaitForProgressToShow.runOrInvokeLaterAboveProgress({ ShowFilePathAction.showDialog( project, - "Successfully created backup " + backupFile.getAbsolutePath(), + "Successfully created backup " + backupFile.absolutePath, "Created backup", backupFile, null diff --git a/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/MakeBackupCompileTask.kt b/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/MakeBackupCompileTask.kt index b908459114d..6a31f393cea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/MakeBackupCompileTask.kt +++ b/idea/src/org/jetbrains/kotlin/idea/internal/makeBackup/MakeBackupCompileTask.kt @@ -26,15 +26,15 @@ val random = Random() val HISTORY_LABEL_KEY = Key.create("history label") -public class MakeBackupCompileTask: CompileTask { +class MakeBackupCompileTask: CompileTask { override fun execute(context: CompileContext?): Boolean { - val project = context!!.getProject()!! + val project = context!!.project!! val localHistory = LocalHistory.getInstance()!! val label = HISTORY_LABEL_PREFIX + Integer.toHexString(random.nextInt()) localHistory.putSystemLabel(project, label) - context.getCompileScope()!!.putUserData(HISTORY_LABEL_KEY, label) + context.compileScope!!.putUserData(HISTORY_LABEL_KEY, label) return true } diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaDocCommentConverter.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaDocCommentConverter.kt index 74260eaa901..d8a5881a116 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaDocCommentConverter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaDocCommentConverter.kt @@ -36,14 +36,14 @@ import org.jetbrains.kotlin.j2k.content object IdeaDocCommentConverter : DocCommentConverter { override fun convertDocComment(docComment: PsiDocComment): String { val html = buildString { - appendJavadocElements(docComment.getDescriptionElements()) + appendJavadocElements(docComment.descriptionElements) tagsLoop@ - for (tag in docComment.getTags()) { - when (tag.getName()) { + for (tag in docComment.tags) { + when (tag.name) { "deprecated" -> continue@tagsLoop "see" -> append("@see ${convertJavadocLink(tag.content())}\n") - else -> appendJavadocElements(tag.getChildren()).append("\n") + else -> appendJavadocElements(tag.children).append("\n") } } } @@ -53,7 +53,7 @@ object IdeaDocCommentConverter : DocCommentConverter { return "" } - val htmlFile = PsiFileFactory.getInstance(docComment.getProject()).createFileFromText( + val htmlFile = PsiFileFactory.getInstance(docComment.project).createFileFromText( "javadoc.html", HtmlFileType.INSTANCE, html) val htmlToMarkdownConverter = HtmlToMarkdownConverter() htmlFile.accept(htmlToMarkdownConverter) @@ -66,35 +66,35 @@ object IdeaDocCommentConverter : DocCommentConverter { append(convertInlineDocTag(it)) } else { - append(it.getText()) + append(it.text) } } return this } - private fun convertInlineDocTag(tag: PsiInlineDocTag) = when(tag.getName()) { + private fun convertInlineDocTag(tag: PsiInlineDocTag) = when(tag.name) { "code", "literal" -> { - val text = tag.getDataElements().joinToString("") { it.getText() } + val text = tag.dataElements.joinToString("") { it.text } val escaped = StringUtil.escapeXml(text.trimStart()) - if (tag.getName() == "code") "$escaped" else escaped + if (tag.name == "code") "$escaped" else escaped } "link", "linkplain" -> { val valueElement = tag.linkElement() - val labelText = tag.getDataElements().firstOrNull { it is PsiDocToken }?.getText() ?: "" - val kdocLink = convertJavadocLink(valueElement?.getText()) + val labelText = tag.dataElements.firstOrNull { it is PsiDocToken }?.text ?: "" + val kdocLink = convertJavadocLink(valueElement?.text) val linkText = if (labelText.isEmpty()) kdocLink else StringUtil.escapeXml(labelText) "$linkText" } - else -> tag.getText() + else -> tag.text } private fun convertJavadocLink(link: String?): String = if (link != null) link.substringBefore('(').replace('#', '.') else "" private fun PsiDocTag.linkElement(): PsiElement? = - getValueElement() ?: getDataElements().firstOrNull { it !is PsiWhiteSpace } + valueElement ?: dataElements.firstOrNull { it !is PsiWhiteSpace } private class HtmlToMarkdownConverter() : XmlRecursiveElementVisitor() { private enum class ListType { Ordered, Unordered; } @@ -121,7 +121,7 @@ object IdeaDocCommentConverter : DocCommentConverter { if (whitespaceIsPartOfText) { appendPendingText() - markdownBuilder.append(space.getText()) + markdownBuilder.append(space.text) if (space.textContains('\n')) { afterLineBreak = true } @@ -131,10 +131,10 @@ object IdeaDocCommentConverter : DocCommentConverter { override fun visitElement(element: PsiElement) { super.visitElement(element) - val tokenType = element.getNode().getElementType() + val tokenType = element.node.elementType if (tokenType == XmlTokenType.XML_DATA_CHARACTERS || tokenType == XmlTokenType.XML_CHAR_ENTITY_REF) { appendPendingText() - markdownBuilder.append(element.getText()) + markdownBuilder.append(element.text) } } @@ -170,7 +170,7 @@ object IdeaDocCommentConverter : DocCommentConverter { } } - private fun getMarkdownForTag(tag: XmlTag, atLineStart: Boolean): MarkdownSpan = when(tag.getName()) { + private fun getMarkdownForTag(tag: XmlTag, atLineStart: Boolean): MarkdownSpan = when(tag.name) { "b", "strong" -> MarkdownSpan.wrap("**") "p" -> if (atLineStart) MarkdownSpan.prefix("\n * ") else MarkdownSpan.prefix("\n *\n *") @@ -184,7 +184,7 @@ object IdeaDocCommentConverter : DocCommentConverter { "a" -> { if (tag.getAttributeValue("docref") != null) { val docRef = tag.getAttributeValue("docref") - val innerText = tag.getValue().getText() + val innerText = tag.value.text if (docRef == innerText) MarkdownSpan("[", "]") else MarkdownSpan("[", "][$docRef]") } else { diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaReferenceSearcher.kt index ff5f8f1e738..8053ef63b5c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaReferenceSearcher.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.j2k.ReferenceSearcher import java.util.* -public object IdeaReferenceSearcher: ReferenceSearcher { +object IdeaReferenceSearcher: ReferenceSearcher { override fun findLocalUsages(element: PsiElement, scope: PsiElement) = ReferencesSearch.search(element, LocalSearchScope(scope)).findAll() override fun hasInheritors(`class`: PsiClass) = ClassInheritorsSearch.search(`class`, false).any() @@ -41,12 +41,12 @@ public object IdeaReferenceSearcher: ReferenceSearcher { override fun findUsagesForExternalCodeProcessing(element: PsiElement, searchJava: Boolean, searchKotlin: Boolean): Collection { val fileTypes = ArrayList() if (searchJava) { - fileTypes.add(JavaLanguage.INSTANCE.getAssociatedFileType()!!) + fileTypes.add(JavaLanguage.INSTANCE.associatedFileType!!) } if (searchKotlin) { - fileTypes.add(KotlinLanguage.INSTANCE.getAssociatedFileType()!!) + fileTypes.add(KotlinLanguage.INSTANCE.associatedFileType!!) } - val searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(element.getProject()), *fileTypes.toTypedArray()) + val searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(element.project), *fileTypes.toTypedArray()) return ReferencesSearch.search(element, searchScope).findAll() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaResolverForConverter.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaResolverForConverter.kt index 8ac923875a0..076ab16e5d7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaResolverForConverter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/IdeaResolverForConverter.kt @@ -20,6 +20,6 @@ import org.jetbrains.kotlin.j2k.ResolverForConverter import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor -public object IdeaResolverForConverter : ResolverForConverter { +object IdeaResolverForConverter : ResolverForConverter { override fun resolveToDescriptor(declaration: KtDeclaration) = declaration.resolveToDescriptor() } diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt index 5927bcc6752..5c61020f80d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.psiUtil.elementsInRange import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics import java.util.* -public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor { +class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor { override fun insertImport(file: KtFile, fqName: FqName) { val descriptors = file.resolveImportReference(fqName) descriptors.firstOrNull()?.let { ImportInsertHelper.getInstance(file.project).importDescriptor(file, it) } diff --git a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt index d231c91aaed..f53fecad418 100644 --- a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt @@ -22,42 +22,42 @@ import com.intellij.psi.PsiFile import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -public class JoinBlockIntoSingleStatementHandler : JoinRawLinesHandlerDelegate { +class JoinBlockIntoSingleStatementHandler : JoinRawLinesHandlerDelegate { override fun tryJoinRawLines(document: Document, file: PsiFile, start: Int, end: Int): Int { if (file !is KtFile) return -1 if (start == 0) return -1 - val c = document.getCharsSequence()[start] + val c = document.charsSequence[start] val index = if (c == '\n') start - 1 else start val brace = file.findElementAt(index)!! - if (brace.getNode()!!.getElementType() != KtTokens.LBRACE) return -1 + if (brace.node!!.elementType != KtTokens.LBRACE) return -1 - val block = brace.getParent() as? KtBlockExpression ?: return -1 - val statement = block.getStatements().singleOrNull() ?: return -1 - val parent = block.getParent() + val block = brace.parent as? KtBlockExpression ?: return -1 + val statement = block.statements.singleOrNull() ?: return -1 + val parent = block.parent if (parent !is KtContainerNode && parent !is KtWhenEntry) return -1 - if (block.getNode().getChildren(KtTokens.COMMENTS).isNotEmpty()) return -1 // otherwise we will loose comments + if (block.node.getChildren(KtTokens.COMMENTS).isNotEmpty()) return -1 // otherwise we will loose comments // handle nested if's - val pparent = parent.getParent() - if (pparent is KtIfExpression && block == pparent.getThen() && statement is KtIfExpression && statement.getElse() == null) { + val pparent = parent.parent + if (pparent is KtIfExpression && block == pparent.then && statement is KtIfExpression && statement.`else` == null) { // if outer if has else-branch and inner does not have it, do not remove braces otherwise else-branch will belong to different if! - if (pparent.getElse() != null) return -1 + if (pparent.`else` != null) return -1 - val condition1 = pparent.getCondition() - val condition2 = statement.getCondition() - val body = statement.getThen() + val condition1 = pparent.condition + val condition2 = statement.condition + val body = statement.then if (condition1 != null && condition2 != null && body != null) { val newCondition = KtPsiFactory(pparent).createExpressionByPattern("$0 && $1", condition1, condition2) condition1.replace(newCondition) val newBody = block.replace(body) - return newBody.getTextRange()!!.getStartOffset() + return newBody.textRange!!.startOffset } } val newStatement = block.replace(statement) - return newStatement.getTextRange()!!.getStartOffset() + return newStatement.textRange!!.startOffset } override fun tryJoinLines(document: Document, file: PsiFile, start: Int, end: Int) diff --git a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinDeclarationAndAssignmentHandler.kt b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinDeclarationAndAssignmentHandler.kt index 4da3109d7f2..68778998363 100644 --- a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinDeclarationAndAssignmentHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinDeclarationAndAssignmentHandler.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import com.intellij.openapi.util.text.StringUtil import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -public class JoinDeclarationAndAssignmentHandler : JoinRawLinesHandlerDelegate { +class JoinDeclarationAndAssignmentHandler : JoinRawLinesHandlerDelegate { override fun tryJoinRawLines(document: Document, file: PsiFile, start: Int, end: Int): Int { if (file !is KtFile) return -1 @@ -46,7 +46,7 @@ public class JoinDeclarationAndAssignmentHandler : JoinRawLinesHandlerDelegate { val (property, assignment) = pair doJoin(property, assignment) - return property.getTextRange()!!.getStartOffset() + return property.textRange!!.startOffset } override fun tryJoinLines(document: Document, file: PsiFile, start: Int, end: Int) @@ -58,24 +58,24 @@ public class JoinDeclarationAndAssignmentHandler : JoinRawLinesHandlerDelegate { val assignment = element.siblings(forward = true, withItself = false) .firstOrNull { !isToSkip(it) } as? KtBinaryExpression ?: return null - if (assignment.getOperationToken() != KtTokens.EQ) return null + if (assignment.operationToken != KtTokens.EQ) return null - val left = assignment.getLeft() as? KtSimpleNameExpression ?: return null - if (assignment.getRight() == null) return null - if (left.getReferencedName() != property.getName()) return null + val left = assignment.left as? KtSimpleNameExpression ?: return null + if (assignment.right == null) return null + if (left.getReferencedName() != property.name) return null return property to assignment } private fun doJoin(property: KtProperty, assignment: KtBinaryExpression) { - property.setInitializer(assignment.getRight()) - property.getParent()!!.deleteChildRange(property.getNextSibling(), assignment) //TODO: should we delete range? + property.setInitializer(assignment.right) + property.parent!!.deleteChildRange(property.nextSibling, assignment) //TODO: should we delete range? } private fun isToSkip(element: PsiElement): Boolean { return when (element) { is PsiWhiteSpace -> StringUtil.getLineBreakCount(element.getText()!!) <= 1 // do not skip blank line - else -> element.getNode()!!.getElementType() == KtTokens.SEMICOLON + else -> element.node!!.elementType == KtTokens.SEMICOLON } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocRenderer.kt b/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocRenderer.kt index 649d2fca04b..0dc8d4f6d98 100644 --- a/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocRenderer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocRenderer.kt @@ -120,7 +120,7 @@ object KDocRenderer { } } - public fun MarkdownNode.toHtml(): String { + fun MarkdownNode.toHtml(): String { val sb = StringBuilder() visit { node, processChildren -> fun wrapChildren(tag: String, newline: Boolean = false) { diff --git a/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocTypedHandler.kt b/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocTypedHandler.kt index 6d9c2d1d69e..20d44964b0e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocTypedHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/kdoc/KDocTypedHandler.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -public class KDocTypedHandler(): TypedHandlerDelegate() { +class KDocTypedHandler(): TypedHandlerDelegate() { override fun beforeCharTyped(c: Char, project: Project, editor: Editor, file: PsiFile, fileType: FileType): TypedHandlerDelegate.Result { if (overwriteClosingBracket(c, editor, file)) { EditorModificationUtil.moveCaretRelatively(editor, 1) @@ -47,14 +47,14 @@ public class KDocTypedHandler(): TypedHandlerDelegate() { if (file !is KtFile) return false if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) return false - val offset = editor.getCaretModel().getOffset() - val document = editor.getDocument() - val chars = document.getCharsSequence() - if (offset < document.getTextLength() && chars[offset] == c) { + val offset = editor.caretModel.offset + val document = editor.document + val chars = document.charsSequence + if (offset < document.textLength && chars[offset] == c) { PsiDocumentManager.getInstance(file.getProject()).commitDocument(document) val element = file.findElementAt(offset) ?: return false - val elementType = element.getNode().getElementType() + val elementType = element.node.elementType return when (c) { ']' -> { // if the bracket is not part of a link, it will be part of KDOC_TEXT, not a separate RBRACKET element @@ -75,13 +75,13 @@ public class KDocTypedHandler(): TypedHandlerDelegate() { if (file !is KtFile) return false if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) return false - val offset = editor.getCaretModel().getOffset() + val offset = editor.caretModel.offset if (offset == 0) return false - val document = editor.getDocument() + val document = editor.document PsiDocumentManager.getInstance(project).commitDocument(document) val element = file.findElementAt(offset - 1) ?: return false - if (element.getNode().getElementType() != KDocTokens.TEXT) return false + if (element.node.elementType != KDocTokens.TEXT) return false when (c) { '[' -> { @@ -90,7 +90,7 @@ public class KDocTypedHandler(): TypedHandlerDelegate() { } '(' -> { - if (offset > 1 && document.getCharsSequence()[offset - 2] == ']') { + if (offset > 1 && document.charsSequence[offset - 2] == ']') { document.insertString(offset, ")") return true } diff --git a/idea/src/org/jetbrains/kotlin/idea/projectView/KotlinProblemFileHighlightFilter.kt b/idea/src/org/jetbrains/kotlin/idea/projectView/KotlinProblemFileHighlightFilter.kt index 3e3e0d35b0b..cc99e742695 100644 --- a/idea/src/org/jetbrains/kotlin/idea/projectView/KotlinProblemFileHighlightFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/projectView/KotlinProblemFileHighlightFilter.kt @@ -21,6 +21,6 @@ import com.intellij.openapi.util.Condition import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.idea.KotlinFileType -public class KotlinProblemFileHighlightFilter : Condition { +class KotlinProblemFileHighlightFilter : Condition { override fun value(t: VirtualFile): Boolean = t.fileType == KotlinFileType.INSTANCE } diff --git a/idea/src/org/jetbrains/kotlin/idea/properties/KotlinPropertiesReferenceContributor.kt b/idea/src/org/jetbrains/kotlin/idea/properties/KotlinPropertiesReferenceContributor.kt index cd0e134b58f..abf03e28783 100644 --- a/idea/src/org/jetbrains/kotlin/idea/properties/KotlinPropertiesReferenceContributor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/properties/KotlinPropertiesReferenceContributor.kt @@ -22,7 +22,7 @@ import com.intellij.psi.PsiReferenceRegistrar import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry import org.jetbrains.kotlin.psi.KtStringTemplateExpression -public class KotlinPropertiesReferenceContributor : PsiReferenceContributor() { +class KotlinPropertiesReferenceContributor : PsiReferenceContributor() { override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { registrar.registerReferenceProvider( PlatformPatterns.psiElement(KtStringTemplateExpression::class.java), diff --git a/idea/src/org/jetbrains/kotlin/idea/properties/referenceProviders.kt b/idea/src/org/jetbrains/kotlin/idea/properties/referenceProviders.kt index c654048a06a..2ef600e483e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/properties/referenceProviders.kt +++ b/idea/src/org/jetbrains/kotlin/idea/properties/referenceProviders.kt @@ -126,7 +126,7 @@ private fun KtStringTemplateExpression.isBundleName(): Boolean { return false } -public object KotlinPropertyKeyReferenceProvider : PsiReferenceProvider() { +object KotlinPropertyKeyReferenceProvider : PsiReferenceProvider() { override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { if (!(element is KtStringTemplateExpression && element.isPlain())) return PsiReference.EMPTY_ARRAY val bundleName = element.getBundleNameByContext() ?: return PsiReference.EMPTY_ARRAY @@ -134,7 +134,7 @@ public object KotlinPropertyKeyReferenceProvider : PsiReferenceProvider() { } } -public object KotlinResourceBundleNameReferenceProvider : PsiReferenceProvider() { +object KotlinResourceBundleNameReferenceProvider : PsiReferenceProvider() { override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { if (!(element is KtStringTemplateExpression && element.isPlain() && element.isBundleName())) return PsiReference.EMPTY_ARRAY return arrayOf(ResourceBundleReference(element)) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt index a542fb572c6..2907e46b5d6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.ConstModifierChecker import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.source.PsiSourceElement -public class AddConstModifierFix(val property: KtProperty) : AddModifierFix(property, KtTokens.CONST_KEYWORD), CleanupFix { +class AddConstModifierFix(val property: KtProperty) : AddModifierFix(property, KtTokens.CONST_KEYWORD), CleanupFix { override fun invoke(project: Project, editor: Editor?, file: KtFile) { addConstModifier(property) } @@ -54,7 +54,7 @@ public class AddConstModifierFix(val property: KtProperty) : AddModifierFix(prop } } -public class AddConstModifierIntention : SelfTargetingIntention(KtProperty::class.java, "Add 'const' modifier") { +class AddConstModifierIntention : SelfTargetingIntention(KtProperty::class.java, "Add 'const' modifier") { override fun applyTo(element: KtProperty, editor: Editor) { AddConstModifierFix.addConstModifier(element) } @@ -76,7 +76,7 @@ public class AddConstModifierIntention : SelfTargetingIntention(KtPr } -public object ConstFixFactory : KotlinSingleIntentionActionFactory() { +object ConstFixFactory : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { val expr = diagnostic.psiElement as? KtReferenceExpression ?: return null val bindingContext = expr.analyze(BodyResolveMode.PARTIAL) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt index cb903ddc9b2..7066bf58c08 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import java.util.* -public class AddFunctionParametersFix( +class AddFunctionParametersFix( private val callElement: KtCallElement, functionDescriptor: FunctionDescriptor, private val hasTypeMismatches: Boolean) : ChangeFunctionSignatureFix(callElement, functionDescriptor) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt index d020e7cbd89..be5a0449d18 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.singletonOrEmptyList -public class AddGenericUpperBoundFix( +class AddGenericUpperBoundFix( typeParameter: KtTypeParameter, upperBound: KotlinType ) : KotlinQuickFixAction(typeParameter) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddLoopLabelFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddLoopLabelFix.kt index 592e903a358..80cbe7d21fd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddLoopLabelFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddLoopLabelFix.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.parents -public class AddLoopLabelFix(loop: KtLoopExpression, val jumpExpression: KtElement): KotlinQuickFixAction(loop) { +class AddLoopLabelFix(loop: KtLoopExpression, val jumpExpression: KtElement): KotlinQuickFixAction(loop) { override fun getText() = "Add label to loop" override fun getFamilyName() = text diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt index 32284e0e046..29bed7237d4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction(argument) { +class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction(argument) { override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean { if (!super.isAvailable(project, editor, file)) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangePrivateTopLevelToInternalFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangePrivateTopLevelToInternalFix.kt index 7848fc2ca5c..95970deca23 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangePrivateTopLevelToInternalFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangePrivateTopLevelToInternalFix.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.KtModifierListOwner import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils -public class ChangePrivateTopLevelToInternalFix(element: KtModifierListOwner, private val elementName: String) : KotlinQuickFixAction(element), CleanupFix { +class ChangePrivateTopLevelToInternalFix(element: KtModifierListOwner, private val elementName: String) : KotlinQuickFixAction(element), CleanupFix { override fun getText() = "Make $elementName internal" override fun getFamilyName() = "Make top-level declaration internal" diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt index b030c755ff1..d164dd7887a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -public class ChangeVariableMutabilityFix(element: KtNamedDeclaration, private val makeVar: Boolean) : KotlinQuickFixAction(element) { +class ChangeVariableMutabilityFix(element: KtNamedDeclaration, private val makeVar: Boolean) : KotlinQuickFixAction(element) { override fun getText() = if (makeVar) "Make variable mutable" else "Make variable immutable" @@ -50,14 +50,14 @@ public class ChangeVariableMutabilityFix(element: KtNamedDeclaration, private va } companion object { - public val VAL_WITH_SETTER_FACTORY: KotlinSingleIntentionActionFactory = object: KotlinSingleIntentionActionFactory() { + val VAL_WITH_SETTER_FACTORY: KotlinSingleIntentionActionFactory = object: KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { val accessor = diagnostic.psiElement as KtPropertyAccessor return ChangeVariableMutabilityFix(accessor.property, true) } } - public val VAL_REASSIGNMENT_FACTORY: KotlinSingleIntentionActionFactory = object: KotlinSingleIntentionActionFactory() { + val VAL_REASSIGNMENT_FACTORY: KotlinSingleIntentionActionFactory = object: KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { val propertyDescriptor = Errors.VAL_REASSIGNMENT.cast(diagnostic).a val declaration = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor) as? KtNamedDeclaration ?: return null @@ -65,7 +65,7 @@ public class ChangeVariableMutabilityFix(element: KtNamedDeclaration, private va } } - public val VAR_OVERRIDDEN_BY_VAL_FACTORY: KotlinSingleIntentionActionFactory = object: KotlinSingleIntentionActionFactory() { + val VAR_OVERRIDDEN_BY_VAL_FACTORY: KotlinSingleIntentionActionFactory = object: KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { val element = diagnostic.psiElement return when (element) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/CleanupFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/CleanupFix.kt index c420585dc75..a113119a60e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/CleanupFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/CleanupFix.kt @@ -22,7 +22,7 @@ import com.intellij.codeInsight.intention.IntentionAction * Marker interface for quickfixes that can be used as part of the "Cleanup Code" action. The diagnostics * that produce these quickfixes need to be added to KotlinCleanupInspection.cleanupDiagnosticsFactories. */ -public interface CleanupFix : IntentionAction { +interface CleanupFix : IntentionAction { } // TODO(yole): add isSafeToApply() method here to get rid of filtering by diagnostics factories in // KotlinCleanupInspection diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DelegatingIntentionAction.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DelegatingIntentionAction.kt index ccfe4377892..19b95f51f30 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DelegatingIntentionAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DelegatingIntentionAction.kt @@ -18,4 +18,4 @@ package org.jetbrains.kotlin.idea.quickfix import com.intellij.codeInsight.intention.IntentionAction -public open class DelegatingIntentionAction(val delegate: IntentionAction): IntentionAction by delegate +open class DelegatingIntentionAction(val delegate: IntentionAction): IntentionAction by delegate diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt index 4c437c6aeb4..8dd9b7b8b58 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.util.OperatorChecks import org.jetbrains.kotlin.util.OperatorNameConventions -public abstract class ExclExclCallFix : IntentionAction { +abstract class ExclExclCallFix : IntentionAction { override fun getFamilyName(): String = text override fun startInWriteAction(): Boolean = true @@ -48,7 +48,7 @@ public abstract class ExclExclCallFix : IntentionAction { override fun isAvailable(project: Project, editor: Editor?, file: PsiFile) = file is KtFile } -public class RemoveExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix(), CleanupFix { +class RemoveExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix(), CleanupFix { override fun getText(): String = KotlinBundle.message("remove.unnecessary.non.null.assertion") override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean @@ -76,7 +76,7 @@ public class RemoveExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix } } -public class AddExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix() { +class AddExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix() { override fun getText() = KotlinBundle.message("introduce.non.null.assertion") override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt index 2f4b33eb963..8b7cb4e0746 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess -public class InsertDelegationCallQuickfix(val isThis: Boolean, element: KtSecondaryConstructor) : KotlinQuickFixAction(element) { +class InsertDelegationCallQuickfix(val isThis: Boolean, element: KtSecondaryConstructor) : KotlinQuickFixAction(element) { override fun getText() = KotlinBundle.message("insert.delegation.call", keywordToUse) override fun getFamilyName() = "Insert explicit delegation call" diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddOrderEntryActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddOrderEntryActionFactory.kt index 9c4ebd08878..734743c603e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddOrderEntryActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddOrderEntryActionFactory.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElement import org.jetbrains.kotlin.psi.psiUtil.startOffset -public object KotlinAddOrderEntryActionFactory : KotlinIntentionActionsFactory() { +object KotlinAddOrderEntryActionFactory : KotlinIntentionActionsFactory() { override fun doCreateActions(diagnostic: Diagnostic): List { val simpleExpression = diagnostic.psiElement as? KtSimpleNameExpression ?: return emptyList() val refElement = simpleExpression.getQualifiedElement() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt index a9be5d62381..b2ca3107627 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt @@ -32,7 +32,7 @@ abstract class KotlinSingleIntentionActionFactoryWithDelegate, diagnostic: Diagnostic, quickFixDataFactory: () -> D? diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinReferenceImporter.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinReferenceImporter.kt index 88232b08494..9333164b08f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinReferenceImporter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinReferenceImporter.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.psiUtil.elementsInRange import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class KotlinReferenceImporter : ReferenceImporter { +class KotlinReferenceImporter : ReferenceImporter { override fun autoImportReferenceAtCursor(editor: Editor, file: PsiFile) = autoImportReferenceAtCursor(editor, file, allowCaretNearRef = false) @@ -51,7 +51,7 @@ public class KotlinReferenceImporter : ReferenceImporter { companion object { // TODO: use in table cell - public fun autoImportReferenceAtCursor(editor: Editor, file: PsiFile, allowCaretNearRef: Boolean): Boolean { + fun autoImportReferenceAtCursor(editor: Editor, file: PsiFile, allowCaretNearRef: Boolean): Boolean { if (file !is KtFile) return false val caretOffset = editor.caretModel.offset diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt index d1dba733464..37b38a153ab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList -public abstract class KotlinSingleIntentionActionFactory : KotlinIntentionActionsFactory() { +abstract class KotlinSingleIntentionActionFactory : KotlinIntentionActionsFactory() { protected abstract fun createAction(diagnostic: Diagnostic): IntentionAction? final override fun doCreateActions(diagnostic: Diagnostic): List = createAction(diagnostic).singletonOrEmptyList() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt index d3fb3840e95..798ded95f82 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeOverriddenMemberOpenFix.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import java.util.* -public class MakeOverriddenMemberOpenFix(declaration: KtDeclaration) : KotlinQuickFixAction(declaration) { +class MakeOverriddenMemberOpenFix(declaration: KtDeclaration) : KotlinQuickFixAction(declaration) { private val overriddenNonOverridableMembers = ArrayList() private val containingDeclarationsNames = ArrayList() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt index 40570c73101..f734b3159c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtPrimaryConstructor import org.jetbrains.kotlin.idea.quickfix.quickfixUtil.addConstructorKeyword -public class MissingConstructorKeywordFix(element: KtPrimaryConstructor) : KotlinQuickFixAction(element), CleanupFix { +class MissingConstructorKeywordFix(element: KtPrimaryConstructor) : KotlinQuickFixAction(element), CleanupFix { override fun getFamilyName(): String = text override fun getText(): String = "Add 'constructor' keyword" @@ -38,7 +38,7 @@ public class MissingConstructorKeywordFix(element: KtPrimaryConstructor) : Kotli override fun createAction(diagnostic: Diagnostic): IntentionAction? = diagnostic.createIntentionForFirstParentOfType(::MissingConstructorKeywordFix) - public fun createWholeProjectFixFactory(): KotlinSingleIntentionActionFactory = createIntentionFactory { + fun createWholeProjectFixFactory(): KotlinSingleIntentionActionFactory = createIntentionFactory { WholeProjectForEachElementOfTypeFix.createByPredicate( predicate = { it.modifierList != null && !it.hasConstructorKeyword() }, taskProcessor = { it.addConstructorKeyword() }, diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 208f14a43e0..e602ef90abd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -44,8 +44,8 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION -public class QuickFixRegistrar : QuickFixContributor { - public override fun registerQuickFixes(quickFixes: QuickFixes) { +class QuickFixRegistrar : QuickFixContributor { + override fun registerQuickFixes(quickFixes: QuickFixes) { fun DiagnosticFactory<*>.registerFactory(vararg factory: KotlinIntentionActionsFactory) { quickFixes.register(this, *factory) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt index bfd0d765627..af5923ceebf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt @@ -23,7 +23,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile -public open class QuickFixWithDelegateFactory( +open class QuickFixWithDelegateFactory( private val delegateFactory: () -> IntentionAction? ) : IntentionAction { private val familyName: String @@ -59,11 +59,11 @@ public open class QuickFixWithDelegateFactory( } } -public class LowPriorityQuickFixWithDelegateFactory( +class LowPriorityQuickFixWithDelegateFactory( delegateFactory: () -> IntentionAction? ): QuickFixWithDelegateFactory(delegateFactory), LowPriorityAction -public class HighPriorityQuickFixWithDelegateFactory( +class HighPriorityQuickFixWithDelegateFactory( delegateFactory: () -> IntentionAction? ): QuickFixWithDelegateFactory(delegateFactory), HighPriorityAction diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index e10c29b55be..e7b78b32fc7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.KtTypeProjection import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.types.Variance -public class RemoveModifierFix( +class RemoveModifierFix( element: KtModifierListOwner, private val modifier: KtModifierKeywordToken, private val isRedundant: Boolean @@ -59,7 +59,7 @@ public class RemoveModifierFix( invoke() } - public fun invoke() { + fun invoke() { //TODO: without this copy&replace we get bad formatting on removing last modifier val newElement = element.copy() as KtModifierListOwner newElement.removeModifier(modifier) @@ -67,7 +67,7 @@ public class RemoveModifierFix( } companion object { - public fun createRemoveModifierFromListOwnerFactory(modifier: KtModifierKeywordToken, isRedundant: Boolean = false): KotlinSingleIntentionActionFactory { + fun createRemoveModifierFromListOwnerFactory(modifier: KtModifierKeywordToken, isRedundant: Boolean = false): KotlinSingleIntentionActionFactory { return object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val modifierListOwner = QuickFixUtil.getParentElementOfType(diagnostic, KtModifierListOwner::class.java) ?: return null @@ -76,7 +76,7 @@ public class RemoveModifierFix( } } - public fun createRemoveModifierFactory(isRedundant: Boolean = false): KotlinSingleIntentionActionFactory { + fun createRemoveModifierFactory(isRedundant: Boolean = false): KotlinSingleIntentionActionFactory { return object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val psiElement = diagnostic.psiElement @@ -87,7 +87,7 @@ public class RemoveModifierFix( } } - public fun createRemoveProjectionFactory(isRedundant: Boolean): KotlinSingleIntentionActionFactory { + fun createRemoveProjectionFactory(isRedundant: Boolean): KotlinSingleIntentionActionFactory { return object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val projection = diagnostic.psiElement as KtTypeProjection @@ -97,7 +97,7 @@ public class RemoveModifierFix( } } - public fun createRemoveVarianceFactory(): KotlinSingleIntentionActionFactory { + fun createRemoveVarianceFactory(): KotlinSingleIntentionActionFactory { return object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val psiElement = diagnostic.psiElement as KtTypeParameter diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNameFromFunctionExpressionFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNameFromFunctionExpressionFix.kt index 621f1a43b8b..4d9b9da8f4a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNameFromFunctionExpressionFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNameFromFunctionExpressionFix.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import org.jetbrains.kotlin.resolve.BindingContext -public class RemoveNameFromFunctionExpressionFix(element: KtNamedFunction) : KotlinQuickFixAction(element), CleanupFix { +class RemoveNameFromFunctionExpressionFix(element: KtNamedFunction) : KotlinQuickFixAction(element), CleanupFix { override fun getText(): String = "Remove identifier from anonymous function" override fun getFamilyName(): String = text diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt index 179678225d7..b7bb57678dd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.psi.* -public abstract class ReplaceCallFix protected constructor(val psiElement: PsiElement) : IntentionAction { +abstract class ReplaceCallFix protected constructor(val psiElement: PsiElement) : IntentionAction { override fun getFamilyName(): String = text @@ -59,7 +59,7 @@ public abstract class ReplaceCallFix protected constructor(val psiElement: PsiEl abstract val classToReplace: Class } -public class ReplaceWithSafeCallFix(psiElement: PsiElement): ReplaceCallFix(psiElement) { +class ReplaceWithSafeCallFix(psiElement: PsiElement): ReplaceCallFix(psiElement) { override fun getText(): String = "Replace with safe (?.) call" override val operation: String get() = "?." override val classToReplace: Class get() = KtDotQualifiedExpression::class.java @@ -70,7 +70,7 @@ public class ReplaceWithSafeCallFix(psiElement: PsiElement): ReplaceCallFix(psiE } } -public class ReplaceWithDotCallFix(psiElement: PsiElement): ReplaceCallFix(psiElement), CleanupFix { +class ReplaceWithDotCallFix(psiElement: PsiElement): ReplaceCallFix(psiElement), CleanupFix { override fun getText(): String = KotlinBundle.message("replace.with.dot.call") override val operation: String get() = "." override val classToReplace: Class get() = KtSafeQualifiedExpression::class.java diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceInfixCallFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceInfixCallFix.kt index 363f03eb1bd..5a11b26d28b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceInfixCallFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceInfixCallFix.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.createExpressionByPattern import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType -public class ReplaceInfixCallFix(element: KtBinaryExpression) : KotlinQuickFixAction(element) { +class ReplaceInfixCallFix(element: KtBinaryExpression) : KotlinQuickFixAction(element) { override fun getText() = "Replace with safe (?.) call" diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceJavaAnnotationPositionedArgumentsFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceJavaAnnotationPositionedArgumentsFix.kt index 7bee78786b9..3035dcee151 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceJavaAnnotationPositionedArgumentsFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceJavaAnnotationPositionedArgumentsFix.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument -public class ReplaceJavaAnnotationPositionedArgumentsFix(element: KtAnnotationEntry) +class ReplaceJavaAnnotationPositionedArgumentsFix(element: KtAnnotationEntry) : KotlinQuickFixAction(element), CleanupFix { override fun getText(): String = "Replace invalid positioned arguments for annotation" override fun getFamilyName(): String = text diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt index c95fb75036f..e64bb47e70e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.BindingContext -public class ReplaceObsoleteLabelSyntaxFix(element: KtAnnotationEntry) : KotlinQuickFixAction(element), CleanupFix { +class ReplaceObsoleteLabelSyntaxFix(element: KtAnnotationEntry) : KotlinQuickFixAction(element), CleanupFix { override fun getFamilyName(): String = "Update obsolete label syntax" override fun getText(): String = "Replace with label ${element.calleeExpression?.text ?: ""}@" @@ -44,7 +44,7 @@ public class ReplaceObsoleteLabelSyntaxFix(element: KtAnnotationEntry) : KotlinQ return ReplaceObsoleteLabelSyntaxFix(annotationEntry) } - public fun createWholeProjectFixFactory(): KotlinSingleIntentionActionFactory = createIntentionFactory factory@ { + fun createWholeProjectFixFactory(): KotlinSingleIntentionActionFactory = createIntentionFactory factory@ { diagnostic -> if (!(diagnostic.psiElement.getNonStrictParentOfType()?.looksLikeObsoleteLabelWithReferencesInCode() @@ -75,7 +75,7 @@ public class ReplaceObsoleteLabelSyntaxFix(element: KtAnnotationEntry) : KotlinQ } && analyze().diagnostics.forElement(nameExpression).any { it.factory == Errors.UNRESOLVED_REFERENCE } } - public fun looksLikeObsoleteLabel(entry: KtAnnotationEntry): Boolean = + fun looksLikeObsoleteLabel(entry: KtAnnotationEntry): Boolean = entry.atSymbol != null && entry.parent is KtAnnotatedExpression && (entry.parent as KtAnnotatedExpression).annotationEntries.size == 1 && diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/SpecifyTypeExplicitlyFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/SpecifyTypeExplicitlyFix.kt index 135405971b1..b5e631bdb27 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/SpecifyTypeExplicitlyFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/SpecifyTypeExplicitlyFix.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtCallableDeclaration import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.KtProperty -public class SpecifyTypeExplicitlyFix : PsiElementBaseIntentionAction() { +class SpecifyTypeExplicitlyFix : PsiElementBaseIntentionAction() { override fun getFamilyName() = "Specify type explicitly" override fun invoke(project: Project, editor: Editor, element: PsiElement) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt index c8faabfb045..7cd5261154b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt @@ -44,7 +44,7 @@ import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* -public object SuperClassNotInitialized : KotlinIntentionActionsFactory() { +object SuperClassNotInitialized : KotlinIntentionActionsFactory() { private val DISPLAY_MAX_PARAMS = 5 override fun doCreateActions(diagnostic: Diagnostic): List { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/UnsupportedAsyncFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/UnsupportedAsyncFix.kt index 145917f96e5..0537c2819be 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/UnsupportedAsyncFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/UnsupportedAsyncFix.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtPsiFactory -public class UnsupportedAsyncFix(val psiElement: PsiElement): KotlinQuickFixAction(psiElement), CleanupFix { +class UnsupportedAsyncFix(val psiElement: PsiElement): KotlinQuickFixAction(psiElement), CleanupFix { override fun getFamilyName(): String = "Migrate unsupported async syntax" override fun getText(): String = familyName diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/WholeProjectModalAction.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/WholeProjectModalAction.kt index 1d6cf5abd1e..4390260d75b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/WholeProjectModalAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/WholeProjectModalAction.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.psiUtil.flatMapDescendantsOfTypeVisitor import org.jetbrains.kotlin.utils.singletonOrEmptyList import java.util.* -public abstract class WholeProjectModalAction(val title: String) : IntentionAction { +abstract class WholeProjectModalAction(val title: String) : IntentionAction { private val LOG = Logger.getInstance(WholeProjectModalAction::class.java); override final fun startInWriteAction() = false @@ -98,7 +98,7 @@ public abstract class WholeProjectModalAction(val title: String) : protected abstract fun applyChangesForFile(project: Project, file: KtFile, data: TData) } -public abstract class WholeProjectModalByCollectionAction(modalTitle: String) +abstract class WholeProjectModalByCollectionAction(modalTitle: String) : WholeProjectModalAction>(modalTitle) { override fun collectDataForFile(project: Project, file: KtFile): Collection? { val accumulator = arrayListOf() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/CreateFromUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/CreateFromUsageFixBase.kt index 6411c2eb88d..7f18729cf1d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/CreateFromUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/CreateFromUsageFixBase.kt @@ -20,6 +20,6 @@ import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction import org.jetbrains.kotlin.psi.KtElement -public abstract class CreateFromUsageFixBase(element: T) : KotlinQuickFixAction(element) { +abstract class CreateFromUsageFixBase(element: T) : KotlinQuickFixAction(element) { override fun getFamilyName(): String = KotlinBundle.message("create.from.usage.family") } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 25d96d322de..0ffb438986a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -88,7 +88,7 @@ private val ATTRIBUTE_FUNCTION_NAME = "FUNCTION_NAME" * Represents a single choice for a type (e.g. parameter type or return type). */ class TypeCandidate(val theType: KotlinType, scope: HierarchicalScope? = null) { - public val typeParameters: Array + val typeParameters: Array var renderedType: String? = null private set var renderedTypeParameters: List? = null @@ -154,7 +154,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { private val typeCandidates = HashMap>() - public var placement: CallablePlacement by Delegates.notNull() + var placement: CallablePlacement by Delegates.notNull() private val elementsToShorten = ArrayList() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/generationUtils.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/generationUtils.kt index c181c6a340e..d708c8b2cc3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/generationUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/generationUtils.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.psi.psiUtil.startOffset -public fun setupEditorSelection(editor: Editor, declaration: KtNamedDeclaration) { +fun setupEditorSelection(editor: Editor, declaration: KtNamedDeclaration) { val caretModel = editor.caretModel val selectionModel = editor.selectionModel diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/templateExpressions.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/templateExpressions.kt index ecc938aca16..fd6e381e2d2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/templateExpressions.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/templateExpressions.kt @@ -102,7 +102,7 @@ internal class ParameterNameExpression( /** * An Expression for type references and delegation specifiers. */ -internal abstract class TypeExpression(public val typeCandidates: List) : Expression() { +internal abstract class TypeExpression(val typeCandidates: List) : Expression() { class ForTypeReference(typeCandidates: List) : TypeExpression(typeCandidates) { override val cachedLookupElements: Array = typeCandidates.map { LookupElementBuilder.create(it, it.renderedType!!) }.toTypedArray() @@ -137,7 +137,7 @@ internal class TypeParameterListExpression(private val mandatoryTypeParameters: insertLeadingSpace: Boolean) : Expression() { private val prefix = if (insertLeadingSpace) " <" else "<" - public var currentTypeParameters: List = Collections.emptyList() + var currentTypeParameters: List = Collections.emptyList() private set override fun calculateResult(context: ExpressionContext?): Result { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt index 79e65fb3ede..f6504c9eb48 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt @@ -232,7 +232,7 @@ private fun KtNamedDeclaration.guessType(context: BindingContext): ArrayKotlinType by another KotlinType. */ -internal class KotlinTypeSubstitution(public val forType: KotlinType, public val byType: KotlinType) +internal class KotlinTypeSubstitution(val forType: KotlinType, val byType: KotlinType) internal fun KotlinType.substitute(substitution: KotlinTypeSubstitution, variance: Variance): KotlinType { val nullable = isMarkedNullable diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt index 7ba22e27c0f..11d2f139f05 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.expressions.OperatorConventions import java.util.* -public object CreateBinaryOperationActionFactory: CreateCallableMemberFromUsageFactory() { +object CreateBinaryOperationActionFactory: CreateCallableMemberFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtBinaryExpression? { return diagnostic.psiElement.parent as? KtBinaryExpression } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt index 2f0191669de..36fcf5ab68e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt @@ -35,17 +35,17 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import java.util.HashSet -public class CreateCallableFromUsageFix( +class CreateCallableFromUsageFix( originalExpression: E, callableInfos: List ) : CreateCallableFromUsageFixBase(originalExpression, callableInfos, false) -public class CreateExtensionCallableFromUsageFix( +class CreateExtensionCallableFromUsageFix( originalExpression: E, callableInfos: List ) : CreateCallableFromUsageFixBase(originalExpression, callableInfos, true), LowPriorityAction -public abstract class CreateCallableFromUsageFixBase( +abstract class CreateCallableFromUsageFixBase( originalExpression: E, val callableInfos: List, val isExtension: Boolean diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableMemberFromUsageFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableMemberFromUsageFactory.kt index 00c3c595960..5908c23ac4b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableMemberFromUsageFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableMemberFromUsageFactory.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* -public abstract class CreateCallableMemberFromUsageFactory( +abstract class CreateCallableMemberFromUsageFactory( val extensionsSupported: Boolean = true ) : KotlinIntentionActionFactoryWithDelegate>() { private fun newCallableQuickFix( diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt index 68812b5b5b4..cdee9f26e66 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtUnaryExpression import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.expressions.OperatorConventions -public object CreateUnaryOperationActionFactory: CreateCallableMemberFromUsageFactory() { +object CreateUnaryOperationActionFactory: CreateCallableMemberFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtUnaryExpression? { return diagnostic.psiElement.parent as? KtUnaryExpression } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromCallWithConstructorCalleeActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromCallWithConstructorCalleeActionFactory.kt index 8ed60a0c1d9..1c2b047faca 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromCallWithConstructorCalleeActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromCallWithConstructorCalleeActionFactory.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.addToStdlib.singletonList import java.util.* -public object CreateClassFromCallWithConstructorCalleeActionFactory : CreateClassFromUsageFactory() { +object CreateClassFromCallWithConstructorCalleeActionFactory : CreateClassFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtCallElement? { val diagElement = diagnostic.psiElement diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromConstructorCallActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromConstructorCallActionFactory.kt index 744ca99531b..93652bca6c1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromConstructorCallActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromConstructorCallActionFactory.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.addToStdlib.singletonList import java.util.* -public object CreateClassFromConstructorCallActionFactory: CreateClassFromUsageFactory() { +object CreateClassFromConstructorCallActionFactory: CreateClassFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtCallExpression? { val diagElement = diagnostic.psiElement if (diagElement.getNonStrictParentOfType() != null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt index 7edc7bc694d..17547fae8bc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import java.util.Arrays import java.util.Collections -public object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFactory() { +object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtSimpleNameExpression? { val refExpr = diagnostic.psiElement as? KtSimpleNameExpression ?: return null if (refExpr.getNonStrictParentOfType() != null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromTypeReferenceActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromTypeReferenceActionFactory.kt index 94304e74bf6..9a2dd98f469 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromTypeReferenceActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromTypeReferenceActionFactory.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.Variance import java.util.* -public object CreateClassFromTypeReferenceActionFactory : CreateClassFromUsageFactory() { +object CreateClassFromTypeReferenceActionFactory : CreateClassFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtUserType? { return QuickFixUtil.getParentElementOfType(diagnostic, KtUserType::class.java) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt index 5b4101ffeb7..944d798c5df 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt @@ -48,7 +48,7 @@ enum class ClassKind(val keyword: String, val description: String) { DEFAULT("", "") // Used as a placeholder and must be replaced with one of the kinds above } -public data class ClassInfo( +data class ClassInfo( val kind: ClassKind = ClassKind.DEFAULT, val name: String, val targetParent: PsiElement, @@ -59,7 +59,7 @@ public data class ClassInfo( val parameterInfos: List = Collections.emptyList() ) -public class CreateClassFromUsageFix( +class CreateClassFromUsageFix( element: E, val classInfo: ClassInfo ): CreateFromUsageFixBase(element) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt index e70dec384f1..8ad23f99d4f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -public object CreateParameterByNamedArgumentActionFactory: CreateParameterFromUsageFactory() { +object CreateParameterByNamedArgumentActionFactory: CreateParameterFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtValueArgument? { val argument = QuickFixUtil.getParentElementOfType(diagnostic, KtValueArgument::class.java) ?: return null return if (argument.isNamed()) argument else null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt index 2af6f222811..d518ad4a74b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.source.getPsi -public open class CreateParameterFromUsageFix( +open class CreateParameterFromUsageFix( val functionDescriptor: FunctionDescriptor, val parameterInfo: KotlinParameterInfo, val defaultValueContext: E @@ -60,7 +60,7 @@ public open class CreateParameterFromUsageFix( } companion object { - public fun createFixForPrimaryConstructorPropertyParameter( + fun createFixForPrimaryConstructorPropertyParameter( element: E, info: PropertyInfo ) : CreateParameterFromUsageFix? { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/quickfixUtil/quickfixUtil.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/quickfixUtil/quickfixUtil.kt index 1474faebc01..650c7b8f48b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/quickfixUtil/quickfixUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/quickfixUtil/quickfixUtil.kt @@ -36,7 +36,7 @@ fun createIntentionFactory( override fun createAction(diagnostic: Diagnostic) = factory(diagnostic) } -public fun KtPrimaryConstructor.addConstructorKeyword(): PsiElement? { +fun KtPrimaryConstructor.addConstructorKeyword(): PsiElement? { val keyword = KtPsiFactory(this).createConstructorKeyword() return addAfter(keyword, modifierList ?: return null) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/CallableUsageReplacementStrategy.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/CallableUsageReplacementStrategy.kt index e3f12afc016..7f0e9f26529 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/CallableUsageReplacementStrategy.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/CallableUsageReplacementStrategy.kt @@ -615,7 +615,7 @@ private open class ConstructedExpressionWrapper( ) { val psiFactory = KtPsiFactory(expression) - public fun replaceExpression(oldExpression: KtExpression, newExpression: KtExpression): KtExpression { + fun replaceExpression(oldExpression: KtExpression, newExpression: KtExpression): KtExpression { assert(expression.isAncestor(oldExpression)) val result = oldExpression.replace(newExpression) as KtExpression if (oldExpression == expression) { @@ -632,7 +632,7 @@ private class ConstructedExpressionWrapperWithIntroduceFeature( ) : ConstructedExpressionWrapper(expression, bindingContext) { val addedStatements = ArrayList() - public fun introduceValue( + fun introduceValue( value: KtExpression, valueType: KotlinType?, usages: Collection, diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt index 42ab76ee668..32891437432 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtImportDirective import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny -public class DeprecatedSymbolUsageFix( +class DeprecatedSymbolUsageFix( element: KtSimpleNameExpression/*TODO?*/, replaceWith: ReplaceWith ) : DeprecatedSymbolUsageFixBase(element, replaceWith), CleanupFix, HighPriorityAction { @@ -50,7 +50,7 @@ public class DeprecatedSymbolUsageFix( return DeprecatedSymbolUsageFix(nameExpression, replacement) } - public fun isImportToBeRemoved(import: KtImportDirective): Boolean { + fun isImportToBeRemoved(import: KtImportDirective): Boolean { return !import.isAllUnder && import.targetDescriptors().all { DeprecatedSymbolUsageFixBase.fetchReplaceWithPattern(it, import.project) != null } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt index 9576cc40cb3..ad9309d2578 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue //TODO: different replacements for property accessors -public abstract class DeprecatedSymbolUsageFixBase( +abstract class DeprecatedSymbolUsageFixBase( element: KtSimpleNameExpression, val replaceWith: ReplaceWith ) : KotlinQuickFixAction(element) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt index 8aa44c3687d..7475d4c3a0c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.NameShortness import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy -public class DeprecatedSymbolUsageInWholeProjectFix( +class DeprecatedSymbolUsageInWholeProjectFix( element: KtSimpleNameExpression, replaceWith: ReplaceWith, private val text: String diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt index 5125b57b7c7..fcfec4299f1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt @@ -56,17 +56,17 @@ import java.util.* data class ReplaceWith(val pattern: String, val imports: List) object ReplaceWithAnnotationAnalyzer { - public val PARAMETER_USAGE_KEY: Key = Key("PARAMETER_USAGE") - public val TYPE_PARAMETER_USAGE_KEY: Key = Key("TYPE_PARAMETER_USAGE") + val PARAMETER_USAGE_KEY: Key = Key("PARAMETER_USAGE") + val TYPE_PARAMETER_USAGE_KEY: Key = Key("TYPE_PARAMETER_USAGE") - public data class ReplacementExpression( + data class ReplacementExpression( val expression: KtExpression, val fqNamesToImport: Collection ) { fun copy() = ReplacementExpression(expression.copied(), fqNamesToImport) } - public fun analyzeCallableReplacement( + fun analyzeCallableReplacement( annotation: ReplaceWith, symbolDescriptor: CallableDescriptor, resolutionFacade: ResolutionFacade @@ -162,7 +162,7 @@ object ReplaceWithAnnotationAnalyzer { return ReplacementExpression(expression, importFqNames) } - public fun analyzeClassReplacement( + fun analyzeClassReplacement( annotation: ReplaceWith, symbolDescriptor: ClassDescriptor, resolutionFacade: ResolutionFacade diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt index 0021676b3cd..f601c9f6bfb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import java.util.HashSet -public abstract class AbstractPullPushMembersHandler( +abstract class AbstractPullPushMembersHandler( private val refactoringName: String, private val helpId: String, private val wrongPositionMessage: String diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt index 22470ea4480..e2853912059 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt @@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope import java.util.* -public abstract class CallableRefactoring( +abstract class CallableRefactoring( val project: Project, val callableDescriptor: T, val commandName: String) { @@ -107,7 +107,7 @@ public abstract class CallableRefactoring( protected abstract fun performRefactoring(descriptorsForChange: Collection) - public fun run(): Boolean { + fun run(): Boolean { fun buttonPressed(code: Int, dialogButtons: List, button: String): Boolean { return code == dialogButtons.indexOf(button) && button in dialogButtons } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt index 32ecb871174..8eed1911f85 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidator.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.core.KotlinNameSuggester import org.jetbrains.kotlin.lexer.KtKeywordToken import org.jetbrains.kotlin.lexer.KtTokens -public class KotlinNamesValidator : NamesValidator { +class KotlinNamesValidator : NamesValidator { private val KEYWORD_SET = KtTokens.KEYWORDS.types.filterIsInstance().map { it.value }.toSet() override fun isKeyword(name: String, project: Project?): Boolean = name in KEYWORD_SET diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt index 89505e7d49c..dd64059835e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSupportProvider.kt @@ -32,21 +32,21 @@ import org.jetbrains.kotlin.idea.refactoring.pushDown.KotlinPushDownHandler import org.jetbrains.kotlin.idea.refactoring.safeDelete.canDeleteElement import org.jetbrains.kotlin.psi.* -public class KotlinRefactoringSupportProvider : RefactoringSupportProvider() { +class KotlinRefactoringSupportProvider : RefactoringSupportProvider() { override fun isSafeDeleteAvailable(element: PsiElement) = element.canDeleteElement() override fun getIntroduceVariableHandler() = KotlinIntroduceVariableHandler override fun getIntroduceParameterHandler() = KotlinIntroduceParameterHandler() - public fun getIntroduceLambdaParameterHandler(): RefactoringActionHandler = KotlinIntroduceLambdaParameterHandler() + fun getIntroduceLambdaParameterHandler(): RefactoringActionHandler = KotlinIntroduceLambdaParameterHandler() - public fun getIntroducePropertyHandler(): RefactoringActionHandler = KotlinIntroducePropertyHandler() + fun getIntroducePropertyHandler(): RefactoringActionHandler = KotlinIntroducePropertyHandler() - public fun getExtractFunctionHandler(): RefactoringActionHandler = + fun getExtractFunctionHandler(): RefactoringActionHandler = ExtractKotlinFunctionHandler() - public fun getExtractFunctionToScopeHandler(): RefactoringActionHandler = + fun getExtractFunctionToScopeHandler(): RefactoringActionHandler = ExtractKotlinFunctionHandler(true, ExtractKotlinFunctionHandler.InteractiveExtractionHelper) override fun isInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt index e257e13e359..ac7ee4b3240 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt @@ -20,7 +20,7 @@ import com.intellij.psi.PsiType import com.intellij.refactoring.changeSignature.ParameterInfoImpl import org.jetbrains.kotlin.psi.KtExpression -public class KotlinAwareJavaParameterInfoImpl( +class KotlinAwareJavaParameterInfoImpl( oldParameterIndex: Int, name: String, type: PsiType, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt index 762eac786e7..39c67921439 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt @@ -52,7 +52,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import org.jetbrains.kotlin.utils.keysToMap import java.util.* -public open class KotlinChangeInfo( +open class KotlinChangeInfo( val methodDescriptor: KotlinMethodDescriptor, private var name: String = methodDescriptor.name, var newReturnTypeInfo: KotlinTypeInfo = KotlinTypeInfo(true, methodDescriptor.baseDescriptor.returnType), @@ -110,7 +110,7 @@ public open class KotlinChangeInfo( var originalToCurrentMethods: Map = emptyMap() private set - public fun getOldParameterIndex(oldParameterName: String): Int? = oldNameToParameterIndex[oldParameterName] + fun getOldParameterIndex(oldParameterName: String): Int? = oldNameToParameterIndex[oldParameterName] override fun isParameterTypesChanged(): Boolean = true @@ -118,7 +118,7 @@ public open class KotlinChangeInfo( override fun isParameterSetOrOrderChanged(): Boolean = isParameterSetOrOrderChangedLazy - public fun getNewParametersCount(): Int = newParameters.size + fun getNewParametersCount(): Int = newParameters.size override fun getNewParameters(): Array = newParameters.toTypedArray() @@ -129,12 +129,11 @@ public open class KotlinChangeInfo( return receiverParameterInfo?.let { receiver -> newParameters.filter { it != receiver } } ?: newParameters } - public fun setNewParameter(index: Int, parameterInfo: KotlinParameterInfo) { + fun setNewParameter(index: Int, parameterInfo: KotlinParameterInfo) { newParameters[index] = parameterInfo } - @JvmOverloads - public fun addParameter(parameterInfo: KotlinParameterInfo, atIndex: Int = -1) { + @JvmOverloads fun addParameter(parameterInfo: KotlinParameterInfo, atIndex: Int = -1) { if (atIndex >= 0) { newParameters.add(atIndex, parameterInfo) } @@ -143,19 +142,19 @@ public open class KotlinChangeInfo( } } - public fun removeParameter(index: Int) { + fun removeParameter(index: Int) { val parameterInfo = newParameters.removeAt(index); if (parameterInfo == receiverParameterInfo) { receiverParameterInfo = null } } - public fun clearParameters() { + fun clearParameters() { newParameters.clear() receiverParameterInfo = null } - public fun hasParameter(parameterInfo: KotlinParameterInfo): Boolean = + fun hasParameter(parameterInfo: KotlinParameterInfo): Boolean = parameterInfo in newParameters override fun isGenerateDelegate(): Boolean = false @@ -168,7 +167,7 @@ public open class KotlinChangeInfo( override fun isNameChanged(): Boolean = name != methodDescriptor.name - public fun isVisibilityChanged(): Boolean = newVisibility != methodDescriptor.visibility + fun isVisibilityChanged(): Boolean = newVisibility != methodDescriptor.visibility override fun getMethod(): PsiElement { return methodDescriptor.method @@ -183,10 +182,10 @@ public open class KotlinChangeInfo( override fun getLanguage(): Language = KotlinLanguage.INSTANCE - public var propagationTargetUsageInfos: List = ArrayList() + var propagationTargetUsageInfos: List = ArrayList() private set - public var primaryPropagationTargets: Collection = emptyList() + var primaryPropagationTargets: Collection = emptyList() set(value: Collection) { field = value @@ -226,7 +225,7 @@ public open class KotlinChangeInfo( return typeInfo.render() } - public fun getNewSignature(inheritedCallable: KotlinCallableDefinitionUsage): String { + fun getNewSignature(inheritedCallable: KotlinCallableDefinitionUsage): String { val buffer = StringBuilder() val defaultVisibility = if (kind.isConstructor) Visibilities.PUBLIC else Visibilities.DEFAULT_VISIBILITY @@ -268,16 +267,16 @@ public open class KotlinChangeInfo( return buffer.toString() } - public fun isRefactoringTarget(inheritedCallableDescriptor: CallableDescriptor?): Boolean { + fun isRefactoringTarget(inheritedCallableDescriptor: CallableDescriptor?): Boolean { return inheritedCallableDescriptor != null && method == DescriptorToSourceUtils.descriptorToDeclaration(inheritedCallableDescriptor) } - public fun getNewParametersSignature(inheritedCallable: KotlinCallableDefinitionUsage<*>): String { + fun getNewParametersSignature(inheritedCallable: KotlinCallableDefinitionUsage<*>): String { return "(" + getNewParametersSignatureWithoutParentheses(inheritedCallable) + ")" } - public fun getNewParametersSignatureWithoutParentheses( + fun getNewParametersSignatureWithoutParentheses( inheritedCallable: KotlinCallableDefinitionUsage<*> ): String { val signatureParameters = getNonReceiverParameters() @@ -292,7 +291,7 @@ public open class KotlinChangeInfo( .joinToString(separator = ", ") } - public fun renderReceiverType(inheritedCallable: KotlinCallableDefinitionUsage<*>): String? { + fun renderReceiverType(inheritedCallable: KotlinCallableDefinitionUsage<*>): String? { val receiverTypeText = receiverParameterInfo?.currentTypeInfo?.render() ?: return null val typeSubstitutor = inheritedCallable.typeSubstitutor ?: return receiverTypeText val currentBaseFunction = inheritedCallable.baseFunction.currentCallableDescriptor ?: return receiverTypeText @@ -301,7 +300,7 @@ public open class KotlinChangeInfo( return receiverType.renderTypeWithSubstitution(typeSubstitutor, receiverTypeText, false) } - public fun renderReturnType(inheritedCallable: KotlinCallableDefinitionUsage<*>): String { + fun renderReturnType(inheritedCallable: KotlinCallableDefinitionUsage<*>): String { val defaultRendering = newReturnTypeInfo.render() val typeSubstitutor = inheritedCallable.typeSubstitutor ?: return defaultRendering val currentBaseFunction = inheritedCallable.baseFunction.currentCallableDescriptor ?: return defaultRendering @@ -310,7 +309,7 @@ public open class KotlinChangeInfo( return returnType.renderTypeWithSubstitution(typeSubstitutor, defaultRendering, false) } - public fun primaryMethodUpdated() { + fun primaryMethodUpdated() { isPrimaryMethodUpdated = true javaChangeInfos = null } @@ -339,7 +338,7 @@ public open class KotlinChangeInfo( return if (index >= 0) removeAt(index) else null } - public fun getOrCreateJavaChangeInfos(): List? { + fun getOrCreateJavaChangeInfos(): List? { fun initCurrentSignatures(currentPsiMethods: List): List { val parameterInfoToPsi = methodDescriptor.original.parameters.zip(originalParameters).toMap() val dummyParameter = KtPsiFactory(method).createParameter("dummy") @@ -509,17 +508,17 @@ public open class KotlinChangeInfo( } } -public val KotlinChangeInfo.originalBaseFunctionDescriptor: CallableDescriptor +val KotlinChangeInfo.originalBaseFunctionDescriptor: CallableDescriptor get() = methodDescriptor.baseDescriptor -public val KotlinChangeInfo.kind: Kind get() = methodDescriptor.kind +val KotlinChangeInfo.kind: Kind get() = methodDescriptor.kind -public val KotlinChangeInfo.oldName: String? +val KotlinChangeInfo.oldName: String? get() = (methodDescriptor.method as? KtFunction)?.name -public fun KotlinChangeInfo.getAffectedCallables(): Collection = methodDescriptor.affectedCallables + propagationTargetUsageInfos +fun KotlinChangeInfo.getAffectedCallables(): Collection = methodDescriptor.affectedCallables + propagationTargetUsageInfos -public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: KotlinMethodDescriptor): KotlinChangeInfo { +fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: KotlinMethodDescriptor): KotlinChangeInfo { val method = method as PsiMethod val functionDescriptor = method.getJavaMethodDescriptor()!! diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt index f22fd862cdb..9c09b9c52ff 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt @@ -47,7 +47,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.OverrideResolver -public interface KotlinChangeSignatureConfiguration { +interface KotlinChangeSignatureConfiguration { fun configure(originalDescriptor: KotlinMethodDescriptor): KotlinMethodDescriptor = originalDescriptor fun performSilently(affectedFunctions: Collection): Boolean = false fun forcePerformForSelectedFunctionOnly(): Boolean = false @@ -61,7 +61,7 @@ fun KotlinMethodDescriptor.modify(action: (KotlinMutableMethodDescriptor) -> Uni return newDescriptor } -public fun runChangeSignature(project: Project, +fun runChangeSignature(project: Project, callableDescriptor: CallableDescriptor, configuration: KotlinChangeSignatureConfiguration, defaultValueContext: PsiElement, @@ -69,7 +69,7 @@ public fun runChangeSignature(project: Project, return KotlinChangeSignature(project, callableDescriptor, configuration, defaultValueContext, commandName).run() } -public class KotlinChangeSignature(project: Project, +class KotlinChangeSignature(project: Project, callableDescriptor: CallableDescriptor, val configuration: KotlinChangeSignatureConfiguration, val defaultValueContext: PsiElement, @@ -218,8 +218,7 @@ public class KotlinChangeSignature(project: Project, } } -@TestOnly -public fun createChangeInfo( +@TestOnly fun createChangeInfo( project: Project, callableDescriptor: CallableDescriptor, configuration: KotlinChangeSignatureConfiguration, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt index 9cdcda34bc5..e1e86f0794d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureData.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.utils.findVariable import java.util.* -public class KotlinChangeSignatureData( +class KotlinChangeSignatureData( override val baseDescriptor: CallableDescriptor, override val baseDeclaration: PsiElement, private val descriptorsForSignatureChange: Collection diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt index 8a380e18c51..0612a7df100 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class KotlinChangeSignatureHandler : ChangeSignatureHandler { +class KotlinChangeSignatureHandler : ChangeSignatureHandler { override fun findTargetMember(file: PsiFile, editor: Editor) = file.findElementAt(editor.caretModel.offset)?.let { findTargetMember(it) } @@ -75,7 +75,7 @@ public class KotlinChangeSignatureHandler : ChangeSignatureHandler { KotlinRefactoringBundle.message("error.wrong.caret.position.function.or.constructor.name") companion object { - public fun findTargetForRefactoring(element: PsiElement): PsiElement? { + fun findTargetForRefactoring(element: PsiElement): PsiElement? { val elementParent = element.parent if ((elementParent is KtNamedFunction || elementParent is KtClass || elementParent is KtProperty) @@ -120,7 +120,7 @@ public class KotlinChangeSignatureHandler : ChangeSignatureHandler { return null } - public fun invokeChangeSignature(element: KtElement, context: PsiElement, project: Project, editor: Editor?) { + fun invokeChangeSignature(element: KtElement, context: PsiElement, project: Project, editor: Editor?) { val bindingContext = element.analyze(BodyResolveMode.FULL) val callableDescriptor = findDescriptor(element, project, editor, bindingContext) ?: return @@ -160,7 +160,7 @@ public class KotlinChangeSignatureHandler : ChangeSignatureHandler { return if (descriptor is ClassDescriptor) descriptor.unsubstitutedPrimaryConstructor else descriptor } - public fun findDescriptor(element: PsiElement, project: Project, editor: Editor?, bindingContext: BindingContext): CallableDescriptor? { + fun findDescriptor(element: PsiElement, project: Project, editor: Editor?, bindingContext: BindingContext): CallableDescriptor? { if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return null var descriptor = getDescriptor(bindingContext, element) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt index dff251d4770..231acb15331 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinUsageI import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinWrapperForJavaUsageInfos import java.util.* -public class KotlinChangeSignatureProcessor(project: Project, +class KotlinChangeSignatureProcessor(project: Project, changeInfo: KotlinChangeInfo, private val commandName: String) : ChangeSignatureProcessorBase(project, changeInfo) { override fun createUsageViewDescriptor(usages: Array): UsageViewDescriptor { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt index 37fc8c587ab..ac4f3e3f97c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMethodDescriptor.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallab import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.psi.KtCallableDeclaration -public interface KotlinMethodDescriptor : MethodDescriptor { +interface KotlinMethodDescriptor : MethodDescriptor { enum class Kind(val isConstructor: Boolean) { FUNCTION(false), PRIMARY_CONSTRUCTOR(true), diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt index b3a2532e54f..12195bd95f6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinMutableMethodDescriptor.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature import org.jetbrains.kotlin.descriptors.Visibility -public class KotlinMutableMethodDescriptor(override val original: KotlinMethodDescriptor): KotlinMethodDescriptor by original { +class KotlinMutableMethodDescriptor(override val original: KotlinMethodDescriptor): KotlinMethodDescriptor by original { private val parameters: MutableList = original.parameters override var receiver: KotlinParameterInfo? = original.receiver @@ -29,22 +29,22 @@ public class KotlinMutableMethodDescriptor(override val original: KotlinMethodDe field = value } - public fun addParameter(parameter: KotlinParameterInfo) { + fun addParameter(parameter: KotlinParameterInfo) { parameters.add(parameter) } - public fun removeParameter(index: Int) { + fun removeParameter(index: Int) { val paramInfo = parameters.removeAt(index) if (paramInfo == receiver) { receiver = null } } - public fun renameParameter(index: Int, newName: String) { + fun renameParameter(index: Int, newName: String) { parameters[index].name = newName } - public fun clearNonReceiverParameters() { + fun clearNonReceiverParameters() { parameters.clear() receiver?.let { parameters.add(it) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt index 9b754dbe0d9..e9fbb04960f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinParameterInfo.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver import java.util.* -public class KotlinParameterInfo @JvmOverloads constructor ( +class KotlinParameterInfo @JvmOverloads constructor ( val callableDescriptor: CallableDescriptor, val originalIndex: Int = -1, private var name: String, @@ -46,7 +46,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( ): ParameterInfo { var currentTypeInfo: KotlinTypeInfo = originalTypeInfo - public val defaultValueParameterReferences: Map + val defaultValueParameterReferences: Map init { val file = defaultValueForCall?.containingFile as? KtFile @@ -124,7 +124,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( override fun getOldIndex(): Int = originalIndex - public val isNewParameter: Boolean + val isNewParameter: Boolean get() = originalIndex == -1 override fun getDefaultValue(): String? = null @@ -137,7 +137,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( override fun getTypeText(): String = currentTypeInfo.render() - public val isTypeChanged: Boolean get() = !currentTypeInfo.isEquivalentTo(originalTypeInfo) + val isTypeChanged: Boolean get() = !currentTypeInfo.isEquivalentTo(originalTypeInfo) override fun isUseAnySingleVariable(): Boolean = false @@ -145,7 +145,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( throw UnsupportedOperationException() } - public fun renderType(parameterIndex: Int, inheritedCallable: KotlinCallableDefinitionUsage<*>): String { + fun renderType(parameterIndex: Int, inheritedCallable: KotlinCallableDefinitionUsage<*>): String { val defaultRendering = currentTypeInfo.render() val typeSubstitutor = inheritedCallable.typeSubstitutor ?: return defaultRendering val currentBaseFunction = inheritedCallable.baseFunction.currentCallableDescriptor ?: return defaultRendering @@ -154,7 +154,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( return parameterType.renderTypeWithSubstitution(typeSubstitutor, defaultRendering, true) } - public fun getInheritedName(inheritedCallable: KotlinCallableDefinitionUsage<*>): String { + fun getInheritedName(inheritedCallable: KotlinCallableDefinitionUsage<*>): String { if (!inheritedCallable.isInherited) return name val baseFunction = inheritedCallable.baseFunction @@ -175,7 +175,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( } } - public fun requiresExplicitType(inheritedCallable: KotlinCallableDefinitionUsage<*>): Boolean { + fun requiresExplicitType(inheritedCallable: KotlinCallableDefinitionUsage<*>): Boolean { val inheritedFunctionDescriptor = inheritedCallable.originalCallableDescriptor if (inheritedFunctionDescriptor !is AnonymousFunctionDescriptor) return true @@ -186,7 +186,7 @@ public class KotlinParameterInfo @JvmOverloads constructor ( return parameter.typeReference != null } - public fun getDeclarationSignature(parameterIndex: Int, inheritedCallable: KotlinCallableDefinitionUsage<*>): String { + fun getDeclarationSignature(parameterIndex: Int, inheritedCallable: KotlinCallableDefinitionUsage<*>): String { val buffer = StringBuilder() if (modifierList != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinUsagesViewDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinUsagesViewDescriptor.kt index 8bc07726f59..ce935cea77f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinUsagesViewDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinUsagesViewDescriptor.kt @@ -21,7 +21,7 @@ import com.intellij.refactoring.RefactoringBundle import com.intellij.usageView.UsageViewBundle import com.intellij.usageView.UsageViewDescriptor -public class KotlinUsagesViewDescriptor(private val element: PsiElement, private val elementsHeader: String) : UsageViewDescriptor { +class KotlinUsagesViewDescriptor(private val element: PsiElement, private val elementsHeader: String) : UsageViewDescriptor { override fun getElements(): Array = arrayOf(element) override fun getProcessedElementsHeader(): String = elementsHeader diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt index 10a1fe3d1a3..5aa1bcf3c5f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinValVar.kt @@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtPsiFactory -public enum class KotlinValVar(val keywordName: String) { +enum class KotlinValVar(val keywordName: String) { None("none") { override fun createKeyword(factory: KtPsiFactory) = null }, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt index 9cddbe5bbb0..d563c45d042 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt @@ -42,7 +42,7 @@ fun KtNamedDeclaration.getDeclarationBody(): KtElement? { } } -public fun PsiElement.isCaller(allUsages: Array): Boolean { +fun PsiElement.isCaller(allUsages: Array): Boolean { val elementToSearch = (this as? KtClass)?.getPrimaryConstructor() ?: this return allUsages .asSequence() @@ -56,7 +56,7 @@ public fun PsiElement.isCaller(allUsages: Array): Boolean { .any { it.element == elementToSearch } } -public fun KtElement.isInsideOfCallerBody(allUsages: Array): Boolean { +fun KtElement.isInsideOfCallerBody(allUsages: Array): Boolean { val container = parentsWithSelf.firstOrNull { it is KtNamedFunction || it is KtConstructor<*> || it is KtClassOrObject } as? KtNamedDeclaration ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt index 6c9d54b9914..800cbb4b8e4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt @@ -48,7 +48,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import java.util.HashSet import java.util.LinkedHashSet -public class KotlinCallerChooser( +class KotlinCallerChooser( declaration: PsiElement, project: Project, title: String, @@ -69,7 +69,7 @@ public class KotlinCallerChooser( "Callee text would be shown here" } -public class KotlinMethodNode( +class KotlinMethodNode( method: PsiElement?, called: HashSet, project: Project, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt index ca9513f11b4..5f9f7a6d183 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt @@ -36,7 +36,7 @@ import javax.swing.JComponent import javax.swing.JLabel import kotlin.properties.Delegates -public class KotlinChangePropertySignatureDialog( +class KotlinChangePropertySignatureDialog( project: Project, private val methodDescriptor: KotlinMethodDescriptor, private val commandName: String? diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt index 5532e3db288..0d26f4323bb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt @@ -64,7 +64,7 @@ import java.awt.event.ItemEvent import java.util.* import javax.swing.* -public class KotlinChangeSignatureDialog( +class KotlinChangeSignatureDialog( project: Project, methodDescriptor: KotlinMethodDescriptor, context: PsiElement, @@ -163,7 +163,7 @@ public class KotlinChangeSignatureDialog( override fun getTableEditor(table: JTable, item: ParameterTableModelItemBase): JBTableRowEditor? { return object : JBTableRowEditor() { private val components = ArrayList() - private val nameEditor = EditorTextField(item.parameter.name, getProject(), getFileType()) + private val nameEditor = EditorTextField(item.parameter.name, project, fileType) private fun updateNameEditor() { nameEditor.isEnabled = item.parameter != parametersTableModel.receiver @@ -183,8 +183,8 @@ public class KotlinChangeSignatureDialog( val columnFinal = column if (KotlinCallableParameterTableModel.isTypeColumn(columnInfo)) { - val document = PsiDocumentManager.getInstance(getProject()).getDocument(item.typeCodeFragment) - editor = EditorTextField(document, getProject(), getFileType()) + val document = PsiDocumentManager.getInstance(project).getDocument(item.typeCodeFragment) + editor = EditorTextField(document, project, fileType) component = editor } else if (KotlinCallableParameterTableModel.isNameColumn(columnInfo)) { @@ -193,8 +193,8 @@ public class KotlinChangeSignatureDialog( updateNameEditor() } else if (KotlinCallableParameterTableModel.isDefaultValueColumn(columnInfo) && isDefaultColumnEnabled()) { - val document = PsiDocumentManager.getInstance(getProject()).getDocument(item.defaultValueCodeFragment) - editor = EditorTextField(document, getProject(), getFileType()) + val document = PsiDocumentManager.getInstance(project).getDocument(item.defaultValueCodeFragment) + editor = EditorTextField(document, project, fileType) component = editor } else if (KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo)) { @@ -390,7 +390,7 @@ public class KotlinChangeSignatureDialog( return KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: title) } - public fun getMethodDescriptor(): KotlinMethodDescriptor = myMethod + fun getMethodDescriptor(): KotlinMethodDescriptor = myMethod override fun getSelectedIdx(): Int { return myMethod.parameters.withIndex().firstOrNull { it.value.isNewParameter }?.index @@ -409,7 +409,7 @@ public class KotlinChangeSignatureDialog( private fun createReturnTypeCodeFragment(project: Project, method: KotlinMethodDescriptor) = KtPsiFactory(project).createTypeCodeFragment(method.returnTypeInfo.render(), method.baseDeclaration) - public fun createRefactoringProcessorForSilentChangeSignature(project: Project, + fun createRefactoringProcessorForSilentChangeSignature(project: Project, commandName: String, method: KotlinMethodDescriptor, defaultValueContext: PsiElement): BaseRefactoringProcessor { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt index 7623dd4f67a..90d9bf55e4e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt @@ -24,11 +24,11 @@ import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.types.KotlinType -public abstract class JavaMethodDeferredKotlinUsage(element: T) : UsageInfo(element) { +abstract class JavaMethodDeferredKotlinUsage(element: T) : UsageInfo(element) { abstract fun resolve(javaMethodChangeInfo: KotlinChangeInfo): JavaMethodKotlinUsageWithDelegate } -public class DeferredJavaMethodOverrideOrSAMUsage( +class DeferredJavaMethodOverrideOrSAMUsage( val function: KtFunction, val functionDescriptor: FunctionDescriptor, val samCallType: KotlinType? @@ -40,7 +40,7 @@ public class DeferredJavaMethodOverrideOrSAMUsage( } } -public class DeferredJavaMethodKotlinCallerUsage( +class DeferredJavaMethodKotlinCallerUsage( val declaration: KtNamedDeclaration ) : JavaMethodDeferredKotlinUsage(declaration) { override fun resolve(javaMethodChangeInfo: KotlinChangeInfo): JavaMethodKotlinUsageWithDelegate { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt index df3bb23907c..314126d0375 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo import org.jetbrains.kotlin.psi.KtCallElement import org.jetbrains.kotlin.psi.KtConstructorDelegationCall -public abstract class JavaMethodKotlinUsageWithDelegate( +abstract class JavaMethodKotlinUsageWithDelegate( val psiElement: T, var javaMethodChangeInfo: KotlinChangeInfo): UsageInfo(psiElement) { abstract val delegateUsage: KotlinUsageInfo @@ -30,7 +30,7 @@ public abstract class JavaMethodKotlinUsageWithDelegate( fun processUsage(allUsages: Array): Boolean = delegateUsage.processUsage(javaMethodChangeInfo, psiElement, allUsages) } -public class JavaMethodKotlinCallUsage( +class JavaMethodKotlinCallUsage( callElement: KtCallElement, javaMethodChangeInfo: KotlinChangeInfo, propagationCall: Boolean diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt index 34a5d92102d..3f86e1608cc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.isInsideOfCallerBod import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* -public class KotlinCallerUsage(element: KtNamedDeclaration): KotlinUsageInfo(element) { +class KotlinCallerUsage(element: KtNamedDeclaration): KotlinUsageInfo(element) { override fun processUsage(changeInfo: KotlinChangeInfo, element: KtNamedDeclaration, allUsages: Array): Boolean { // Do not process function twice if (changeInfo.getAffectedCallables().any { it is KotlinCallableDefinitionUsage<*> && it.element == element }) return true @@ -49,7 +49,7 @@ public class KotlinCallerUsage(element: KtNamedDeclaration): KotlinUsageInfo(element) { +class KotlinCallerCallUsage(element: KtCallElement): KotlinUsageInfo(element) { override fun processUsage(changeInfo: KotlinChangeInfo, element: KtCallElement, allUsages: Array): Boolean { val argumentList = element.valueArgumentList ?: return true val psiFactory = KtPsiFactory(project) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt index 64296474c34..0fc52f1b04f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinConstructorDelegationCallUsage.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.KtConstructorDelegationCall import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtSecondaryConstructor -public class KotlinConstructorDelegationCallUsage( +class KotlinConstructorDelegationCallUsage( call: KtConstructorDelegationCall, changeInfo: KotlinChangeInfo ) : KotlinUsageInfo(call) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt index c7fbc4b687e..556349a1025 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinEnumEntryWithoutSuperCallUsage.kt @@ -20,7 +20,7 @@ import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo import org.jetbrains.kotlin.psi.* -public class KotlinEnumEntryWithoutSuperCallUsage(enumEntry: KtEnumEntry) : KotlinUsageInfo(enumEntry) { +class KotlinEnumEntryWithoutSuperCallUsage(enumEntry: KtEnumEntry) : KotlinUsageInfo(enumEntry) { override fun processUsage(changeInfo: KotlinChangeInfo, element: KtEnumEntry, allUsages: Array): Boolean { if (changeInfo.newParameters.size > 0) { val psiFactory = KtPsiFactory(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt index 7374a961506..d87b551fa0b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinImplicitThisToParameterUsage.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet import org.jetbrains.kotlin.idea.util.ShortenReferences.Options -public abstract class KotlinImplicitReceiverUsage(callElement: KtElement): KotlinUsageInfo(callElement) { +abstract class KotlinImplicitReceiverUsage(callElement: KtElement): KotlinUsageInfo(callElement) { protected abstract fun getNewReceiverText(): String protected open fun processReplacedElement(element: KtElement) { @@ -42,7 +42,7 @@ public abstract class KotlinImplicitReceiverUsage(callElement: KtElement): Kotli } } -public class KotlinImplicitThisToParameterUsage( +class KotlinImplicitThisToParameterUsage( callElement: KtElement, val parameterInfo: KotlinParameterInfo, val containingCallable: KotlinCallableDefinitionUsage<*> @@ -54,13 +54,13 @@ public class KotlinImplicitThisToParameterUsage( } } -public class KotlinImplicitThisUsage( +class KotlinImplicitThisUsage( callElement: KtElement, val targetDescriptor: DeclarationDescriptor ): KotlinImplicitReceiverUsage(callElement) { override fun getNewReceiverText(): String { - val name = targetDescriptor.getName() - return if (name.isSpecial()) "this" else "this@${name.asString()}" + val name = targetDescriptor.name + return if (name.isSpecial) "this" else "this@${name.asString()}" } override fun processReplacedElement(element: KtElement) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt index 71d8c731886..41413912dbe 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinParameterUsage.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtQualifiedExpression import org.jetbrains.kotlin.psi.KtThisExpression // Explicit reference to function parameter or outer this -public abstract class KotlinExplicitReferenceUsage(element: T) : KotlinUsageInfo(element) { +abstract class KotlinExplicitReferenceUsage(element: T) : KotlinUsageInfo(element) { abstract fun getReplacementText(changeInfo: KotlinChangeInfo): String protected open fun processReplacedElement(element: KtElement) { @@ -44,7 +44,7 @@ public abstract class KotlinExplicitReferenceUsage(element: T) : } } -public class KotlinParameterUsage( +class KotlinParameterUsage( element: KtElement, private val parameterInfo: KotlinParameterInfo, val containingCallable: KotlinCallableDefinitionUsage<*> @@ -65,7 +65,7 @@ public class KotlinParameterUsage( } } -public class KotlinNonQualifiedOuterThisUsage( +class KotlinNonQualifiedOuterThisUsage( element: KtThisExpression, val targetDescriptor: DeclarationDescriptor ) : KotlinExplicitReferenceUsage(element) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt index 8b6c578c5da..9959625214f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinPropertyCallUsage.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver -public class KotlinPropertyCallUsage(element: KtSimpleNameExpression): KotlinUsageInfo(element) { +class KotlinPropertyCallUsage(element: KtSimpleNameExpression): KotlinUsageInfo(element) { private val resolvedCall = element.getResolvedCall(element.analyze()) override fun processUsage(changeInfo: KotlinChangeInfo, element: KtSimpleNameExpression, allUsages: Array): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinUsageInfo.kt index 4ca73c2f139..55c416b10be 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinUsageInfo.kt @@ -21,12 +21,12 @@ import com.intellij.psi.PsiReference import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinChangeInfo -public abstract class KotlinUsageInfo : UsageInfo { - public constructor(element: T) : super(element) - public constructor(reference: PsiReference) : super(reference) +abstract class KotlinUsageInfo : UsageInfo { + constructor(element: T) : super(element) + constructor(reference: PsiReference) : super(reference) @Suppress("UNCHECKED_CAST") override fun getElement() = super.getElement() as T? - public abstract fun processUsage(changeInfo: KotlinChangeInfo, element: T, allUsages: Array): Boolean + abstract fun processUsage(changeInfo: KotlinChangeInfo, element: T, allUsages: Array): Boolean } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt index d59681833cb..809de2dc9f7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt @@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement import com.intellij.refactoring.changeSignature.JavaChangeInfo import com.intellij.usageView.UsageInfo -public class KotlinWrapperForJavaUsageInfos( +class KotlinWrapperForJavaUsageInfos( val javaChangeInfo: JavaChangeInfo, val javaUsageInfos: Array, val primaryMethod: PsiElement diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt index e5f44728c9c..5a954f38730 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt @@ -22,7 +22,7 @@ import com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler import com.intellij.refactoring.copy.CopyHandlerDelegateBase import org.jetbrains.kotlin.psi.KtFile -public class CopyKotlinFileHandler : CopyHandlerDelegateBase() { +class CopyKotlinFileHandler : CopyHandlerDelegateBase() { private val delegate = CopyFilesOrDirectoriesHandler() private fun adjustElements(elements: Array): Array? { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt index 6a6a3c96646..472045ae2c6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractIntroduceAction.kt @@ -20,13 +20,13 @@ import com.intellij.refactoring.actions.* import com.intellij.psi.* import org.jetbrains.kotlin.psi.* -public abstract class AbstractIntroduceAction : BasePlatformRefactoringAction() { +abstract class AbstractIntroduceAction : BasePlatformRefactoringAction() { init { setInjectedContext(true) } override fun isAvailableInEditorOnly(): Boolean = true - protected override fun isEnabledOnElements(elements: Array): Boolean = + override fun isEnabledOnElements(elements: Array): Boolean = elements.all { it is KtElement } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt index 072bf961d19..6c696169c91 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch import java.awt.BorderLayout -public abstract class AbstractKotlinInplaceIntroducer( +abstract class AbstractKotlinInplaceIntroducer( localVariable: D?, expression: KtExpression?, occurrences: Array, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt index 926f7caaca4..bf8cdd1692b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractFunctionAction.kt @@ -21,12 +21,12 @@ import com.intellij.lang.refactoring.RefactoringSupportProvider import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSupportProvider import org.jetbrains.kotlin.idea.refactoring.introduce.* -public class ExtractFunctionAction: AbstractIntroduceAction() { +class ExtractFunctionAction: AbstractIntroduceAction() { override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? = (provider as? KotlinRefactoringSupportProvider)?.getExtractFunctionHandler() } -public class ExtractFunctionToScopeAction: AbstractIntroduceAction() { +class ExtractFunctionToScopeAction: AbstractIntroduceAction() { override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? = (provider as? KotlinRefactoringSupportProvider)?.getExtractFunctionToScopeHandler() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt index 147ace69c72..5e35d8e4917 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt @@ -31,8 +31,8 @@ import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtFile -public class ExtractKotlinFunctionHandler( - public val allContainersEnabled: Boolean = false, +class ExtractKotlinFunctionHandler( + val allContainersEnabled: Boolean = false, private val helper: ExtractionEngineHelper = ExtractKotlinFunctionHandler.InteractiveExtractionHelper) : RefactoringActionHandler { object InteractiveExtractionHelper : ExtractionEngineHelper(EXTRACT_FUNCTION) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinFunctionSignatureComponent.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinFunctionSignatureComponent.kt index 581ec950476..e49bedf4661 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinFunctionSignatureComponent.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinFunctionSignatureComponent.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.project.Project import org.jetbrains.kotlin.idea.KotlinFileType import com.intellij.refactoring.ui.MethodSignatureComponent -public class KotlinFunctionSignatureComponent( +class KotlinFunctionSignatureComponent( signature: String, project: Project ) : MethodSignatureComponent(signature, project, KotlinFileType.INSTANCE) { private val myFileName = "dummy." + KotlinFileType.EXTENSION diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt index 43852e62634..bf7b090f835 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.showErrorHint import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import javax.swing.event.HyperlinkEvent -public abstract class ExtractionEngineHelper(val operationName: String) { +abstract class ExtractionEngineHelper(val operationName: String) { open fun adjustExtractionData(data: ExtractionData): ExtractionData = data fun doRefactor(config: ExtractionGeneratorConfiguration, onFinish: (ExtractionResult) -> Unit = {}) { @@ -45,7 +45,7 @@ public abstract class ExtractionEngineHelper(val operationName: String) { ) } -public class ExtractionEngine( +class ExtractionEngine( val helper: ExtractionEngineHelper ) { fun run(editor: Editor, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt index fbf23a4eebf..90963ab0831 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt @@ -37,7 +37,7 @@ import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler import com.intellij.refactoring.RefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.getPhysicalTextRange -public fun KotlinPsiRange.highlight(project: Project, editor: Editor): RangeHighlighter? { +fun KotlinPsiRange.highlight(project: Project, editor: Editor): RangeHighlighter? { val textRange = getPhysicalTextRange() val highlighters = ArrayList() val attributes = EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!! @@ -47,7 +47,7 @@ public fun KotlinPsiRange.highlight(project: Project, editor: Editor): RangeHigh return highlighters.firstOrNull() } -public fun KotlinPsiRange.preview(project: Project, editor: Editor): RangeHighlighter? { +fun KotlinPsiRange.preview(project: Project, editor: Editor): RangeHighlighter? { return highlight(project, editor)?.let { val startOffset = getPhysicalTextRange().startOffset val foldedRegions = @@ -63,7 +63,7 @@ public fun KotlinPsiRange.preview(project: Project, editor: Editor): RangeHighli } } -public fun processDuplicates( +fun processDuplicates( duplicateReplacers: Map Unit>, project: Project, editor: Editor @@ -115,7 +115,7 @@ public fun processDuplicates( } } -public fun processDuplicatesSilently(duplicateReplacers: Map Unit>, project: Project) { +fun processDuplicatesSilently(duplicateReplacers: Map Unit>, project: Project) { project.executeWriteCommand(MethodDuplicatesHandler.REFACTORING_NAME) { duplicateReplacers.values.forEach { it() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/IntroduceLambdaParameterAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/IntroduceLambdaParameterAction.kt index 5185f01cfd1..a5f4d6506f0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/IntroduceLambdaParameterAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/IntroduceLambdaParameterAction.kt @@ -21,7 +21,7 @@ import com.intellij.refactoring.RefactoringActionHandler import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSupportProvider import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractIntroduceAction -public class IntroduceLambdaParameterAction : AbstractIntroduceAction() { +class IntroduceLambdaParameterAction : AbstractIntroduceAction() { override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? = (provider as? KotlinRefactoringSupportProvider)?.getIntroduceLambdaParameterHandler() } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt index cf9a7de5f5d..1b45220b522 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt @@ -47,7 +47,7 @@ import java.awt.Color import java.util.* import javax.swing.JCheckBox -public class KotlinInplaceParameterIntroducer( +class KotlinInplaceParameterIntroducer( val originalDescriptor: IntroduceParameterDescriptor, val parameterType: KotlinType, val suggestedNames: Array, @@ -175,7 +175,7 @@ public class KotlinInplaceParameterIntroducer( init { initFormComponents { - addComponent(getPreviewComponent()) + addComponent(previewComponent) val defaultValueCheckBox = NonFocusableCheckBox("Introduce default value") defaultValueCheckBox.isSelected = descriptor.withDefaultValue diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt index b61b9a248e3..6733cc650c7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt @@ -45,7 +45,7 @@ import javax.swing.JComponent import javax.swing.JLabel import javax.swing.JPanel -public class KotlinIntroduceParameterDialog private constructor( +class KotlinIntroduceParameterDialog private constructor( project: Project, val editor: Editor, val descriptor: IntroduceParameterDescriptor, @@ -238,7 +238,7 @@ public class KotlinIntroduceParameterDialog private constructor( performRefactoring() } - public fun performRefactoring() { + fun performRefactoring() { invokeRefactoring( object : BaseRefactoringProcessor(myProject) { override fun findUsages() = UsageInfo.EMPTY_ARRAY diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index 25afc38f50f..8eb4fa2e0cb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -66,7 +66,7 @@ import org.jetbrains.kotlin.types.typeUtil.supertypes import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* -public data class IntroduceParameterDescriptor( +data class IntroduceParameterDescriptor( val originalRange: KotlinPsiRange, val callable: KtNamedDeclaration, val callableDescriptor: FunctionDescriptor, @@ -206,13 +206,13 @@ fun selectNewParameterContext( ) } -public interface KotlinIntroduceParameterHelper { +interface KotlinIntroduceParameterHelper { object Default: KotlinIntroduceParameterHelper fun configure(descriptor: IntroduceParameterDescriptor): IntroduceParameterDescriptor = descriptor } -public open class KotlinIntroduceParameterHandler( +open class KotlinIntroduceParameterHandler( val helper: KotlinIntroduceParameterHelper = KotlinIntroduceParameterHelper.Default ): RefactoringActionHandler { open fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) { @@ -450,7 +450,7 @@ interface KotlinIntroduceLambdaParameterHelper: KotlinIntroduceParameterHelper { fun configureExtractLambda(descriptor: ExtractableCodeDescriptor): ExtractableCodeDescriptor = descriptor } -public open class KotlinIntroduceLambdaParameterHandler( +open class KotlinIntroduceLambdaParameterHandler( helper: KotlinIntroduceLambdaParameterHelper = KotlinIntroduceLambdaParameterHelper.Default ): KotlinIntroduceParameterHandler(helper) { val extractLambdaHelper = object: ExtractionEngineHelper(INTRODUCE_LAMBDA_PARAMETER) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt index beb82524a61..b508bdb9806 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import java.util.* -public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMethodUsagesProcessor { +class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMethodUsagesProcessor { override fun isMethodUsage(usage: UsageInfo): Boolean = (usage.element as? KtElement)?.let { it.getParentOfTypeAndBranch(true) { calleeExpression } != null } ?: false diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt index 23880dbeed2..b4a667796b6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/IntroducePropertyAction.kt @@ -21,7 +21,7 @@ import com.intellij.lang.refactoring.RefactoringSupportProvider import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSupportProvider import org.jetbrains.kotlin.idea.refactoring.introduce.* -public class IntroducePropertyAction : AbstractIntroduceAction() { +class IntroducePropertyAction : AbstractIntroduceAction() { override fun getRefactoringHandler(provider: RefactoringSupportProvider): RefactoringActionHandler? = (provider as? KotlinRefactoringSupportProvider)?.getIntroducePropertyHandler() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt index 7a67d436509..369a628df7f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.types.KotlinType import javax.swing.* import javax.swing.event.PopupMenuEvent -public class KotlinInplacePropertyIntroducer( +class KotlinInplacePropertyIntroducer( property: KtProperty, editor: Editor, project: Project, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt index 9712b2f3d98..80cd40505fa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt @@ -30,7 +30,7 @@ import com.intellij.refactoring.RefactoringActionHandler import org.jetbrains.kotlin.idea.refactoring.getExtractionContainers import java.util.* -public class KotlinIntroducePropertyHandler( +class KotlinIntroducePropertyHandler( val helper: ExtractionEngineHelper = KotlinIntroducePropertyHandler.InteractiveExtractionHelper ): RefactoringActionHandler { object InteractiveExtractionHelper : ExtractionEngineHelper(INTRODUCE_PROPERTY) { @@ -52,7 +52,7 @@ public class KotlinIntroducePropertyHandler( } } - public fun selectElements(editor: Editor, file: KtFile, continuation: (elements: List, targetSibling: PsiElement) -> Unit) { + fun selectElements(editor: Editor, file: KtFile, continuation: (elements: List, targetSibling: PsiElement) -> Unit) { selectElementsWithTargetSibling( INTRODUCE_PROPERTY, editor, @@ -64,7 +64,7 @@ public class KotlinIntroducePropertyHandler( ) } - public fun doInvoke(project: Project, editor: Editor, file: KtFile, elements: List, targetSibling: PsiElement) { + fun doInvoke(project: Project, editor: Editor, file: KtFile, elements: List, targetSibling: PsiElement) { val adjustedElements = (elements.singleOrNull() as? KtBlockExpression)?.statements ?: elements if (adjustedElements.isNotEmpty()) { val options = ExtractionOptions(extractAsProperty = true) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt index 52a915122c1..2ce80c5aaec 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.types.KotlinType -public class KotlinVariableInplaceIntroducer( +class KotlinVariableInplaceIntroducer( val addedVariable: KtProperty, val originalExpression: KtExpression?, val occurrencesToReplace: Array, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt index d8a577e7ebc..48df90f61dc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/javaElementFactoryUtils.kt @@ -21,7 +21,7 @@ import com.intellij.psi.PsiJavaCodeReferenceElement import com.intellij.psi.PsiReferenceList import com.intellij.psi.PsiReferenceList.Role -public fun PsiElementFactory.createReferenceListWithRole( +fun PsiElementFactory.createReferenceListWithRole( references: Array, role: Role ): PsiReferenceList? { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index 1bd32f06a50..d68abcd5fb5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -107,36 +107,36 @@ fun createKotlinFile(fileName: String, return targetDir.add(file) as KtFile } -public fun File.toVirtualFile(): VirtualFile? = LocalFileSystem.getInstance().findFileByIoFile(this) +fun File.toVirtualFile(): VirtualFile? = LocalFileSystem.getInstance().findFileByIoFile(this) -public fun File.toPsiFile(project: Project): PsiFile? = toVirtualFile()?.toPsiFile(project) +fun File.toPsiFile(project: Project): PsiFile? = toVirtualFile()?.toPsiFile(project) -public fun File.toPsiDirectory(project: Project): PsiDirectory? { +fun File.toPsiDirectory(project: Project): PsiDirectory? { return toVirtualFile()?.let { vfile -> PsiManager.getInstance(project).findDirectory(vfile) } } -public fun VirtualFile.toPsiFile(project: Project): PsiFile? = PsiManager.getInstance(project).findFile(this) +fun VirtualFile.toPsiFile(project: Project): PsiFile? = PsiManager.getInstance(project).findFile(this) -public fun VirtualFile.toPsiDirectory(project: Project): PsiDirectory? = PsiManager.getInstance(project).findDirectory(this) +fun VirtualFile.toPsiDirectory(project: Project): PsiDirectory? = PsiManager.getInstance(project).findDirectory(this) -public fun PsiElement.getUsageContext(): PsiElement { +fun PsiElement.getUsageContext(): PsiElement { return when (this) { is KtElement -> PsiTreeUtil.getParentOfType(this, KtNamedDeclaration::class.java, KtFile::class.java)!! else -> ConflictsUtil.getContainer(this) } } -public fun PsiElement.isInJavaSourceRoot(): Boolean = +fun PsiElement.isInJavaSourceRoot(): Boolean = !JavaProjectRootsUtil.isOutsideJavaSourceRoot(containingFile) -public fun KtFile.createTempCopy(text: String? = null): KtFile { +fun KtFile.createTempCopy(text: String? = null): KtFile { val tmpFile = KtPsiFactory(this).createAnalyzableFile(name, text ?: this.text ?: "", this) tmpFile.originalFile = this tmpFile.suppressDiagnosticsInDebugMode = suppressDiagnosticsInDebugMode return tmpFile } -public fun PsiElement.getAllExtractionContainers(strict: Boolean = true): List { +fun PsiElement.getAllExtractionContainers(strict: Boolean = true): List { val containers = ArrayList() var objectFound = false @@ -158,7 +158,7 @@ public fun PsiElement.getAllExtractionContainers(strict: Boolean = true): List { +fun PsiElement.getExtractionContainers(strict: Boolean = true, includeAll: Boolean = false): List { fun getEnclosingDeclaration(element: PsiElement, strict: Boolean): PsiElement? { return (if (strict) element.parents else element.parentsWithSelf) .filter { @@ -190,7 +190,7 @@ public fun PsiElement.getExtractionContainers(strict: Boolean = true, includeAll } } -public fun Project.checkConflictsInteractively( +fun Project.checkConflictsInteractively( conflicts: MultiMap, onShowConflicts: () -> Unit = {}, onAccept: () -> Unit) { @@ -210,7 +210,7 @@ public fun Project.checkConflictsInteractively( onAccept() } -public fun reportDeclarationConflict( +fun reportDeclarationConflict( conflicts: MultiMap, declaration: PsiElement, message: (renderedDeclaration: String) -> String @@ -218,7 +218,7 @@ public fun reportDeclarationConflict( conflicts.putValue(declaration, message(RefactoringUIUtil.getDescription(declaration, true).capitalize())) } -public fun getPsiElementPopup( +fun getPsiElementPopup( editor: Editor, elements: List, renderer: PsiElementListCellRenderer, @@ -257,7 +257,7 @@ public fun getPsiElementPopup( } } -public class SelectionAwareScopeHighlighter(val editor: Editor) { +class SelectionAwareScopeHighlighter(val editor: Editor) { private val highlighters = ArrayList() private fun addHighlighter(r: TextRange, attr: TextAttributes) { @@ -272,7 +272,7 @@ public class SelectionAwareScopeHighlighter(val editor: Editor) { ) } - public fun highlight(wholeAffected: PsiElement) { + fun highlight(wholeAffected: PsiElement) { dropHighlight() val attributes = EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!! @@ -282,7 +282,7 @@ public class SelectionAwareScopeHighlighter(val editor: Editor) { } } - public fun dropHighlight() { + fun dropHighlight() { highlighters.forEach { it.dispose() } highlighters.clear() } @@ -324,7 +324,7 @@ fun PsiElement.getLineCount(): Int { fun PsiElement.isMultiLine(): Boolean = getLineCount() > 1 -public fun KtElement.getContextForContainingDeclarationBody(): BindingContext? { +fun KtElement.getContextForContainingDeclarationBody(): BindingContext? { val enclosingDeclaration = getStrictParentOfType() val bodyElement = when (enclosingDeclaration) { is KtDeclarationWithBody -> enclosingDeclaration.bodyExpression @@ -341,7 +341,7 @@ public fun KtElement.getContextForContainingDeclarationBody(): BindingContext? { return bodyElement?.let { it.analyze() } } -public fun chooseContainerElement( +fun chooseContainerElement( containers: List, editor: Editor, title: String, @@ -414,7 +414,7 @@ public fun chooseContainerElement( ).showInBestPositionFor(editor) } -public fun chooseContainerElementIfNecessary( +fun chooseContainerElementIfNecessary( containers: List, editor: Editor, title: String, @@ -429,9 +429,9 @@ public fun chooseContainerElementIfNecessary( } } -public fun PsiElement.isTrueJavaMethod(): Boolean = this is PsiMethod && this !is KtLightMethod +fun PsiElement.isTrueJavaMethod(): Boolean = this is PsiMethod && this !is KtLightMethod -public fun PsiElement.canRefactor(): Boolean { +fun PsiElement.canRefactor(): Boolean { return when { this is PsiPackage -> directories.any { it.canRefactor() } @@ -483,13 +483,13 @@ private fun copyTypeParameters( } } -public fun createJavaMethod(function: KtFunction, targetClass: PsiClass): PsiMethod { +fun createJavaMethod(function: KtFunction, targetClass: PsiClass): PsiMethod { val template = LightClassUtil.getLightClassMethod(function) ?: throw AssertionError("Can't generate light method: ${function.getElementTextWithContext()}") return createJavaMethod(template, targetClass) } -public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMethod { +fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMethod { val factory = PsiElementFactory.SERVICE.getInstance(template.project) val methodToAdd = if (template.isConstructor) { factory.createConstructor(template.name) @@ -634,7 +634,7 @@ fun PsiMember.j2k(): KtNamedDeclaration? { return KtPsiFactory(project).createDeclaration(text) } -public fun (() -> Any).runRefactoringWithPostprocessing( +fun (() -> Any).runRefactoringWithPostprocessing( project: Project, targetRefactoringId: String, finishAction: () -> Unit @@ -668,8 +668,7 @@ public fun (() -> Any).runRefactoringWithPostprocessing( this() } -@Throws(ConfigurationException::class) -public fun KtElement?.validateElement(errorMessage: String) { +@Throws(ConfigurationException::class) fun KtElement?.validateElement(errorMessage: String) { if (this == null) throw ConfigurationException(errorMessage) try { @@ -680,13 +679,13 @@ public fun KtElement?.validateElement(errorMessage: String) { } } -public fun Project.runSynchronouslyWithProgress(progressTitle: String, canBeCanceled: Boolean, action: () -> T): T? { +fun Project.runSynchronouslyWithProgress(progressTitle: String, canBeCanceled: Boolean, action: () -> T): T? { var result: T? = null ProgressManager.getInstance().runProcessWithProgressSynchronously({ result = action() }, progressTitle, canBeCanceled, this) return result } -public fun invokeOnceOnCommandFinish(action: () -> Unit) { +fun invokeOnceOnCommandFinish(action: () -> Unit) { val commandProcessor = CommandProcessor.getInstance() val listener = object: CommandAdapter() { override fun beforeCommandFinished(event: CommandEvent?) { @@ -697,9 +696,9 @@ public fun invokeOnceOnCommandFinish(action: () -> Unit) { commandProcessor.addCommandListener(listener) } -public fun String.quoteIfNeeded(): String = if (KotlinNameSuggester.isIdentifier(this)) this else "`$this`" +fun String.quoteIfNeeded(): String = if (KotlinNameSuggester.isIdentifier(this)) this else "`$this`" -public fun FqNameUnsafe.hasIdentifiersOnly(): Boolean = pathSegments().all { KotlinNameSuggester.isIdentifier(it.asString()) } +fun FqNameUnsafe.hasIdentifiersOnly(): Boolean = pathSegments().all { KotlinNameSuggester.isIdentifier(it.asString()) } fun PsiNamedElement.isInterfaceClass(): Boolean = this is KtClass && isInterface() || this is PsiClass && isInterface diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt index 5d47d1a0aee..7866bf1be39 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfo.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.renderer.DescriptorRendererModifier import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptySet -public class KotlinMemberInfo(member: KtNamedDeclaration, val isSuperClass: Boolean = false) : MemberInfoBase(member) { +class KotlinMemberInfo(member: KtNamedDeclaration, val isSuperClass: Boolean = false) : MemberInfoBase(member) { companion object { private val RENDERER = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.withOptions { modifiers = DescriptorRendererModifier.INNER.singletonOrEmptySet() @@ -66,7 +66,7 @@ public class KotlinMemberInfo(member: KtNamedDeclaration, val isSuperClass: Bool } } -public fun KotlinMemberInfo.toJavaMemberInfo(): MemberInfo? { +fun KotlinMemberInfo.toJavaMemberInfo(): MemberInfo? { val declaration = member val psiMember: PsiMember? = when (declaration) { is KtNamedFunction, is KtProperty -> declaration.getRepresentativeLightMethod() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfoStorage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfoStorage.kt index 3ac142f37f5..11ee1d57a49 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfoStorage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberInfoStorage.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes import java.util.ArrayList -public class KotlinMemberInfoStorage( +class KotlinMemberInfoStorage( classOrObject: PsiNamedElement, filter: (KtNamedDeclaration) -> Boolean = { true } ): AbstractMemberInfoStorage(classOrObject, filter) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionPanel.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionPanel.kt index 0ffe408228b..c243286567b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionPanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionPanel.kt @@ -22,7 +22,7 @@ import com.intellij.ui.SeparatorFactory import org.jetbrains.kotlin.psi.KtNamedDeclaration import java.awt.BorderLayout -public class KotlinMemberSelectionPanel(title: String, +class KotlinMemberSelectionPanel(title: String, memberInfo: List, abstractColumnHeader: String? ) : AbstractMemberSelectionPanel() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt index da5117f707c..4c16aa42d2a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/KotlinMemberSelectionTable.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.KtProperty import javax.swing.Icon -public class KotlinMemberSelectionTable( +class KotlinMemberSelectionTable( memberInfos: List, memberInfoModel: MemberInfoModel?, abstractColumnHeader: String? diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt index 000525210ee..d21d3fc58d6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/memberInfo/memberInfoUtils.kt @@ -35,7 +35,7 @@ fun PsiNamedElement.getClassDescriptorIfAny(resolutionFacade: ResolutionFacade? } // Applies to JetClassOrObject and PsiClass -public fun PsiNamedElement.qualifiedClassNameForRendering(): String { +fun PsiNamedElement.qualifiedClassNameForRendering(): String { val fqName = when (this) { is KtClassOrObject -> fqName?.asString() is PsiClass -> qualifiedName diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt index 0a79b1fb934..40d3504eb0f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt @@ -29,7 +29,7 @@ import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.PsiWhiteSpace import org.jetbrains.kotlin.idea.references.mainReference -public class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler { +class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler { override fun correctInnerClassUsage(usage: UsageInfo, outerClass: PsiClass) { val innerCall = usage.element?.parent as? KtCallExpression ?: return diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt index 490a4fe7965..b18ed5bd45c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageIntention.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.psi.KtPackageDirective -public class ChangePackageIntention: SelfTargetingOffsetIndependentIntention(KtPackageDirective::class.java, "Change package") { +class ChangePackageIntention: SelfTargetingOffsetIndependentIntention(KtPackageDirective::class.java, "Change package") { companion object { private val PACKAGE_NAME_VAR = "PACKAGE_NAME" } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageToMatchDirectoryIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageToMatchDirectoryIntention.kt index fc2f3ce243d..2cc9e28b37b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageToMatchDirectoryIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/ChangePackageToMatchDirectoryIntention.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.refactoring.hasIdentifiersOnly import org.jetbrains.kotlin.idea.intentions.SelfTargetingOffsetIndependentIntention import org.jetbrains.kotlin.psi.KtPackageDirective -public class ChangePackageToMatchDirectoryIntention : SelfTargetingOffsetIndependentIntention( +class ChangePackageToMatchDirectoryIntention : SelfTargetingOffsetIndependentIntention( KtPackageDirective::class.java, "", "Change file's package to match directory" ) { override fun isApplicableTo(element: KtPackageDirective): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt index e04f3d640fd..0416dfaf4b0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtNamedDeclaration -public class KotlinChangePackageRefactoring(val file: KtFile) { +class KotlinChangePackageRefactoring(val file: KtFile) { private val project = file.project fun run(newFqName: FqName) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt index 68ffb03988c..90bb948c8c1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/MoveFileToPackageMatchingDirectoryIntention.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.core.packageMatchesDirectory import org.jetbrains.kotlin.idea.intentions.SelfTargetingOffsetIndependentIntention import org.jetbrains.kotlin.psi.KtPackageDirective -public class MoveFileToPackageMatchingDirectoryIntention : SelfTargetingOffsetIndependentIntention( +class MoveFileToPackageMatchingDirectoryIntention : SelfTargetingOffsetIndependentIntention( KtPackageDirective::class.java, "", "Move file to package-matching directory" ) { override fun isApplicableTo(element: KtPackageDirective): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt index db9c4cb18fc..6eecfbc639d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.refactoring.move.changePackage import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.psi.KtPackageDirective -public class PackageDirectoryMismatchInspection: IntentionBasedInspection( +class PackageDirectoryMismatchInspection: IntentionBasedInspection( listOf(IntentionBasedInspection.IntentionData(MoveFileToPackageMatchingDirectoryIntention()), IntentionBasedInspection.IntentionData(ChangePackageToMatchDirectoryIntention())), "Package directive doesn't match file location", KtPackageDirective::class.java diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt index 84b05aa54a8..57c2d44708c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtFile import java.util.ArrayList import java.util.HashMap -public class KotlinMoveDirectoryWithClassesHelper : MoveDirectoryWithClassesHelper() { +class KotlinMoveDirectoryWithClassesHelper : MoveDirectoryWithClassesHelper() { private class FileUsagesWrapper( val psiFile: PsiFile, val usages: List, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt index 03ce1a1169d..c048478dc4c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveFilesOrDirectoriesHandler.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.idea.refactoring.move.* import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile -public class KotlinMoveFilesOrDirectoriesHandler : MoveFilesOrDirectoriesHandler() { +class KotlinMoveFilesOrDirectoriesHandler : MoveFilesOrDirectoriesHandler() { private fun adjustElements(elements: Array): Array? { return elements.map { when { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt index f5ccd967707..d536b574bda 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.* -public class MoveKotlinFileHandler : MoveFileHandler() { +class MoveKotlinFileHandler : MoveFileHandler() { internal class InternalUsagesWrapper(file: KtFile, val usages: List) : UsageInfo(file) // This is special 'PsiElement' whose purpose is to wrap MoveKotlinTopLevelDeclarationsProcessor diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt index 35e7e048ea8..89396c5b239 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/KotlinMoveTarget.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile import java.util.HashMap -public interface KotlinMoveTarget { +interface KotlinMoveTarget { val packageWrapper: PackageWrapper? fun getOrCreateTargetPsi(originalPsi: PsiElement): PsiFile? fun getTargetPsiIfExists(originalPsi: PsiElement): PsiFile? @@ -34,14 +34,14 @@ public interface KotlinMoveTarget { fun verify(file: PsiFile): String? } -public object EmptyKotlinMoveTarget: KotlinMoveTarget { +object EmptyKotlinMoveTarget: KotlinMoveTarget { override val packageWrapper: PackageWrapper? get() = null override fun getOrCreateTargetPsi(originalPsi: PsiElement) = null override fun getTargetPsiIfExists(originalPsi: PsiElement) = null override fun verify(file: PsiFile) = null } -public class KotlinMoveTargetForExistingFile(val targetFile: KtFile): KotlinMoveTarget { +class KotlinMoveTargetForExistingFile(val targetFile: KtFile): KotlinMoveTarget { override val packageWrapper: PackageWrapper? = targetFile.packageFqName.asString().let { packageName -> PackageWrapper(PsiManager.getInstance(targetFile.project), packageName) } @@ -54,7 +54,7 @@ public class KotlinMoveTargetForExistingFile(val targetFile: KtFile): KotlinMove override fun verify(file: PsiFile): String? = null } -public class KotlinMoveTargetForDeferredFile( +class KotlinMoveTargetForDeferredFile( project: Project, private val packageFqName: FqName, private val createFile: (KtFile) -> KtFile?): KotlinMoveTarget { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt index 03ea0745af0..9958f59a0ef 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveDeclarationToSeparateFileIntention.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class MoveDeclarationToSeparateFileIntention : +class MoveDeclarationToSeparateFileIntention : SelfTargetingRangeIntention(KtClassOrObject::class.java, "Move declaration to separate file"), LowPriorityAction { override fun applicabilityRange(element: KtClassOrObject): TextRange? { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt index 9e532464bca..715b563c121 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsHandler.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.Mo import org.jetbrains.kotlin.psi.* import java.util.* -public class MoveKotlinTopLevelDeclarationsHandler : MoveHandlerDelegate() { +class MoveKotlinTopLevelDeclarationsHandler : MoveHandlerDelegate() { private fun getSourceDirectories(elements: Array) = elements.mapTo(LinkedHashSet()) { it.containingFile?.parent } private fun doMoveWithCheck( diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt index 6e289d711fe..75006cf8981 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt @@ -77,7 +77,7 @@ interface Mover: (KtNamedDeclaration, KtFile) -> KtNamedDeclaration { } } -public class MoveKotlinTopLevelDeclarationsOptions( +class MoveKotlinTopLevelDeclarationsOptions( val elementsToMove: Collection, val moveTarget: KotlinMoveTarget, val searchInCommentsAndStrings: Boolean = true, @@ -87,7 +87,7 @@ public class MoveKotlinTopLevelDeclarationsOptions( val moveCallback: MoveCallback? = null ) -public class MoveKotlinTopLevelDeclarationsProcessor( +class MoveKotlinTopLevelDeclarationsProcessor( val project: Project, val options: MoveKotlinTopLevelDeclarationsOptions, val mover: Mover = Mover.Default) : BaseRefactoringProcessor(project) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt index 7d5bc39175f..cb95542d333 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt @@ -53,7 +53,7 @@ import java.io.File import javax.swing.JComponent import javax.swing.event.DocumentEvent -public class KotlinAwareMoveFilesOrDirectoriesDialog( +class KotlinAwareMoveFilesOrDirectoriesDialog( private val project: Project, private val callback: (KotlinAwareMoveFilesOrDirectoriesDialog?) -> Unit ) : DialogWrapper(project, true) { @@ -76,7 +76,7 @@ public class KotlinAwareMoveFilesOrDirectoriesDialog( init() } - public val updatePackageDirective: Boolean + val updatePackageDirective: Boolean get() = updatePackageDirectiveCb.isSelected override fun createActions() = arrayOf(okAction, cancelAction, helpAction) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt index 70d81b994c5..2b6b3988850 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt @@ -66,7 +66,7 @@ import java.util.* val UNKNOWN_PACKAGE_FQ_NAME = FqNameUnsafe("org.jetbrains.kotlin.idea.refactoring.move.") -public class PackageNameInfo(val oldPackageName: FqName, val newPackageName: FqNameUnsafe) +class PackageNameInfo(val oldPackageName: FqName, val newPackageName: FqNameUnsafe) fun KtElement.getInternalReferencesToUpdateOnPackageNameChange(packageNameInfo: PackageNameInfo): List { val usages = ArrayList() @@ -198,7 +198,7 @@ private fun isUnqualifiedExtensionReference(reference: PsiReference, referencedE && reference.element.getNonStrictParentOfType() == null } -public fun guessNewFileName(declarationsToMove: Collection): String? { +fun guessNewFileName(declarationsToMove: Collection): String? { if (declarationsToMove.isEmpty()) return null val representative = declarationsToMove.singleOrNull() @@ -314,7 +314,7 @@ fun postProcessMoveUsages(usages: List, var KtFile.updatePackageDirective: Boolean? by UserDataProperty(Key.create("UPDATE_PACKAGE_DIRECTIVE")) // Mostly copied from MoveFilesOrDirectoriesUtil.doMove() -public fun moveFilesOrDirectories( +fun moveFilesOrDirectories( project: Project, elements: Array, targetElement: PsiElement?, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPostconversionPullUpHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPostconversionPullUpHelper.kt index e0cf7e7ed31..abc772ce7c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPostconversionPullUpHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPostconversionPullUpHelper.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression import java.util.LinkedHashSet -public class JavaToKotlinPostconversionPullUpHelper(private val data: PullUpData) : PullUpHelper { +class JavaToKotlinPostconversionPullUpHelper(private val data: PullUpData) : PullUpHelper { override fun setCorrectVisibility(info: MemberInfo?) { } override fun encodeContextInfo(info: MemberInfo?) { } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt index 1367b68bc20..e2f08a46cae 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/JavaToKotlinPreconversionPullUpHelper.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi.* import java.util.* -public class JavaToKotlinPreconversionPullUpHelper( +class JavaToKotlinPreconversionPullUpHelper( private val data: PullUpData, private val dummyTargetClass: PsiClass, private val javaHelper: JavaPullUpHelper diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt index ff398f9c15b..bd4d02be2a2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpDialog.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.idea.refactoring.isInterfaceClass import org.jetbrains.kotlin.idea.refactoring.memberInfo.* import org.jetbrains.kotlin.psi.* -public class KotlinPullUpDialog( +class KotlinPullUpDialog( project: Project, private val classOrObject: KtClassOrObject, superClasses: List, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt index eb48ac11869..261234c720f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHandler.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.types.typeUtil.supertypes -public class KotlinPullUpHandler : AbstractPullPushMembersHandler( +class KotlinPullUpHandler : AbstractPullPushMembersHandler( refactoringName = PULL_MEMBERS_UP, helpId = HelpID.MEMBERS_PULL_UP, wrongPositionMessage = RefactoringBundle.message("the.caret.should.be.positioned.inside.a.class.to.pull.members.from") diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt index 35cbf166723..cd254469c60 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/KotlinPullUpHelperFactory.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.psi.psiUtil.startOffset -public class KotlinPullUpHelperFactory : PullUpHelperFactory { +class KotlinPullUpHelperFactory : PullUpHelperFactory { private fun PullUpData.toKotlinPullUpData(): KotlinPullUpData? { val sourceClass = sourceClass.unwrapped as? KtClassOrObject ?: return null val targetClass = targetClass.unwrapped as? PsiNamedElement ?: return null @@ -55,7 +55,7 @@ public class KotlinPullUpHelperFactory : PullUpHelperFactory { } } -public class JavaToKotlinPullUpHelperFactory : PullUpHelperFactory { +class JavaToKotlinPullUpHelperFactory : PullUpHelperFactory { private fun createJavaToKotlinPullUpHelper(data: PullUpData): JavaToKotlinPreconversionPullUpHelper? { if (!data.sourceClass.isInheritor(data.targetClass, true)) return null val dummyTargetClass = createDummyTargetClass(data) ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt index b091d061e82..f1ff8655716 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownDialog.kt @@ -37,7 +37,7 @@ import javax.swing.JComponent import javax.swing.JLabel import javax.swing.JPanel -public class KotlinPushDownDialog( +class KotlinPushDownDialog( project: Project, private val memberInfos: List, private val sourceClass: KtClass @@ -49,7 +49,7 @@ public class KotlinPushDownDialog( private var memberInfoModel: AbstractMemberInfoModel? = null - public val selectedMemberInfos: List + val selectedMemberInfos: List get() = memberInfos.filter { it.isChecked && memberInfoModel?.isMemberEnabled(it) ?: false } override fun getDimensionServiceKey() = "#" + javaClass.name diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt index 7b562d31fa4..5b031b24529 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownHandler.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.psiUtil.isInheritable val PUSH_MEMBERS_DOWN = "Push Members Down" -public class KotlinPushDownHandler : AbstractPullPushMembersHandler( +class KotlinPushDownHandler : AbstractPullPushMembersHandler( refactoringName = PUSH_MEMBERS_DOWN, helpId = HelpID.MEMBERS_PUSH_DOWN, wrongPositionMessage = RefactoringBundle.message("the.caret.should.be.positioned.inside.a.class.to.push.members.from") diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt index 5adaab63bd9..e7ed1150d33 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pushDown/KotlinPushDownProcessor.kt @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.util.findCallableMemberBySignature import org.jetbrains.kotlin.utils.keysToMap import java.util.ArrayList -public class KotlinPushDownContext( +class KotlinPushDownContext( val sourceClass: KtClass, val membersToMove: List ) { @@ -64,7 +64,7 @@ public class KotlinPushDownContext( .keysToMap { sourceClassContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it]!! } } -public class KotlinPushDownProcessor( +class KotlinPushDownProcessor( project: Project, sourceClass: KtClass, membersToMove: List diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt index 909342b43fe..ace1e4a75c4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticInheritorRenamer.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.asJava.LightClassUtil import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.psi.KtClass -public class AutomaticInheritorRenamer(klass: KtClass, newName: String): AutomaticRenamer() { +class AutomaticInheritorRenamer(klass: KtClass, newName: String): AutomaticRenamer() { init { val lightClass = LightClassUtil.getPsiClass(klass) if (lightClass != null) { @@ -47,7 +47,7 @@ public class AutomaticInheritorRenamer(klass: KtClass, newName: String): Automat override fun entityName() = RefactoringBundle.message("entity.name.inheritor") } -public class AutomaticInheritorRenamerFactory : AutomaticRenamerFactory { +class AutomaticInheritorRenamerFactory : AutomaticRenamerFactory { override fun isApplicable(element: PsiElement) = element is KtClass override fun getOptionName() = RefactoringBundle.message("rename.inheritors") override fun isEnabled() = JavaRefactoringSettings.getInstance().isToRenameInheritors diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt index 7ad9cf0eccc..783ecd4e3e0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticOverloadsRenamer.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtClassBody import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtNamedFunction -public class AutomaticOverloadsRenamer(function: KtNamedFunction, newName: String) : AutomaticRenamer() { +class AutomaticOverloadsRenamer(function: KtNamedFunction, newName: String) : AutomaticRenamer() { init { myElements.addAll(function.getOverloads().filter { it != function }) suggestAllNames(function.name, newName) @@ -61,7 +61,7 @@ private fun KtNamedFunction.getOverloads(): Collection { return emptyList() } -public class AutomaticOverloadsRenamerFactory : AutomaticRenamerFactory { +class AutomaticOverloadsRenamerFactory : AutomaticRenamerFactory { override fun isApplicable(element: PsiElement): Boolean { return element is KtNamedFunction && element.name != null && (element.parent is KtFile || element.parent is KtClassBody) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt index 3cb143aa798..4d508969ffc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.types.KotlinType import java.util.* -public class AutomaticVariableRenamer( +class AutomaticVariableRenamer( klass: PsiNamedElement, // PsiClass or JetClass newClassName: String, usages: Collection @@ -116,7 +116,7 @@ private fun KotlinType.isCollectionLikeOf(classPsiElement: PsiNamedElement): Boo } -public class AutomaticVariableRenamerFactory: AutomaticRenamerFactory { +class AutomaticVariableRenamerFactory: AutomaticRenamerFactory { override fun isApplicable(element: PsiElement) = element is KtClass || element is PsiClass override fun createRenamer(element: PsiElement, newName: String, usages: Collection) = @@ -128,7 +128,7 @@ public class AutomaticVariableRenamerFactory: AutomaticRenamerFactory { override fun getOptionName() = RefactoringBundle.message("rename.variables") } -public class AutomaticVariableInJavaRenamerFactory: AutomaticRenamerFactory { +class AutomaticVariableInJavaRenamerFactory: AutomaticRenamerFactory { override fun isApplicable(element: PsiElement) = element is KtClass && element.toLightClass() != null override fun createRenamer(element: PsiElement, newName: String, usages: Collection) = diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt index 52721b7f74e..0fdd925c1c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameDynamicMemberHandler.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic -public class RenameDynamicMemberHandler: VariableInplaceRenameHandler() { +class RenameDynamicMemberHandler: VariableInplaceRenameHandler() { override fun isAvailable(element: PsiElement?, editor: Editor, file: PsiFile): Boolean { val callee = PsiTreeUtil.findElementOfClassAtOffset( file, editor.caretModel.offset, KtSimpleNameExpression::class.java, false diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinClassProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinClassProcessor.kt index eb0a58ed940..03166f9bce7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinClassProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinClassProcessor.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class RenameKotlinClassProcessor : RenameKotlinPsiProcessor() { +class RenameKotlinClassProcessor : RenameKotlinPsiProcessor() { override fun canProcessElement(element: PsiElement): Boolean { return element is KtClassOrObject || element is KtLightClass || element is KtConstructor<*> } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt index a06b5136449..fbe6f611716 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinFunctionProcessor.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.KtSecondaryConstructor -public class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() { +class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() { private val javaMethodProcessorInstance = RenameJavaMethodProcessor() override fun canProcessElement(element: PsiElement): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt index a1f76c9b1e8..22275f307bf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinImplicitLambdaParameter.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.intentions.isAutoCreatedItUsage import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.KtNameReferenceExpression -public class RenameKotlinImplicitLambdaParameter: VariableInplaceRenameHandler() { +class RenameKotlinImplicitLambdaParameter: VariableInplaceRenameHandler() { override fun isAvailable(element: PsiElement?, editor: Editor, file: PsiFile): Boolean { val nameExpression = PsiTreeUtil.findElementOfClassAtOffset( file, editor.caretModel.offset, KtNameReferenceExpression::class.java, false) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt index 0811e77ee8e..556b803c5b8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinParameterProcessor.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.OverrideResolver -public class RenameKotlinParameterProcessor : RenameKotlinPsiProcessor() { +class RenameKotlinParameterProcessor : RenameKotlinPsiProcessor() { override fun canProcessElement(element: PsiElement): Boolean { return element is KtParameter && element.parent.parent is KtNamedFunction } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt index b6a2d09bd59..83f522d56a5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.OverrideResolver -public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() { +class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() { override fun canProcessElement(element: PsiElement): Boolean { val namedUnwrappedElement = element.namedUnwrappedElement return namedUnwrappedElement is KtProperty || (namedUnwrappedElement is KtParameter && namedUnwrappedElement.hasValOrVar()) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt index 0c1affa7880..23b5257fc88 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameOnSecondaryConstructorHandler.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.KtSecondaryConstructor import org.jetbrains.kotlin.psi.KtValueArgumentList -public class RenameOnSecondaryConstructorHandler : RenameHandler { +class RenameOnSecondaryConstructorHandler : RenameHandler { override fun isAvailableOnDataContext(dataContext: DataContext?): Boolean { if (dataContext == null) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt index b50e8baf1ca..ff9d74d56f3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinJavaSafeDeleteDelegate.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parameterIndex import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.idea.caches.resolve.analyze -public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate { +class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate { override fun createUsageInfoForParameter( reference: PsiReference, usages: MutableList, parameter: PsiParameter, method: PsiMethod ) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt index 7ff10efc0d4..2872cf18094 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverrideAnnotation.kt @@ -20,10 +20,10 @@ import com.intellij.psi.PsiElement import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteCustomUsageInfo import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteUsageInfo -public class KotlinSafeDeleteOverrideAnnotation( +class KotlinSafeDeleteOverrideAnnotation( element: PsiElement, referencedElement: PsiElement ) : SafeDeleteUsageInfo(element, referencedElement), SafeDeleteCustomUsageInfo { - public override fun performRefactoring() { + override fun performRefactoring() { element?.removeOverrideModifier() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt index 880a7322a28..c56feb8004a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteOverridingUsageInfo.kt @@ -21,12 +21,12 @@ import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteCustomUsageInfo import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteUsageInfo import org.jetbrains.kotlin.psi.KtPsiUtil -public class KotlinSafeDeleteOverridingUsageInfo( +class KotlinSafeDeleteOverridingUsageInfo( overridingElement: PsiElement, superElement: PsiElement ) : SafeDeleteUsageInfo(overridingElement, superElement), SafeDeleteCustomUsageInfo { - public val overridingElement: PsiElement get() = element!! + val overridingElement: PsiElement get() = element!! - public override fun performRefactoring(): Unit { + override fun performRefactoring(): Unit { KtPsiUtil.ascendIfPropertyAccessor(element)?.delete() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt index ec07cfa463a..9dd6fe1f81c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.utils.ifEmpty import java.util.* -public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() { +class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() { override fun handlesElement(element: PsiElement): Boolean = element.canDeleteElement() override fun findUsages( diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteImportDirectiveUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteImportDirectiveUsageInfo.kt index 174c6ff7e5b..c56191a103d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteImportDirectiveUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteImportDirectiveUsageInfo.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.core.targetDescriptors import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtImportDirective -public class SafeDeleteImportDirectiveUsageInfo( +class SafeDeleteImportDirectiveUsageInfo( importDirective: KtImportDirective, declaration: KtDeclaration ) : SafeDeleteReferenceSimpleDeleteUsageInfo(importDirective, declaration, importDirective.isSafeToDelete(declaration)) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt index e127fa01548..394619535dc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteTypeArgumentListUsageInfo.kt @@ -20,10 +20,10 @@ import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDe import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.idea.core.deleteElementAndCleanParent -public class SafeDeleteTypeArgumentListUsageInfo( +class SafeDeleteTypeArgumentListUsageInfo( typeProjection: KtTypeProjection, parameter: KtTypeParameter ) : SafeDeleteReferenceSimpleDeleteUsageInfo(typeProjection, parameter, true) { - public override fun deleteElement() { + override fun deleteElement() { element?.deleteElementAndCleanParent() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt index 3b93b603052..ebdef31fb45 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/SafeDeleteValueArgumentListUsageInfo.kt @@ -21,10 +21,10 @@ import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDe import org.jetbrains.kotlin.psi.KtValueArgument import org.jetbrains.kotlin.psi.KtValueArgumentList -public class SafeDeleteValueArgumentListUsageInfo( +class SafeDeleteValueArgumentListUsageInfo( valueArgument: KtValueArgument, parameter: PsiElement ) : SafeDeleteReferenceSimpleDeleteUsageInfo(valueArgument, parameter, true) { - public override fun deleteElement() { + override fun deleteElement() { val element = element as? KtValueArgument ?: return val parent = element.parent if (parent is KtValueArgumentList) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt index 4e56dba29be..1312aa8700a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -public fun PsiElement.canDeleteElement(): Boolean { +fun PsiElement.canDeleteElement(): Boolean { if (this is KtObjectDeclaration && isObjectLiteral()) return false if (this is KtParameter) { diff --git a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt index 86a9724f0e3..fa5f70b5006 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt @@ -37,19 +37,19 @@ import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -public class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer(JUnitConfigurationType.getInstance()) { +class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer(JUnitConfigurationType.getInstance()) { override fun isConfigurationFromContext(configuration: JUnitConfiguration, context: ConfigurationContext): Boolean { if (RunConfigurationProducer.getInstance(PatternConfigurationProducer::class.java).isMultipleElementsSelected(context)) { return false } - val leaf = context.getLocation()?.getPsiElement() ?: return false + val leaf = context.location?.psiElement ?: return false val methodLocation = getTestMethodLocation(leaf) val testClass = getTestClass(leaf) - val testObject = configuration.getTestObject() + val testObject = configuration.testObject - if (!testObject.isConfiguredByElement(configuration, testClass, methodLocation?.getPsiElement(), null, null)) { + if (!testObject.isConfiguredByElement(configuration, testClass, methodLocation?.psiElement, null, null)) { return false } @@ -60,32 +60,32 @@ public class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer).getConfigurationModule().getModule() - val configurationModule = configuration.getConfigurationModule().getModule() - return configurationModule == context.getLocation()?.getModule() || configurationModule == predefinedModule + val template = RunManager.getInstance(configuration.project).getConfigurationTemplate(configurationFactory) + val predefinedModule = (template.configuration as ModuleBasedConfiguration<*>).configurationModule.module + val configurationModule = configuration.configurationModule.module + return configurationModule == context.location?.module || configurationModule == predefinedModule } override fun setupConfigurationFromContext(configuration: JUnitConfiguration, context: ConfigurationContext, sourceElement: Ref): Boolean { - if (DumbService.getInstance(context.getProject()).isDumb()) return false + if (DumbService.getInstance(context.project).isDumb) return false - val location = context.getLocation() ?: return false - val leaf = location.getPsiElement() + val location = context.location ?: return false + val leaf = location.psiElement if (!ProjectRootsUtil.isInProjectOrLibSource(leaf)) { return false } - if (leaf.getContainingFile() !is KtFile) { + if (leaf.containingFile !is KtFile) { return false } - val jetFile = leaf.getContainingFile() as KtFile + val jetFile = leaf.containingFile as KtFile if (ProjectStructureUtil.isJsKotlinModule(jetFile)) { return false @@ -93,7 +93,7 @@ public class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer(false) if (!jetClass.isJUnitTestClass()) { jetClass = getTestClassInFile(containingFile) @@ -163,5 +163,5 @@ public class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer().singleOrNull { it.isJUnitTestClass() } + jetFile.declarations.filterIsInstance().singleOrNull { it.isJUnitTestClass() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt index 6860b47c836..e06c86af257 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt @@ -34,13 +34,13 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -public class KotlinRunConfigurationProducer : RunConfigurationProducer(JetRunConfigurationType.getInstance()) { +class KotlinRunConfigurationProducer : RunConfigurationProducer(JetRunConfigurationType.getInstance()) { override fun setupConfigurationFromContext(configuration: JetRunConfiguration, context: ConfigurationContext, sourceElement: Ref): Boolean { - val location = context.getLocation() ?: return false - val module = location.getModule() ?: return false + val location = context.location ?: return false + val module = location.module ?: return false val container = getEntryPointContainer(location) val startClassFQName = getStartClassFqName(container) ?: return false @@ -50,13 +50,13 @@ public class KotlinRunConfigurationProducer : RunConfigurationProducer?): KtDeclarationContainer? { if (location == null) return null - if (DumbService.getInstance(location.getProject()).isDumb()) return null + if (DumbService.getInstance(location.project).isDumb) return null - val module = location.getModule() ?: return null + val module = location.module ?: return null if (ProjectStructureUtil.isJsKotlinModule(module)) return null - val locationElement = location.getPsiElement() + val locationElement = location.psiElement return getEntryPointContainer(locationElement) } @@ -65,20 +65,20 @@ public class KotlinRunConfigurationProducer : RunConfigurationProducer null is KtFile -> container.javaFileFacadeFqName is KtClassOrObject -> { if (container is KtObjectDeclaration && container.isCompanion()) { val containerClass = container.getParentOfType(true) - containerClass?.getFqName() + containerClass?.fqName } else { - container.getFqName() + container.fqName } } - else -> throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement).getText()) + else -> throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement).text) } private fun PsiElement.declarationContainer(strict: Boolean): KtDeclarationContainer? { diff --git a/idea/src/org/jetbrains/kotlin/idea/run/script/standalone/KotlinStandaloneScriptRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/script/standalone/KotlinStandaloneScriptRunConfigurationProducer.kt index 54f33214a9b..a0acf49cf62 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/script/standalone/KotlinStandaloneScriptRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/script/standalone/KotlinStandaloneScriptRunConfigurationProducer.kt @@ -23,7 +23,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -public class KotlinStandaloneScriptRunConfigurationProducer : +class KotlinStandaloneScriptRunConfigurationProducer : RunConfigurationProducer(KotlinStandaloneScriptRunConfigurationType.instance) { override fun setupConfigurationFromContext( configuration: KotlinStandaloneScriptRunConfiguration, diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinAnnotatedElementsSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinAnnotatedElementsSearcher.kt index 618a97372fa..1b34707c9e5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinAnnotatedElementsSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinAnnotatedElementsSearcher.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class KotlinAnnotatedElementsSearcher : QueryExecutor { +class KotlinAnnotatedElementsSearcher : QueryExecutor { override fun execute(p: AnnotatedElementsSearch.Parameters, consumer: Processor): Boolean { return processAnnotatedMembers(p.annotationClass, p.scope) { declaration -> @@ -60,13 +60,13 @@ public class KotlinAnnotatedElementsSearcher : QueryExecutor Boolean = { true }, consumer: (KtDeclaration) -> Boolean): Boolean { - assert(annClass.isAnnotationType()) { "Annotation type should be passed to annotated members search" } + assert(annClass.isAnnotationType) { "Annotation type should be passed to annotated members search" } - val annotationFQN = annClass.getQualifiedName() + val annotationFQN = annClass.qualifiedName assert(annotationFQN != null) val candidates = getKotlinAnnotationCandidates(annClass, useScope) @@ -82,7 +82,7 @@ public class KotlinAnnotatedElementsSearcher : QueryExecutor { return runReadAction(fun(): Collection { if (useScope is GlobalSearchScope) { - val name = annClass.getName() ?: return emptyList() - return KotlinAnnotationsIndex.getInstance().get(name, annClass.getProject(), useScope) + val name = annClass.name ?: return emptyList() + return KotlinAnnotationsIndex.getInstance().get(name, annClass.project, useScope) } return (useScope as LocalSearchScope).scope.flatMap { it.collectDescendantsOfType() } @@ -112,7 +112,7 @@ public class KotlinAnnotatedElementsSearcher : QueryExecutor(true) { +class KotlinConstructorDelegationCallReferenceSearcher() : QueryExecutorBase(true) { override fun processQuery(queryParameters: SearchParameters, consumer: Processor) { val method = queryParameters.method if (!method.isConstructor) return method.processDelegationCallConstructorUsages(method.useScope.intersectWith(queryParameters.effectiveSearchScope)) { - it.calleeExpression?.getReference()?.let { consumer.process(it) } ?: true + it.calleeExpression?.reference?.let { consumer.process(it) } ?: true } } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinDirectInheritorsSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinDirectInheritorsSearcher.kt index f168a098108..01df1f785ab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinDirectInheritorsSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinDirectInheritorsSearcher.kt @@ -28,25 +28,25 @@ import org.jetbrains.kotlin.idea.search.fileScope import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope import org.jetbrains.kotlin.idea.util.application.runReadAction -public open class KotlinDirectInheritorsSearcher() : QueryExecutorBase(true) { - public override fun processQuery(queryParameters: DirectClassInheritorsSearch.SearchParameters, consumer: Processor) { - val baseClass = queryParameters.getClassToProcess() +open class KotlinDirectInheritorsSearcher() : QueryExecutorBase(true) { + override fun processQuery(queryParameters: DirectClassInheritorsSearch.SearchParameters, consumer: Processor) { + val baseClass = queryParameters.classToProcess if (baseClass == null) return - val name = baseClass.getName() + val name = baseClass.name if (name == null) return - val originalScope = queryParameters.getScope() + val originalScope = queryParameters.scope val scope = if (originalScope is GlobalSearchScope) originalScope else - baseClass.getContainingFile()?.let { file -> file.fileScope() } + baseClass.containingFile?.let { file -> file.fileScope() } if (scope == null) return runReadAction { - val noLibrarySourceScope = KotlinSourceFilterScope.sourceAndClassFiles(scope, baseClass.getProject()) - KotlinSuperClassIndex.getInstance().get(name, baseClass.getProject(), noLibrarySourceScope).asSequence() + val noLibrarySourceScope = KotlinSourceFilterScope.sourceAndClassFiles(scope, baseClass.project) + KotlinSuperClassIndex.getInstance().get(name, baseClass.project, noLibrarySourceScope).asSequence() .mapNotNull { candidate -> SourceNavigationHelper.getOriginalPsiClassOrCreateLightClass(candidate)} .filter { candidate -> candidate.isInheritor(baseClass, false) } .forEach { candidate -> consumer.process(candidate) } diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt index 5c6455520fa..71c3b34304e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.utils.ifEmpty -public class KotlinOverridingMethodReferenceSearcher : MethodUsagesSearcher() { +class KotlinOverridingMethodReferenceSearcher : MethodUsagesSearcher() { override fun processQuery(p: MethodReferencesSearch.SearchParameters, consumer: Processor) { super.processQuery(p, consumer) diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodsWithGenericsSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodsWithGenericsSearcher.kt index 638c1def41d..5a04c84782f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodsWithGenericsSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodsWithGenericsSearcher.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtCallableDeclaration import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.OverrideResolver -public class KotlinOverridingMethodsWithGenericsSearcher : QueryExecutor { +class KotlinOverridingMethodsWithGenericsSearcher : QueryExecutor { override fun execute(p: OverridingMethodsSearch.SearchParameters, consumer: Processor): Boolean { val method = p.method if (method !is KtLightMethod) return true diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt index a135a311a6e..36303c03c4e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt @@ -31,14 +31,14 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.synthetic.JavaSyntheticPropertiesScope import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor -public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase(true) { +class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase(true) { override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor) { - val method = queryParameters.getMethod() + val method = queryParameters.method val propertyName = propertyName(method) ?: return - val onlyKotlinFiles = queryParameters.getEffectiveSearchScope().restrictToKotlinSources() + val onlyKotlinFiles = queryParameters.effectiveSearchScope.restrictToKotlinSources() - queryParameters.getOptimizer()!!.searchWord( + queryParameters.optimizer!!.searchWord( propertyName, onlyKotlinFiles, UsageSearchContext.IN_CODE, @@ -55,6 +55,6 @@ public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase()?.getTextOffset() == offset + return file.findElementAt(offset)?.getNonStrictParentOfType()?.textOffset == offset } } diff --git a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestDialog.kt b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestDialog.kt index 9c5ffed9bf9..395a88d4582 100644 --- a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestDialog.kt @@ -27,7 +27,7 @@ class KotlinCreateTestDialog(project: Project, targetClass: PsiClass?, targetPackage: PsiPackage?, targetModule: Module) : CreateTestDialog(project, title, targetClass, targetPackage, targetModule) { - public var explicitClassName: String? = null + var explicitClassName: String? = null override fun getClassName() = explicitClassName ?: super.getClassName() } diff --git a/idea/src/org/jetbrains/kotlin/idea/testIntegration/testIntegrationUtils.kt b/idea/src/org/jetbrains/kotlin/idea/testIntegration/testIntegrationUtils.kt index b15b48b2fba..1752a34f371 100644 --- a/idea/src/org/jetbrains/kotlin/idea/testIntegration/testIntegrationUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/testIntegration/testIntegrationUtils.kt @@ -23,7 +23,7 @@ import com.intellij.util.SmartList import org.jetbrains.kotlin.asJava.toLightClass import org.jetbrains.kotlin.psi.KtClassOrObject -public fun findSuitableFrameworks(klass: KtClassOrObject): List { +fun findSuitableFrameworks(klass: KtClassOrObject): List { val lightClass = klass.toLightClass() ?: return emptyList() val frameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME).filter { it.language == JavaLanguage.INSTANCE } return frameworks.firstOrNull { it.isTestClass(lightClass) }?.let { listOf(it) } diff --git a/idea/src/org/jetbrains/kotlin/idea/util/DialogWithEditor.kt b/idea/src/org/jetbrains/kotlin/idea/util/DialogWithEditor.kt index 324f1ae249b..3a09fc9205c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/DialogWithEditor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/DialogWithEditor.kt @@ -30,7 +30,7 @@ import com.intellij.openapi.editor.colors.* import java.awt.event.* import com.intellij.psi.* -public open class DialogWithEditor( +open class DialogWithEditor( val project: Project, title: String, val initialText: String @@ -48,31 +48,31 @@ public open class DialogWithEditor( val document = FileDocumentManager.getInstance().getDocument(virtualFile)!! val editor = editorFactory.createEditor(document, project, KotlinFileType.INSTANCE, false) - val settings = editor.getSettings() - settings.setVirtualSpace(false) - settings.setLineMarkerAreaShown(false) - settings.setFoldingOutlineShown(false) - settings.setRightMarginShown(false) - settings.setAdditionalPageAtBottom(false) - settings.setAdditionalLinesCount(2) - settings.setAdditionalColumnsCount(12) + val settings = editor.settings + settings.isVirtualSpace = false + settings.isLineMarkerAreaShown = false + settings.isFoldingOutlineShown = false + settings.isRightMarginShown = false + settings.isAdditionalPageAtBottom = false + settings.additionalLinesCount = 2 + settings.additionalColumnsCount = 12 assert(editor is EditorEx) - (editor as EditorEx).setEmbeddedIntoDialogWrapper(true) + (editor as EditorEx).isEmbeddedIntoDialogWrapper = true - editor.getColorsScheme().setColor(EditorColors.CARET_ROW_COLOR, editor.getColorsScheme().getDefaultBackground()) + editor.getColorsScheme().setColor(EditorColors.CARET_ROW_COLOR, editor.getColorsScheme().defaultBackground) return editor } override fun createCenterPanel(): JComponent { val panel = JPanel(BorderLayout()) - panel.add(editor.getComponent(), BorderLayout.CENTER) + panel.add(editor.component, BorderLayout.CENTER) return panel } override fun getPreferredFocusedComponent(): JComponent { - return editor.getContentComponent() + return editor.contentComponent } override fun dispose() { diff --git a/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt b/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt index ccb28598b95..e9cf99e0a96 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.findVariable import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* -public class ImportInsertHelperImpl(private val project: Project) : ImportInsertHelper() { +class ImportInsertHelperImpl(private val project: Project) : ImportInsertHelper() { private val codeStyleSettings: KotlinCodeStyleSettings get() = KotlinCodeStyleSettings.getInstance(project) @@ -75,7 +75,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert } private fun isJavaOrKotlinStdlibImport(path: ImportPath): Boolean { - val s = path.getPathStr() + val s = path.pathStr return s.startsWith("java.") || s.startsWith("javax.")|| s.startsWith("kotlin.") } } @@ -91,11 +91,11 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert is PackageViewDescriptor -> false // now package cannot be imported is ClassDescriptor -> { - importable.getContainingDeclaration() is PackageFragmentDescriptor + importable.containingDeclaration is PackageFragmentDescriptor || codeStyleSettings.IMPORT_NESTED_CLASSES } - else -> importable.getContainingDeclaration() is PackageFragmentDescriptor // do not import members (e.g. java static members) + else -> importable.containingDeclaration is PackageFragmentDescriptor // do not import members (e.g. java static members) } } @@ -209,8 +209,8 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert if (containerFqName.asString() in codeStyleSettings.PACKAGES_TO_USE_STAR_IMPORTS) return true val importsFromPackage = imports.count { - val path = it.getImportPath() - path != null && !path.isAllUnder() && !path.hasAlias() && path.fqnPart().parent() == containerFqName + val path = it.importPath + path != null && !path.isAllUnder && !path.hasAlias() && path.fqnPart().parent() == containerFqName } val nameCountToUseStar = if (target.containingDeclaration is ClassDescriptor) codeStyleSettings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS @@ -233,12 +233,12 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert val parentFqName = targetFqName.parent() val moduleDescriptor = resolutionFacade.moduleDescriptor - val imports = file.getImportDirectives() + val imports = file.importDirectives val scopeToImport = getMemberScope(parentFqName, moduleDescriptor) ?: return ImportDescriptorResult.FAIL val importedScopes = imports - .filter { it.isAllUnder () } + .filter { it.isAllUnder } .mapNotNull { - val importPath = it.getImportPath() + val importPath = it.importPath if (importPath != null) { val fqName = importPath.fqnPart() getMemberScope(fqName, moduleDescriptor) @@ -248,18 +248,18 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert } } - val filePackage = moduleDescriptor.getPackage(file.getPackageFqName()) + val filePackage = moduleDescriptor.getPackage(file.packageFqName) fun isVisible(descriptor: DeclarationDescriptor): Boolean { if (descriptor !is DeclarationDescriptorWithVisibility) return true - val visibility = descriptor.getVisibility() + val visibility = descriptor.visibility return !visibility.mustCheckInImports() || Visibilities.isVisibleWithIrrelevantReceiver(descriptor, filePackage) } val classNamesToImport = scopeToImport .getDescriptorsFiltered(DescriptorKindFilter.CLASSIFIERS, { true }) .filter(::isVisible) - .map { it.getName() } + .map { it.name } val topLevelScope = resolutionFacade.getFileResolutionScope(file) val conflictCandidates: List = classNamesToImport @@ -301,13 +301,13 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert val parentScope = getMemberScope(fqName.parent(), moduleDescriptor) ?: return null val classifier = parentScope.getContributedClassifier(fqName.shortName(), NoLookupLocation.FROM_IDE) val classDescriptor = classifier as? ClassDescriptor ?: return null - return classDescriptor.getDefaultType().getMemberScope() + return classDescriptor.defaultType.memberScope } private fun addExplicitImport(target: DeclarationDescriptor): ImportDescriptorResult { if (target is ClassDescriptor || target is PackageViewDescriptor) { val topLevelScope = resolutionFacade.getFileResolutionScope(file) - val name = target.getName() + val name = target.name // check if there is a conflicting class imported with * import // (not with explicit import - explicit imports are checked before this method invocation) @@ -322,8 +322,8 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert } private fun dropRedundantExplicitImports(packageFqName: FqName) { - val dropCandidates = file.getImportDirectives().filter { - !it.isAllUnder() && it.getAliasName() == null && it.getImportPath()?.fqnPart()?.parent() == packageFqName + val dropCandidates = file.importDirectives.filter { + !it.isAllUnder && it.aliasName == null && it.importPath?.fqnPart()?.parent() == packageFqName } val importsToCheck = ArrayList() @@ -350,7 +350,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert private fun detectNeededImports(importedClasses: Collection): Set { if (importedClasses.isEmpty()) return setOf() - val classesToCheck = importedClasses.map { it.getName() to it }.toMap().toLinkedMap() + val classesToCheck = importedClasses.map { it.name to it }.toMap().toLinkedMap() val result = LinkedHashSet() file.accept(object : KtVisitorVoid() { override fun visitElement(element: PsiElement) { @@ -398,14 +398,14 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert val psiFactory = KtPsiFactory(project) if (file is KtCodeFragment) { val newDirective = psiFactory.createImportDirective(importPath) - file.addImportsFromString(newDirective.getText()) + file.addImportsFromString(newDirective.text) return newDirective } - val importList = file.getImportList() + val importList = file.importList if (importList != null) { val newDirective = psiFactory.createImportDirective(importPath) - val imports = importList.getImports() + val imports = importList.imports if (imports.isEmpty()) { //TODO: strange hack importList.add(psiFactory.createNewLine()) return importList.add(newDirective) as KtImportDirective @@ -413,14 +413,14 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert else { val insertAfter = imports .lastOrNull { - val directivePath = it.getImportPath() + val directivePath = it.importPath directivePath != null && ImportPathComparator.compare(directivePath, importPath) <= 0 } return importList.addAfter(newDirective, insertAfter) as KtImportDirective } } else { - error("Trying to insert import $fqName into a file ${file.getName()} of type ${file.javaClass} with no import list.") + error("Trying to insert import $fqName into a file ${file.name} of type ${file.javaClass} with no import list.") } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/util/attachment/attachmentUtils.kt b/idea/src/org/jetbrains/kotlin/idea/util/attachment/attachmentUtils.kt index 6d071fe8678..951970540c9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/attachment/attachmentUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/attachment/attachmentUtils.kt @@ -20,7 +20,7 @@ import com.intellij.psi.PsiFile import com.intellij.openapi.diagnostic.Attachment import com.intellij.diagnostic.AttachmentFactory -public fun attachmentByPsiFileAsArray(file: PsiFile?): Array { +fun attachmentByPsiFileAsArray(file: PsiFile?): Array { val attachment = attachmentByPsiFile(file) if (attachment == null) { return arrayOf() @@ -28,27 +28,29 @@ public fun attachmentByPsiFileAsArray(file: PsiFile?): Array { return arrayOf(attachment) } -public fun attachmentByPsiFile(file: PsiFile?): Attachment? { +fun attachmentByPsiFile(file: PsiFile?): Attachment? { if (file == null) return null - val virtualFile = file.getVirtualFile() + val virtualFile = file.virtualFile if (virtualFile != null) return AttachmentFactory.createAttachment(virtualFile) - val text = try { file.getText() } catch(e: Exception) { null } - val name = try { file.getName() } catch(e: Exception) { null } + val text = try { file.text + } catch(e: Exception) { null } + val name = try { file.name + } catch(e: Exception) { null } if (text != null && name != null) return Attachment(name, text) return null } -public fun mergeAttachments(vararg attachments: Attachment?): Attachment { +fun mergeAttachments(vararg attachments: Attachment?): Attachment { val builder = StringBuilder() attachments.forEach { if (it != null) { - builder.append("\n----- START ${it.getPath()} -----\n") - builder.append(it.getDisplayText()) - builder.append("\n----- END ${it.getPath()} -----\n") + builder.append("\n----- START ${it.path} -----\n") + builder.append(it.displayText) + builder.append("\n----- END ${it.path} -----\n") } } diff --git a/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt b/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt index 58f436e0253..33b1c935ae5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt @@ -23,9 +23,9 @@ import java.io.File import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.roots.OrderRootType -public fun Module.findLibrary(predicate: (Library) -> Boolean): Library? = OrderEnumerator.orderEntries(this).findLibrary(predicate) +fun Module.findLibrary(predicate: (Library) -> Boolean): Library? = OrderEnumerator.orderEntries(this).findLibrary(predicate) -public fun OrderEnumerator.findLibrary(predicate: (Library) -> Boolean): Library? { +fun OrderEnumerator.findLibrary(predicate: (Library) -> Boolean): Library? { var lib: Library? = null forEachLibrary { library -> if (predicate(library!!)) { @@ -40,9 +40,9 @@ public fun OrderEnumerator.findLibrary(predicate: (Library) -> Boolean): Library return lib } -public fun Module.getModuleDir(): String = File(getModuleFilePath()).getParent()!!.replace(File.separatorChar, '/') +fun Module.getModuleDir(): String = File(moduleFilePath).parent!!.replace(File.separatorChar, '/') -public fun Library.ModifiableModel.replaceFileRoot(oldFile: File, newFile: File) { +fun Library.ModifiableModel.replaceFileRoot(oldFile: File, newFile: File) { val oldRoot = VfsUtil.getUrlForLibraryRoot(oldFile) val newRoot = VfsUtil.getUrlForLibraryRoot(newFile) diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt index df70865e10f..5a6fd311302 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt @@ -25,25 +25,25 @@ import org.jetbrains.kotlin.psi.KtTreeVisitorVoid import org.jetbrains.kotlin.psi.psiUtil.siblings import java.util.* -private val SIGNIFICANT_FILTER = { e: PsiElement -> e !is PsiWhiteSpace && e !is PsiComment && e.getTextLength() > 0 } +private val SIGNIFICANT_FILTER = { e: PsiElement -> e !is PsiWhiteSpace && e !is PsiComment && e.textLength > 0 } -public interface KotlinPsiRange { - public object Empty : KotlinPsiRange { +interface KotlinPsiRange { + object Empty : KotlinPsiRange { override val elements: List get() = Collections.emptyList() override fun getTextRange(): TextRange = TextRange.EMPTY_RANGE } - public class ListRange(override val elements: List): KotlinPsiRange { + class ListRange(override val elements: List): KotlinPsiRange { val startElement: PsiElement = elements.first() val endElement: PsiElement = elements.last() override fun getTextRange(): TextRange { - val startRange = startElement.getTextRange() - val endRange = endElement.getTextRange() + val startRange = startElement.textRange + val endRange = endElement.textRange if (startRange == null || endRange == null) return TextRange.EMPTY_RANGE - return TextRange(startRange.getStartOffset(), endRange.getEndOffset()) + return TextRange(startRange.startOffset, endRange.endOffset) } } @@ -51,11 +51,11 @@ public interface KotlinPsiRange { fun getTextRange(): TextRange - fun isValid(): Boolean = elements.all { it.isValid() } + fun isValid(): Boolean = elements.all { it.isValid } val empty: Boolean get() = this is Empty - operator fun contains(element: PsiElement): Boolean = getTextRange().contains(element.getTextRange() ?: TextRange.EMPTY_RANGE) + operator fun contains(element: PsiElement): Boolean = getTextRange().contains(element.textRange ?: TextRange.EMPTY_RANGE) fun match(scope: PsiElement, unifier: KotlinPsiUnifier): List { val elements = elements.filter(SIGNIFICANT_FILTER) @@ -91,8 +91,8 @@ public interface KotlinPsiRange { } } -public fun List.toRange(significantOnly: Boolean = true): KotlinPsiRange { +fun List.toRange(significantOnly: Boolean = true): KotlinPsiRange { return if (isEmpty()) KotlinPsiRange.Empty else KotlinPsiRange.ListRange(if (significantOnly) filter(SIGNIFICANT_FILTER) else this) } -public fun PsiElement?.toRange(): KotlinPsiRange = this?.let { KotlinPsiRange.ListRange(Collections.singletonList(it)) } ?: KotlinPsiRange.Empty +fun PsiElement?.toRange(): KotlinPsiRange = this?.let { KotlinPsiRange.ListRange(Collections.singletonList(it)) } ?: KotlinPsiRange.Empty diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt index 629e0318913..9230e105e92 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt @@ -52,8 +52,8 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.expressions.OperatorConventions import java.util.* -public interface UnificationResult { - public enum class Status { +interface UnificationResult { + enum class Status { MATCHED { override fun and(other: Status): Status = other }, @@ -62,7 +62,7 @@ public interface UnificationResult { override fun and(other: Status): Status = this }; - public abstract infix fun and(other: Status): Status + abstract infix fun and(other: Status): Status } object Unmatched : UnificationResult { @@ -90,12 +90,12 @@ public interface UnificationResult { val matched: Boolean get() = status != UNMATCHED } -public class UnifierParameter( +class UnifierParameter( val descriptor: DeclarationDescriptor, val expectedType: KotlinType ) -public class KotlinPsiUnifier( +class KotlinPsiUnifier( parameters: Collection = Collections.emptySet(), val allowWeakMatches: Boolean = false ) { @@ -117,7 +117,7 @@ public class KotlinPsiUnifier( private fun KotlinPsiRange.getBindingContext(): BindingContext { val element = (this as? KotlinPsiRange.ListRange)?.startElement as? KtElement - if ((element?.getContainingFile() as? KtFile)?.doNotAnalyze != null) return BindingContext.EMPTY + if ((element?.containingFile as? KtFile)?.doNotAnalyze != null) return BindingContext.EMPTY return element?.getContextForContainingDeclarationBody() ?: BindingContext.EMPTY } @@ -151,8 +151,8 @@ public class KotlinPsiUnifier( } private fun matchCalls(call1: Call, call2: Call): Boolean { - return matchReceivers(call1.getExplicitReceiver(), call2.getExplicitReceiver()) && - matchReceivers(call1.getDispatchReceiver(), call2.getDispatchReceiver()) + return matchReceivers(call1.explicitReceiver, call2.explicitReceiver) && + matchReceivers(call1.dispatchReceiver, call2.dispatchReceiver) } private fun matchArguments(arg1: ValueArgument, arg2: ValueArgument): Status { @@ -170,8 +170,8 @@ public class KotlinPsiUnifier( private fun matchResolvedCalls(rc1: ResolvedCall<*>, rc2: ResolvedCall<*>): Status? { fun checkSpecialOperations(): Boolean { - val op1 = (rc1.getCall().getCalleeExpression() as? KtSimpleNameExpression)?.getReferencedNameElementType() - val op2 = (rc2.getCall().getCalleeExpression() as? KtSimpleNameExpression)?.getReferencedNameElementType() + val op1 = (rc1.call.calleeExpression as? KtSimpleNameExpression)?.getReferencedNameElementType() + val op2 = (rc2.call.calleeExpression as? KtSimpleNameExpression)?.getReferencedNameElementType() return when { op1 == op2 -> @@ -188,17 +188,17 @@ public class KotlinPsiUnifier( } fun checkArguments(): Status? { - val args1 = rc1.getResultingDescriptor()?.getValueParameters()?.map { rc1.getValueArguments()[it] } ?: Collections.emptyList() - val args2 = rc2.getResultingDescriptor()?.getValueParameters()?.map { rc2.getValueArguments()[it] } ?: Collections.emptyList() + val args1 = rc1.resultingDescriptor?.valueParameters?.map { rc1.valueArguments[it] } ?: Collections.emptyList() + val args2 = rc2.resultingDescriptor?.valueParameters?.map { rc2.valueArguments[it] } ?: Collections.emptyList() if (args1.size != args2.size) return UNMATCHED - if (rc1.getCall().getValueArguments().size != args1.size || rc2.getCall().getValueArguments().size != args2.size) return null + if (rc1.call.valueArguments.size != args1.size || rc2.call.valueArguments.size != args2.size) return null return (args1.asSequence().zip(args2.asSequence())).fold(MATCHED) { s, p -> val (arg1, arg2) = p s and when { arg1 == arg2 -> MATCHED arg1 == null || arg2 == null -> UNMATCHED - else -> (arg1.getArguments().asSequence().zip(arg2.getArguments().asSequence())).fold(MATCHED) { s, p -> + else -> (arg1.arguments.asSequence().zip(arg2.arguments.asSequence())).fold(MATCHED) { s, p -> s and matchArguments(p.first, p.second) } } @@ -207,14 +207,14 @@ public class KotlinPsiUnifier( fun checkImplicitReceiver(implicitCall: ResolvedCall<*>, explicitCall: ResolvedCall<*>): Boolean { val (implicitReceiver, explicitReceiver) = - when (explicitCall.getExplicitReceiverKind()) { + when (explicitCall.explicitReceiverKind) { ExplicitReceiverKind.EXTENSION_RECEIVER -> - (implicitCall.getExtensionReceiver() as? ImplicitReceiver) to - (explicitCall.getExtensionReceiver() as? ExpressionReceiver) + (implicitCall.extensionReceiver as? ImplicitReceiver) to + (explicitCall.extensionReceiver as? ExpressionReceiver) ExplicitReceiverKind.DISPATCH_RECEIVER -> - (implicitCall.getDispatchReceiver() as? ImplicitReceiver) to - (explicitCall.getDispatchReceiver() as? ExpressionReceiver) + (implicitCall.dispatchReceiver as? ImplicitReceiver) to + (explicitCall.dispatchReceiver as? ExpressionReceiver) else -> null to null @@ -225,28 +225,28 @@ public class KotlinPsiUnifier( return matchDescriptors( implicitReceiver.declarationDescriptor, - thisExpression.getAdjustedResolvedCall()?.getCandidateDescriptor()?.getContainingDeclaration() + thisExpression.getAdjustedResolvedCall()?.candidateDescriptor?.containingDeclaration ) } fun checkReceivers(): Boolean { return when { - rc1.getExplicitReceiverKind() == rc2.getExplicitReceiverKind() -> { - matchReceivers(rc1.getExtensionReceiver(), rc2.getExtensionReceiver()) && - (rc1.getExplicitReceiverKind() == ExplicitReceiverKind.BOTH_RECEIVERS || matchReceivers(rc1.getDispatchReceiver(), rc2.getDispatchReceiver())) + rc1.explicitReceiverKind == rc2.explicitReceiverKind -> { + matchReceivers(rc1.extensionReceiver, rc2.extensionReceiver) && + (rc1.explicitReceiverKind == ExplicitReceiverKind.BOTH_RECEIVERS || matchReceivers(rc1.dispatchReceiver, rc2.dispatchReceiver)) } - rc1.getExplicitReceiverKind() == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> checkImplicitReceiver(rc1, rc2) + rc1.explicitReceiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> checkImplicitReceiver(rc1, rc2) - rc2.getExplicitReceiverKind() == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> checkImplicitReceiver(rc2, rc1) + rc2.explicitReceiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> checkImplicitReceiver(rc2, rc1) else -> false } } fun checkTypeArguments(): Status? { - val typeArgs1 = rc1.getTypeArguments().toList() - val typeArgs2 = rc2.getTypeArguments().toList() + val typeArgs1 = rc1.typeArguments.toList() + val typeArgs2 = rc2.typeArguments.toList() if (typeArgs1.size != typeArgs2.size) return UNMATCHED for ((typeArg1, typeArg2) in (typeArgs1.zip(typeArgs2))) { @@ -261,9 +261,9 @@ public class KotlinPsiUnifier( return when { !checkSpecialOperations() -> UNMATCHED - !matchDescriptors(rc1.getCandidateDescriptor(), rc2.getCandidateDescriptor()) -> UNMATCHED + !matchDescriptors(rc1.candidateDescriptor, rc2.candidateDescriptor) -> UNMATCHED !checkReceivers() -> UNMATCHED - rc1.isSafeCall() != rc2.isSafeCall() -> UNMATCHED + rc1.isSafeCall != rc2.isSafeCall -> UNMATCHED else -> { val s = checkTypeArguments() if (s != MATCHED) s else checkArguments() @@ -288,7 +288,7 @@ public class KotlinPsiUnifier( } return when { - rc == null || ErrorUtils.isError(rc.getCandidateDescriptor()) -> null + rc == null || ErrorUtils.isError(rc.candidateDescriptor) -> null else -> rc } } @@ -323,24 +323,24 @@ public class KotlinPsiUnifier( private fun KtTypeReference.getType(): KotlinType? { val t = bindingContext[BindingContext.TYPE, this] - return if (t == null || t.isError()) null else t + return if (t == null || t.isError) null else t } private fun matchTypes(type1: KotlinType?, type2: KotlinType?): Status? { if (type1 != null && type2 != null) { - if (type1.isError() || type2.isError()) return null + if (type1.isError || type2.isError) return null if (TypeUtils.equalTypes(type1, type2)) return MATCHED - if (type1.isMarkedNullable() != type2.isMarkedNullable()) return UNMATCHED + if (type1.isMarkedNullable != type2.isMarkedNullable) return UNMATCHED if (!matchDescriptors( - type1.getConstructor().getDeclarationDescriptor(), - type2.getConstructor().getDeclarationDescriptor())) return UNMATCHED + type1.constructor.declarationDescriptor, + type2.constructor.declarationDescriptor)) return UNMATCHED - val args1 = type1.getArguments() - val args2 = type2.getArguments() + val args1 = type1.arguments + val args2 = type2.arguments if (args1.size != args2.size) return UNMATCHED if (!args1.zip(args2).all { - it.first.getProjectionKind() == it.second.getProjectionKind() && matchTypes(it.first.getType(), it.second.getType()) == MATCHED } + it.first.projectionKind == it.second.projectionKind && matchTypes(it.first.type, it.second.type) == MATCHED } ) return UNMATCHED return MATCHED @@ -361,24 +361,24 @@ public class KotlinPsiUnifier( this is KtConstantExpression -> true this is KtOperationReferenceExpression -> getReferencedNameElementType() == KtTokens.EXCLEXCL this is KtIfExpression -> true - this is KtUnaryExpression -> when (getOperationReference().getReferencedNameElementType()) { + this is KtUnaryExpression -> when (operationReference.getReferencedNameElementType()) { KtTokens.EXCLEXCL, KtTokens.PLUSPLUS, KtTokens.MINUSMINUS -> true else -> false } - this is KtBinaryExpression -> getOperationReference().getReferencedNameElementType() == KtTokens.ELVIS + this is KtBinaryExpression -> operationReference.getReferencedNameElementType() == KtTokens.ELVIS else -> false } } private fun KtBinaryExpression.matchComplexAssignmentWithSimple(simple: KtBinaryExpression): Status? { return when { - doUnify(getLeft(), simple.getLeft()) == UNMATCHED -> UNMATCHED - else -> simple.getRight()?.let { matchCalls(this, it) } ?: UNMATCHED + doUnify(left, simple.left) == UNMATCHED -> UNMATCHED + else -> simple.right?.let { matchCalls(this, it) } ?: UNMATCHED } } private fun KtBinaryExpression.matchAssignment(e: KtElement): Status? { - val operationType = getOperationReference().getReferencedNameElementType() as KtToken + val operationType = operationReference.getReferencedNameElementType() as KtToken if (operationType == KtTokens.EQ) { if (e.shouldIgnoreResolvedCall()) return UNMATCHED @@ -386,7 +386,7 @@ public class KotlinPsiUnifier( return (e as KtBinaryExpression).matchComplexAssignmentWithSimple(this) } - val lhs = getLeft()?.unwrap() + val lhs = left?.unwrap() if (lhs !is KtArrayAccessExpression) return null val setResolvedCall = bindingContext[BindingContext.INDEXED_LVALUE_SET, lhs] @@ -399,7 +399,7 @@ public class KotlinPsiUnifier( if (assignResolvedCall == null) return UNMATCHED val operationName = OperatorConventions.getNameForOperationSymbol(operationType) - if (assignResolvedCall.getResultingDescriptor()?.getName() == operationName) return matchCalls(this, e) + if (assignResolvedCall.resultingDescriptor?.name == operationName) return matchCalls(this, e) return if (KtPsiUtil.isAssignment(e)) null else UNMATCHED } @@ -412,21 +412,21 @@ public class KotlinPsiUnifier( } private fun PsiElement.isIncrement(): Boolean { - val parent = getParent() + val parent = parent return parent is KtUnaryExpression - && this == parent.getOperationReference() - && ((parent.getOperationToken() as KtToken) in OperatorConventions.INCREMENT_OPERATIONS) + && this == parent.operationReference + && ((parent.operationToken as KtToken) in OperatorConventions.INCREMENT_OPERATIONS) } private fun matchCallableReferences(e1: KtCallableReferenceExpression, e2: KtCallableReferenceExpression): Boolean { - val d1 = e1.bindingContext[BindingContext.REFERENCE_TARGET, e1.getCallableReference()] - val d2 = e2.bindingContext[BindingContext.REFERENCE_TARGET, e2.getCallableReference()] + val d1 = e1.bindingContext[BindingContext.REFERENCE_TARGET, e1.callableReference] + val d2 = e2.bindingContext[BindingContext.REFERENCE_TARGET, e2.callableReference] return matchDescriptors(d1, d2) } private fun matchDestructuringDeclarations(e1: KtDestructuringDeclaration, e2: KtDestructuringDeclaration): Boolean { - val entries1 = e1.getEntries() - val entries2 = e2.getEntries() + val entries1 = e1.entries + val entries2 = e2.entries if (entries1.size != entries2.size) return false return entries1.zip(entries2).all { p -> @@ -445,7 +445,7 @@ public class KotlinPsiUnifier( val matchedReceivers = when { receiver1 == null && receiver2 == null -> true matchDescriptors(receiver1, receiver2) -> true - receiver1 != null && receiver2 != null -> matchTypes(receiver1.getType(), receiver2.getType()) == MATCHED + receiver1 != null && receiver2 != null -> matchTypes(receiver1.type, receiver2.type) == MATCHED else -> false } @@ -463,47 +463,47 @@ public class KotlinPsiUnifier( desc2: CallableDescriptor): Status? { fun needToCompareReturnTypes(): Boolean { if (decl1 !is KtCallableDeclaration) return true - return decl1.getTypeReference() != null || (decl2 as KtCallableDeclaration).getTypeReference() != null + return decl1.typeReference != null || (decl2 as KtCallableDeclaration).typeReference != null } - if (desc1 is VariableDescriptor && desc1.isVar() != (desc2 as VariableDescriptor).isVar()) return UNMATCHED + if (desc1 is VariableDescriptor && desc1.isVar != (desc2 as VariableDescriptor).isVar) return UNMATCHED if (!matchNames(decl1, decl2, desc1, desc2)) return UNMATCHED if (needToCompareReturnTypes()) { - val type1 = desc1.getReturnType() - val type2 = desc2.getReturnType() + val type1 = desc1.returnType + val type2 = desc2.returnType if (type1 != type2 - && (type1 == null || type2 == null || type1.isError() || type2.isError() || matchTypes(type1, type2) != MATCHED)) { + && (type1 == null || type2 == null || type1.isError || type2.isError || matchTypes(type1, type2) != MATCHED)) { return UNMATCHED } } - if (!matchReceiverParameters(desc1.getExtensionReceiverParameter(), desc2.getExtensionReceiverParameter())) return UNMATCHED - if (!matchReceiverParameters(desc1.getDispatchReceiverParameter(), desc2.getDispatchReceiverParameter())) return UNMATCHED + if (!matchReceiverParameters(desc1.extensionReceiverParameter, desc2.extensionReceiverParameter)) return UNMATCHED + if (!matchReceiverParameters(desc1.dispatchReceiverParameter, desc2.dispatchReceiverParameter)) return UNMATCHED - val params1 = desc1.getValueParameters() - val params2 = desc2.getValueParameters() + val params1 = desc1.valueParameters + val params2 = desc2.valueParameters val zippedParams = params1.zip(params2) val parametersMatch = - (params1.size == params2.size) && zippedParams.all { matchTypes(it.first.getType(), it.second.getType()) == MATCHED } + (params1.size == params2.size) && zippedParams.all { matchTypes(it.first.type, it.second.type) == MATCHED } if (!parametersMatch) return UNMATCHED zippedParams.forEach { declarationPatternsToTargets.putValue(it.first, it.second) } return doUnify( - (decl1 as? KtTypeParameterListOwner)?.getTypeParameters()?.toRange() ?: Empty, - (decl2 as? KtTypeParameterListOwner)?.getTypeParameters()?.toRange() ?: Empty + (decl1 as? KtTypeParameterListOwner)?.typeParameters?.toRange() ?: Empty, + (decl2 as? KtTypeParameterListOwner)?.typeParameters?.toRange() ?: Empty ) and when (decl1) { is KtDeclarationWithBody -> - doUnify(decl1.getBodyExpression(), (decl2 as KtDeclarationWithBody).getBodyExpression()) + doUnify(decl1.bodyExpression, (decl2 as KtDeclarationWithBody).bodyExpression) is KtWithExpressionInitializer -> - doUnify(decl1.getInitializer(), (decl2 as KtWithExpressionInitializer).getInitializer()) + doUnify(decl1.initializer, (decl2 as KtWithExpressionInitializer).initializer) is KtParameter -> - doUnify(decl1.getDefaultValue(), (decl2 as KtParameter).getDefaultValue()) + doUnify(decl1.defaultValue, (decl2 as KtParameter).defaultValue) else -> UNMATCHED @@ -513,12 +513,12 @@ public class KotlinPsiUnifier( private fun KtDeclaration.isNameRelevant(): Boolean { if (this is KtParameter && hasValOrVar()) return true - val parent = getParent() + val parent = parent return parent is KtClassBody || parent is KtFile } private fun matchNames(decl1: KtDeclaration, decl2: KtDeclaration, desc1: DeclarationDescriptor, desc2: DeclarationDescriptor): Boolean { - return (!decl1.isNameRelevant() && !decl2.isNameRelevant()) || desc1.getName() == desc2.getName() + return (!decl1.isNameRelevant() && !decl2.isNameRelevant()) || desc1.name == desc2.name } private fun matchContainedDescriptors( @@ -544,7 +544,7 @@ public class KotlinPsiUnifier( ) fun getMemberOrderInfo(cls: KtClassOrObject): OrderInfo { - val (orderInsensitive, orderSensitive) = (cls.getBody()?.getDeclarations() ?: Collections.emptyList()).partition { + val (orderInsensitive, orderSensitive) = (cls.getBody()?.declarations ?: Collections.emptyList()).partition { it is KtClassOrObject || it is KtFunction } @@ -563,16 +563,16 @@ public class KotlinPsiUnifier( } fun sortDeclarationsByElementType(declarations: List): List { - return declarations.sortedBy { it.getNode()?.getElementType()?.getIndex() ?: -1 } + return declarations.sortedBy { it.node?.elementType?.index ?: -1 } } - if (desc1.getKind() != desc2.getKind()) return UNMATCHED + if (desc1.kind != desc2.kind) return UNMATCHED if (!matchNames(decl1, decl2, desc1, desc2)) return UNMATCHED - declarationPatternsToTargets.putValue(desc1.getThisAsReceiverParameter(), desc2.getThisAsReceiverParameter()) + declarationPatternsToTargets.putValue(desc1.thisAsReceiverParameter, desc2.thisAsReceiverParameter) - val constructor1 = desc1.getUnsubstitutedPrimaryConstructor() - val constructor2 = desc2.getUnsubstitutedPrimaryConstructor() + val constructor1 = desc1.unsubstitutedPrimaryConstructor + val constructor2 = desc2.unsubstitutedPrimaryConstructor if (constructor1 != null && constructor2 != null) { declarationPatternsToTargets.putValue(constructor1, constructor2) } @@ -590,7 +590,7 @@ public class KotlinPsiUnifier( } val status = doUnify((decl1 as? KtClass)?.getPrimaryConstructorParameterList(), (decl2 as? KtClass)?.getPrimaryConstructorParameterList()) and - doUnify((decl1 as? KtClass)?.getTypeParameterList(), (decl2 as? KtClass)?.getTypeParameterList()) and + doUnify((decl1 as? KtClass)?.typeParameterList, (decl2 as? KtClass)?.typeParameterList) and doUnify(delegationInfo1.orderSensitive.toRange(), delegationInfo2.orderSensitive.toRange()) if (status == UNMATCHED) return UNMATCHED @@ -615,9 +615,9 @@ public class KotlinPsiUnifier( desc1: TypeParameterDescriptor, desc2: TypeParameterDescriptor ): Status { - if (desc1.getVariance() != desc2.getVariance()) return UNMATCHED - if (!matchTypes(desc1.getLowerBounds(), desc2.getLowerBounds())) return UNMATCHED - if (!matchTypes(desc1.getUpperBounds(), desc2.getUpperBounds())) return UNMATCHED + if (desc1.variance != desc2.variance) return UNMATCHED + if (!matchTypes(desc1.lowerBounds, desc2.lowerBounds)) return UNMATCHED + if (!matchTypes(desc1.upperBounds, desc2.upperBounds)) return UNMATCHED return MATCHED } @@ -782,13 +782,13 @@ public class KotlinPsiUnifier( } private fun ASTNode.getChildrenRange(): KotlinPsiRange = - getChildren(null).mapNotNull { it.getPsi() }.toRange() + getChildren(null).mapNotNull { it.psi }.toRange() private fun PsiElement.unwrapWeakly(): KtElement? { return when { - this is KtReturnExpression -> getReturnedExpression() - this is KtProperty -> getInitializer() - KtPsiUtil.isOrdinaryAssignment(this) -> (this as KtBinaryExpression).getRight() + this is KtReturnExpression -> returnedExpression + this is KtProperty -> initializer + KtPsiUtil.isOrdinaryAssignment(this) -> (this as KtBinaryExpression).right this is KtExpression && this !is KtDeclaration -> this else -> null } @@ -850,8 +850,8 @@ public class KotlinPsiUnifier( } } - val targetNode = targetElementUnwrapped.getNode() - val patternNode = patternElementUnwrapped.getNode() + val targetNode = targetElementUnwrapped.node + val patternNode = patternElementUnwrapped.node if (targetNode == null || patternNode == null) return UNMATCHED val resolvedStatus = matchResolvedInfo(targetElementUnwrapped, patternElementUnwrapped) @@ -862,7 +862,7 @@ public class KotlinPsiUnifier( if (weakStatus != UNMATCHED) return weakStatus } - if (targetNode.getElementType() != patternNode.getElementType()) return UNMATCHED + if (targetNode.elementType != patternNode.elementType) return UNMATCHED if (resolvedStatus != null) return resolvedStatus @@ -884,17 +884,17 @@ public class KotlinPsiUnifier( private fun PsiElement.unwrap(): PsiElement? { return when (this) { is KtExpression -> KtPsiUtil.deparenthesize(this) - is KtStringTemplateEntryWithExpression -> KtPsiUtil.deparenthesize(getExpression()) + is KtStringTemplateEntryWithExpression -> KtPsiUtil.deparenthesize(expression) else -> this } } private fun PsiElement.unquotedText(): String { - val text = getText() ?: "" + val text = text ?: "" return if (this is LeafPsiElement) KtPsiUtil.unquoteIdentifier(text) else text } - public fun unify(target: KotlinPsiRange, pattern: KotlinPsiRange): UnificationResult { + fun unify(target: KotlinPsiRange, pattern: KotlinPsiRange): UnificationResult { return with(Context(target, pattern)) { val status = doUnify(target, pattern) when { @@ -914,9 +914,9 @@ public class KotlinPsiUnifier( } } - public fun unify(targetElement: PsiElement?, patternElement: PsiElement?): UnificationResult = + fun unify(targetElement: PsiElement?, patternElement: PsiElement?): UnificationResult = unify(targetElement.toRange(), patternElement.toRange()) } -public fun PsiElement?.matches(e: PsiElement?): Boolean = KotlinPsiUnifier.DEFAULT.unify(this, e).matched -public fun KotlinPsiRange.matches(r: KotlinPsiRange): Boolean = KotlinPsiUnifier.DEFAULT.unify(this, r).matched +fun PsiElement?.matches(e: PsiElement?): Boolean = KotlinPsiUnifier.DEFAULT.unify(this, e).matched +fun KotlinPsiRange.matches(r: KotlinPsiRange): Boolean = KotlinPsiUnifier.DEFAULT.unify(this, r).matched diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinAbiVersionIndex.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinAbiVersionIndex.kt index dc546876a4e..a85c040a807 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinAbiVersionIndex.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinAbiVersionIndex.kt @@ -29,7 +29,7 @@ import org.jetbrains.org.objectweb.asm.ClassReader import org.jetbrains.org.objectweb.asm.ClassVisitor import org.jetbrains.org.objectweb.asm.Opcodes -public object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase(KotlinAbiVersionIndex::class.java) { +object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase(KotlinAbiVersionIndex::class.java) { override fun getIndexer() = INDEXER diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinJavaScriptAbiVersionIndex.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinJavaScriptAbiVersionIndex.kt index 6fada6ffb8b..52cdf6c0063 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinJavaScriptAbiVersionIndex.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinJavaScriptAbiVersionIndex.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils import java.util.* -public object KotlinJavaScriptAbiVersionIndex : KotlinAbiVersionIndexBase(KotlinJavaScriptAbiVersionIndex::class.java) { +object KotlinJavaScriptAbiVersionIndex : KotlinAbiVersionIndexBase(KotlinJavaScriptAbiVersionIndex::class.java) { override fun getIndexer() = INDEXER diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt index f159be05cb6..7a227c38932 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt @@ -40,7 +40,7 @@ private val INSTALLED_KOTLIN_VERSION = "installed.kotlin.plugin.version" */ class KotlinUpdatePluginComponent : ApplicationComponent { override fun initComponent() { - if (ApplicationManager.getApplication()?.isUnitTestMode() == true) { + if (ApplicationManager.getApplication()?.isUnitTestMode == true) { return } @@ -50,20 +50,20 @@ class KotlinUpdatePluginComponent : ApplicationComponent { val ideaPluginPaths = PathUtil.getKotlinPathsForIdeaPlugin() // Force refresh jar handlers - requestFullJarUpdate(ideaPluginPaths.getRuntimePath()) - requestFullJarUpdate(ideaPluginPaths.getReflectPath()) - requestFullJarUpdate(ideaPluginPaths.getRuntimeSourcesPath()) + requestFullJarUpdate(ideaPluginPaths.runtimePath) + requestFullJarUpdate(ideaPluginPaths.reflectPath) + requestFullJarUpdate(ideaPluginPaths.runtimeSourcesPath) - requestFullJarUpdate(ideaPluginPaths.getJsStdLibJarPath()) - requestFullJarUpdate(ideaPluginPaths.getJsStdLibSrcJarPath()) + requestFullJarUpdate(ideaPluginPaths.jsStdLibJarPath) + requestFullJarUpdate(ideaPluginPaths.jsStdLibSrcJarPath) - requestFullJarUpdate(ideaPluginPaths.getJdkAnnotationsPath()) - requestFullJarUpdate(ideaPluginPaths.getAndroidSdkAnnotationsPath()) + requestFullJarUpdate(ideaPluginPaths.jdkAnnotationsPath) + requestFullJarUpdate(ideaPluginPaths.androidSdkAnnotationsPath) // Force update indices for files under config directory val fileBasedIndex = FileBasedIndex.getInstance() - fileBasedIndex.requestRebuild(KotlinAbiVersionIndex.getName()) - fileBasedIndex.requestRebuild(KotlinJavaScriptAbiVersionIndex.getName()) + fileBasedIndex.requestRebuild(KotlinAbiVersionIndex.name) + fileBasedIndex.requestRebuild(KotlinJavaScriptAbiVersionIndex.name) fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY) fileBasedIndex.requestRebuild(KotlinJavaScriptMetaFileIndex.KEY) fileBasedIndex.requestRebuild(KotlinModuleMappingIndex.KEY) diff --git a/idea/src/org/jetbrains/kotlin/plugin/findUsages/handlers/KotlinFindUsagesHandlerDecorator.kt b/idea/src/org/jetbrains/kotlin/plugin/findUsages/handlers/KotlinFindUsagesHandlerDecorator.kt index 259da975ffc..d7dc8a8a0d4 100644 --- a/idea/src/org/jetbrains/kotlin/plugin/findUsages/handlers/KotlinFindUsagesHandlerDecorator.kt +++ b/idea/src/org/jetbrains/kotlin/plugin/findUsages/handlers/KotlinFindUsagesHandlerDecorator.kt @@ -20,10 +20,10 @@ import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.psi.PsiElement import com.intellij.find.findUsages.FindUsagesHandler -public interface KotlinFindUsagesHandlerDecorator { +interface KotlinFindUsagesHandlerDecorator { companion object { - public val EP_NAME: ExtensionPointName = ExtensionPointName.create("org.jetbrains.kotlin.findUsagesHandlerDecorator")!! + val EP_NAME: ExtensionPointName = ExtensionPointName.create("org.jetbrains.kotlin.findUsagesHandlerDecorator")!! } - public fun decorateHandler(element: PsiElement, forHighlightUsages: Boolean, delegate: FindUsagesHandler): FindUsagesHandler + fun decorateHandler(element: PsiElement, forHighlightUsages: Boolean, delegate: FindUsagesHandler): FindUsagesHandler } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt b/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt index f1ca0f4729e..7c854e85c71 100644 --- a/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt @@ -27,16 +27,16 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -public abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory() override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE protected fun doTest(testPath: String) { val settingManager = CodeStyleSettingsManager.getInstance() - val tempSettings = settingManager.getCurrentSettings().clone() - settingManager.setTemporarySettings(tempSettings) + val tempSettings = settingManager.currentSettings.clone() + settingManager.temporarySettings = tempSettings - val codeStyleSettings = KotlinCodeStyleSettings.getInstance(getProject()) + val codeStyleSettings = KotlinCodeStyleSettings.getInstance(project) try { val fixture = myFixture @@ -51,9 +51,9 @@ public abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCas fixture.configureByFile(testPath) - val file = fixture.getFile() as KtFile + val file = fixture.file as KtFile - val fileText = file.getText() + val fileText = file.text codeStyleSettings.NAME_COUNT_TO_USE_STAR_IMPORT = InTextDirectivesUtils.getPrefixedInt(fileText, "// NAME_COUNT_TO_USE_STAR_IMPORT:") ?: nameCountToUseStarImportDefault codeStyleSettings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS = InTextDirectivesUtils.getPrefixedInt(fileText, "// NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS:") ?: nameCountToUseStarImportForMembersDefault @@ -66,11 +66,11 @@ public abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCas codeStyleSettings.PACKAGES_TO_USE_STAR_IMPORTS.addEntry(PackageEntry(false, it.trim(), true)) } - getProject().executeWriteCommand("") { + project.executeWriteCommand("") { doTest(file) } - KotlinTestUtils.assertEqualsToFile(File(testPath + ".after"), myFixture.getFile().getText()) + KotlinTestUtils.assertEqualsToFile(File(testPath + ".after"), myFixture.file.text) } finally { settingManager.dropTemporarySettings() diff --git a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt index 8da3f6510a7..852339e79a2 100644 --- a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -public abstract class AbstractDataFlowValueRenderingTest: KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractDataFlowValueRenderingTest: KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath() : String { return PluginTestCaseBase.getTestDataPathBase() + "/dataFlowValueRendering/" } @@ -43,12 +43,12 @@ public abstract class AbstractDataFlowValueRenderingTest: KotlinLightCodeInsight val fixture = myFixture fixture.configureByFile(fileName) - val jetFile = fixture.getFile() as KtFile - val element = jetFile.findElementAt(fixture.getCaretOffset())!! + val jetFile = fixture.file as KtFile + val element = jetFile.findElementAt(fixture.caretOffset)!! val expression = element.getStrictParentOfType()!! val info = expression.analyze().getDataFlowInfo(expression) - val allValues = (info.getCompleteTypeInfo().keySet() + info.getCompleteNullabilityInfo().keys).toSet() + val allValues = (info.completeTypeInfo.keySet() + info.completeNullabilityInfo.keys).toSet() val actual = allValues.mapNotNull { renderDataFlowValue(it) }.sorted().joinToString("\n") KotlinTestUtils.assertEqualsToFile(File(FileUtil.getNameWithoutExtension(fileName) + ".txt"), actual) diff --git a/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt b/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt index ac261b35e6a..148cc84bdf2 100644 --- a/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt +++ b/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.test.InTextDirectivesUtils -public abstract class AbstractAddImportTest : AbstractImportsTest() { +abstract class AbstractAddImportTest : AbstractImportsTest() { override fun doTest(file: KtFile) { - var descriptorName = InTextDirectivesUtils.findStringWithPrefixes(file.getText(), "// IMPORT:") + var descriptorName = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// IMPORT:") ?: error("No IMPORT directive defined") var filter: (DeclarationDescriptor) -> Boolean = { true } @@ -49,11 +49,11 @@ public abstract class AbstractAddImportTest : AbstractImportsTest() { error("Multiple descriptors found:\n " + descriptors.map { DescriptorRenderer.FQ_NAMES_IN_TYPES.render(it) }.joinToString("\n ")) else -> { - val success = ImportInsertHelper.getInstance(getProject()).importDescriptor(file, descriptors.single()) != ImportDescriptorResult.FAIL + val success = ImportInsertHelper.getInstance(project).importDescriptor(file, descriptors.single()) != ImportDescriptorResult.FAIL if (!success) { - val document = PsiDocumentManager.getInstance(getProject()).getDocument(file)!! - document.replaceString(0, document.getTextLength(), "Failed to add import") - PsiDocumentManager.getInstance(getProject()).commitAllDocuments() + val document = PsiDocumentManager.getInstance(project).getDocument(file)!! + document.replaceString(0, document.textLength, "Failed to add import") + PsiDocumentManager.getInstance(project).commitAllDocuments() } } } diff --git a/idea/tests/org/jetbrains/kotlin/asJava/KotlinLightClassInheritorTest.kt b/idea/tests/org/jetbrains/kotlin/asJava/KotlinLightClassInheritorTest.kt index 8bb97e9ac56..64acd167345 100644 --- a/idea/tests/org/jetbrains/kotlin/asJava/KotlinLightClassInheritorTest.kt +++ b/idea/tests/org/jetbrains/kotlin/asJava/KotlinLightClassInheritorTest.kt @@ -25,24 +25,24 @@ import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtFile import org.junit.Assert -public class KotlinLightClassInheritorTest : KotlinLightCodeInsightFixtureTestCase() { - public fun testAnnotation() { +class KotlinLightClassInheritorTest : KotlinLightCodeInsightFixtureTestCase() { + fun testAnnotation() { doTestInheritorByText("annotation class A", "java.lang.annotation.Annotation", false) } - public fun testEnum() { + fun testEnum() { doTestInheritorByText("enum class A", "java.lang.Enum", false) } - public fun testIterable() { + fun testIterable() { doTestInheritorByText("abstract class A : Iterable", "java.lang.Iterable", false) } - public fun testIterableDeep() { + fun testIterableDeep() { doTestInheritorByText("abstract class A : List", "java.lang.Iterable", true) } - public fun testObjectDeep() { + fun testObjectDeep() { doTestInheritorByText("abstract class A : List", "java.lang.Object", true) } diff --git a/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt b/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt index 4872d369d63..fea50741512 100644 --- a/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt @@ -40,9 +40,9 @@ class LightClassesClasspathSortingTest : KotlinCodeInsightTestCase() { // Configure library first to make classes be indexed before correspondent classes from sources val dirName = getTestName(true) - getModule().configureAs(getProjectDescriptor(dirName)) + module.configureAs(getProjectDescriptor(dirName)) - val testDirRoot = File(getTestDataPath()) + val testDirRoot = File(testDataPath) val filePaths = File(testDirRoot, dirName).listFiles().map { it.toRelativeString(testDirRoot) }.toTypedArray() configureByFiles(null, *filePaths) @@ -50,7 +50,7 @@ class LightClassesClasspathSortingTest : KotlinCodeInsightTestCase() { } private fun checkLightClassBeforeDecompiled(fqName: String) { - val psiClass = JavaPsiFacade.getInstance(getProject()).findClass(fqName, ResolveScopeManager.getElementResolveScope(getFile())) + val psiClass = JavaPsiFacade.getInstance(project).findClass(fqName, ResolveScopeManager.getElementResolveScope(file)) assertNotNull(psiClass, "Can't find class for $fqName") psiClass!! diff --git a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerCustomTest.kt b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerCustomTest.kt index 94a94d2998d..6bed912190b 100644 --- a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerCustomTest.kt +++ b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerCustomTest.kt @@ -18,15 +18,15 @@ package org.jetbrains.kotlin.checkers import com.intellij.codeInspection.ex.EntryPointsManagerBase -public class PsiCheckerCustomTest : AbstractPsiCheckerTest() { - public fun testNoUnusedParameterWhenCustom() { +class PsiCheckerCustomTest : AbstractPsiCheckerTest() { + fun testNoUnusedParameterWhenCustom() { val testAnnotation = "MyTestAnnotation" - EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.add(testAnnotation) + EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(testAnnotation) try { doTest("idea/testData/checker/custom/noUnusedParameterWhenCustom.kt") } finally { - EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.remove(testAnnotation) + EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.remove(testAnnotation) } } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/AbstractKotlinFindUsagesWithLibraryTest.kt b/idea/tests/org/jetbrains/kotlin/findUsages/AbstractKotlinFindUsagesWithLibraryTest.kt index cc357b2bd8f..2e6eca67c34 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/AbstractKotlinFindUsagesWithLibraryTest.kt +++ b/idea/tests/org/jetbrains/kotlin/findUsages/AbstractKotlinFindUsagesWithLibraryTest.kt @@ -21,7 +21,7 @@ import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -public abstract class AbstractKotlinFindUsagesWithLibraryTest : AbstractFindUsagesTest() { +abstract class AbstractKotlinFindUsagesWithLibraryTest : AbstractFindUsagesTest() { override fun getProjectDescriptor() = JdkAndMockLibraryProjectDescriptor(PluginTestCaseBase.getTestDataPathBase() + "/findUsages/libraryUsages/_library", true) } diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt b/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt index 7b2195d4d18..1fc23fb9b39 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt +++ b/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt @@ -21,10 +21,10 @@ import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import kotlin.test.assertEquals -public class KotlinFindUsagesWithLibraryCustomTest : AbstractKotlinFindUsagesWithLibraryTest() { - public fun testFindUsagesForLocalClassProperty() { - val libraryFile = FilenameIndex.getFilesByName(getProject(), "library.kt", myFixture.getModule().getModuleWithLibrariesScope()).first() - val indexOf = libraryFile.getText().indexOf("localClassProperty") +class KotlinFindUsagesWithLibraryCustomTest : AbstractKotlinFindUsagesWithLibraryTest() { + fun testFindUsagesForLocalClassProperty() { + val libraryFile = FilenameIndex.getFilesByName(getProject(), "library.kt", myFixture.module.moduleWithLibrariesScope).first() + val indexOf = libraryFile.text.indexOf("localClassProperty") val jetParameter = libraryFile.findElementAt(indexOf)!!.getStrictParentOfType()!! val usages = findUsages(jetParameter.getOriginalElement(), null, false) assertEquals(2, usages.size) diff --git a/idea/tests/org/jetbrains/kotlin/idea/AbstractCopyPasteTest.kt b/idea/tests/org/jetbrains/kotlin/idea/AbstractCopyPasteTest.kt index 92c8a489e09..2153eb09291 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/AbstractCopyPasteTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/AbstractCopyPasteTest.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.psi.KtFile import java.io.File -public abstract class AbstractCopyPasteTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractCopyPasteTest : KotlinLightCodeInsightFixtureTestCase() { private var savedImportsOnPasteSetting: Int = 0 private val DEFAULT_TO_FILE_TEXT = "package to\n\n" @@ -39,11 +39,11 @@ public abstract class AbstractCopyPasteTest : KotlinLightCodeInsightFixtureTestC } protected fun configureByDependencyIfExists(dependencyFileName: String): PsiFile? { - val file = File(getTestDataPath() + File.separator + dependencyFileName) + val file = File(testDataPath + File.separator + dependencyFileName) if (!file.exists()) return null return if (dependencyFileName.endsWith(".java")) { //allow test framework to put it under right directory - myFixture.addClass(FileUtil.loadFile(file, true)).getContainingFile() + myFixture.addClass(FileUtil.loadFile(file, true)).containingFile } else { myFixture.configureByFile(dependencyFileName) @@ -51,7 +51,7 @@ public abstract class AbstractCopyPasteTest : KotlinLightCodeInsightFixtureTestC } protected fun configureTargetFile(fileName: String): KtFile { - if (File(getTestDataPath() + File.separator + fileName).exists()) { + if (File(testDataPath + File.separator + fileName).exists()) { return myFixture.configureByFile(fileName) as KtFile } else { diff --git a/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt index e761abf8cab..24555e7ef9e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt @@ -22,8 +22,8 @@ import org.jetbrains.kotlin.idea.versions.OutdatedKotlinRuntimeNotification import org.junit.Assert -public class KotlinRuntimeLibraryUtilTest : TestCase() { - public fun testKotlinLibraryRelevantVersion() { +class KotlinRuntimeLibraryUtilTest : TestCase() { + fun testKotlinLibraryRelevantVersion() { test("0.10.2013", "0.10.2013") test("0.10.M.2013", "0.10") test("0.10.2.Idea140.2013", "0.10.2") @@ -55,7 +55,7 @@ public class KotlinRuntimeLibraryUtilTest : TestCase() { test("1.2.2123-alpha-023", "1.2.2123-alpha-023") } - public fun testOutdatedRuntime() { + fun testOutdatedRuntime() { outdated("1.0.0-beta1-001-Idea141-12", "0.12.15") outdated("1.0.0-beta1-001-Idea141-1", "0.152.16") outdated("1.0.0-beta1-001-Idea141-1", "0.152.16") diff --git a/idea/tests/org/jetbrains/kotlin/idea/RegisteredFindersTest.kt b/idea/tests/org/jetbrains/kotlin/idea/RegisteredFindersTest.kt index c0b9ba7b067..7ceb8760c72 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/RegisteredFindersTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/RegisteredFindersTest.kt @@ -23,15 +23,15 @@ import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade import org.junit.Assert -public class RegisteredFindersTest : KotlinLightCodeInsightFixtureTestCase() { +class RegisteredFindersTest : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor() = LightCodeInsightFixtureTestCase.JAVA_LATEST - public fun testKnownNonClasspathFinder() { + fun testKnownNonClasspathFinder() { val expectedFindersNames = setOf("GantClassFinder", "GradleClassFinder").toMutableSet() - getProject().getExtensions(PsiElementFinder.EP_NAME).forEach { finder -> + project.getExtensions(PsiElementFinder.EP_NAME).forEach { finder -> if (finder is NonClasspathClassFinder) { - val name = finder.javaClass.getSimpleName() + val name = finder.javaClass.simpleName val removed = expectedFindersNames.remove(name) Assert.assertTrue("Unknown finder found: $finder, class name: $name, search in $expectedFindersNames.\n" + "Consider updating ${KotlinJavaPsiFacade::class.java}", diff --git a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt index 1a311bcd2f2..698782d28ff 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -public class ResolveElementCacheTest : KotlinLightCodeInsightFixtureTestCase() { +class ResolveElementCacheTest : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor() = KotlinLightProjectDescriptor.INSTANCE private val FILE_TEXT = @@ -66,10 +66,10 @@ class C(param1: String = "", param2: Int = 0) { val members = klass.declarations val function = members.first() as KtNamedFunction val statements = (function.bodyExpression as KtBlockExpression).statements - return Data(file, klass, members, statements, KtPsiFactory(getProject())) + return Data(file, klass, members, statements, KtPsiFactory(project)) } - public fun testFullResolveCaching() { + fun testFullResolveCaching() { doTest { this.testResolveCaching() } } @@ -109,9 +109,9 @@ class C(param1: String = "", param2: Int = 0) { assert(bFunBodyContextAfterChange2 !== bFunBodyContextAfterChange1) } - public fun testNonPhysicalFileFullResolveCaching() { + fun testNonPhysicalFileFullResolveCaching() { doTest { - val nonPhysicalFile = KtPsiFactory(getProject()).createAnalyzableFile("NonPhysical.kt", FILE_TEXT, file) + val nonPhysicalFile = KtPsiFactory(project).createAnalyzableFile("NonPhysical.kt", FILE_TEXT, file) val nonPhysicalData = extractData(nonPhysicalFile) nonPhysicalData.testResolveCaching() @@ -137,7 +137,7 @@ class C(param1: String = "", param2: Int = 0) { } } - public fun testResolveSurvivesTypingInCodeBlock() { + fun testResolveSurvivesTypingInCodeBlock() { doTest { val statement = statements[0] val bindingContext1 = statement.analyze(BodyResolveMode.FULL) @@ -145,7 +145,7 @@ class C(param1: String = "", param2: Int = 0) { val classConstructorParamTypeRef = klass.getPrimaryConstructor()!!.valueParameters.first().typeReference!! val bindingContext2 = classConstructorParamTypeRef.analyze(BodyResolveMode.FULL) - val documentManager = PsiDocumentManager.getInstance(getProject()) + val documentManager = PsiDocumentManager.getInstance(project) val document = documentManager.getDocument(file)!! documentManager.doPostponedOperationsAndUnblockDocument(document) @@ -173,7 +173,7 @@ class C(param1: String = "", param2: Int = 0) { } } - public fun testPartialResolveUsesFullResolveCached() { + fun testPartialResolveUsesFullResolveCached() { doTest { val statement1 = statements[0] val statement2 = statements[1] @@ -187,7 +187,7 @@ class C(param1: String = "", param2: Int = 0) { } } - public fun testPartialResolveCaching() { + fun testPartialResolveCaching() { doTest { this.testPartialResolveCaching() } } @@ -208,35 +208,35 @@ class C(param1: String = "", param2: Int = 0) { val bindingContext5 = statement1.analyze(BodyResolveMode.PARTIAL) assert(bindingContext5 !== bindingContext1) - statement1.getParent().addAfter(factory.createExpression("x()"), statement1) + statement1.parent.addAfter(factory.createExpression("x()"), statement1) val bindingContext6 = statement1.analyze(BodyResolveMode.PARTIAL) assert(bindingContext6 !== bindingContext5) } - public fun testNonPhysicalFilePartialResolveCaching() { + fun testNonPhysicalFilePartialResolveCaching() { doTest { - val nonPhysicalFile = KtPsiFactory(getProject()).createAnalyzableFile("NonPhysical.kt", FILE_TEXT, file) + val nonPhysicalFile = KtPsiFactory(project).createAnalyzableFile("NonPhysical.kt", FILE_TEXT, file) val nonPhysicalData = extractData(nonPhysicalFile) nonPhysicalData.testPartialResolveCaching() } } - public fun testPartialResolveCachedForWholeStatement() { + fun testPartialResolveCachedForWholeStatement() { doTest { val statement = statements[0] as KtCallExpression - val argument1 = statement.getValueArguments()[0] - val argument2 = statement.getValueArguments()[1] + val argument1 = statement.valueArguments[0] + val argument2 = statement.valueArguments[1] val bindingContext1 = argument1.analyze(BodyResolveMode.PARTIAL) val bindingContext2 = argument2.analyze(BodyResolveMode.PARTIAL) assert(bindingContext1 === bindingContext2) } } - public fun testPartialResolveCachedForAllStatementsResolved() { + fun testPartialResolveCachedForAllStatementsResolved() { doTest { val bindingContext1 = statements[2].analyze(BodyResolveMode.PARTIAL) // resolve 'd(x)' - val bindingContext2 = (statements[1] as KtVariableDeclaration).getInitializer()!!.analyze(BodyResolveMode.PARTIAL) // resolve initializer in 'val x = c()' - it required for resolved 'd(x)' and should be already resolved + val bindingContext2 = (statements[1] as KtVariableDeclaration).initializer!!.analyze(BodyResolveMode.PARTIAL) // resolve initializer in 'val x = c()' - it required for resolved 'd(x)' and should be already resolved assert(bindingContext1 === bindingContext2) val bindingContext3 = statements[0].analyze(BodyResolveMode.PARTIAL) @@ -244,9 +244,9 @@ class C(param1: String = "", param2: Int = 0) { } } - public fun testPartialResolveCachedForDefaultParameterValue() { + fun testPartialResolveCachedForDefaultParameterValue() { doTest { - val defaultValue = (members[0] as KtNamedFunction).getValueParameters()[0].getDefaultValue() + val defaultValue = (members[0] as KtNamedFunction).valueParameters[0].defaultValue val bindingContext1 = defaultValue!!.analyze(BodyResolveMode.PARTIAL) val bindingContext2 = defaultValue.analyze(BodyResolveMode.PARTIAL) assert(bindingContext1 === bindingContext2) @@ -256,30 +256,30 @@ class C(param1: String = "", param2: Int = 0) { } } - public fun testFullResolvedCachedWhenPartialForConstructorInvoked() { + fun testFullResolvedCachedWhenPartialForConstructorInvoked() { doTest { - val defaultValue1 = klass.getPrimaryConstructorParameters()[0].getDefaultValue()!! - val defaultValue2 = klass.getPrimaryConstructorParameters()[1].getDefaultValue()!! + val defaultValue1 = klass.getPrimaryConstructorParameters()[0].defaultValue!! + val defaultValue2 = klass.getPrimaryConstructorParameters()[1].defaultValue!! val bindingContext1 = defaultValue1.analyze(BodyResolveMode.PARTIAL) val bindingContext2 = defaultValue2.analyze(BodyResolveMode.FULL) assert(bindingContext1 === bindingContext2) } } - public fun testAnnotationEntry() { + fun testAnnotationEntry() { val file = myFixture.configureByText("Test.kt", """ annotation class A @A class B {} """) as KtFile - val klass = file.getDeclarations()[1] as KtClass - val annotationEntry = klass.getAnnotationEntries().single() + val klass = file.declarations[1] as KtClass + val annotationEntry = klass.annotationEntries.single() val context = annotationEntry.analyze(BodyResolveMode.PARTIAL) assert(context[BindingContext.ANNOTATION, annotationEntry] != null) } - public fun testFileAnnotationList() { + fun testFileAnnotationList() { val file = myFixture.configureByText("Test.kt", """ @file:Suppress("Some") @file:JvmName("Hi") @@ -291,7 +291,7 @@ class C(param1: String = "", param2: Int = 0) { assert(context[BindingContext.ANNOTATION, fileAnnotationList.annotationEntries[1]] != null) } - public fun testIncompleteFileAnnotationList() { + fun testIncompleteFileAnnotationList() { val file = myFixture.configureByText("Test.kt", """ @file import some.hello diff --git a/idea/tests/org/jetbrains/kotlin/idea/actions/AbstractGotoTestOrCodeActionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/actions/AbstractGotoTestOrCodeActionTest.kt index abed81015cd..54fcfc6e165 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/actions/AbstractGotoTestOrCodeActionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/actions/AbstractGotoTestOrCodeActionTest.kt @@ -48,7 +48,7 @@ abstract class AbstractGotoTestOrCodeActionTest : KotlinLightCodeInsightFixtureT } ConfigLibraryUtil.configureLibrariesByDirective(myModule, PlatformTestUtil.getCommunityPath(), fileText) - myFixture.testDataPath = "${KotlinTestUtils.getHomeDirectory()}/${mainFile.getParent()}" + myFixture.testDataPath = "${KotlinTestUtils.getHomeDirectory()}/${mainFile.parent}" val mainFileName = mainFile.name val mainFileBaseName = mainFileName.substring(0, mainFileName.indexOf('.')) diff --git a/idea/tests/org/jetbrains/kotlin/idea/actions/QualifiedNamesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/actions/QualifiedNamesTest.kt index c87092232e9..95df6ea1d78 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/actions/QualifiedNamesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/actions/QualifiedNamesTest.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import java.util.ArrayList import kotlin.test.assertEquals -public class QualifiedNamesTest: LightCodeInsightTestCase() { +class QualifiedNamesTest: LightCodeInsightTestCase() { fun testClassRef() { LightPlatformCodeInsightTestCase.configureFromFileText( "class.kt", diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt index db32e3ef85b..9ad8ecf1b8b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt @@ -40,7 +40,7 @@ abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE } -public abstract class AbstractIdeCompiledLightClassTest : KotlinDaemonAnalyzerTestCase() { +abstract class AbstractIdeCompiledLightClassTest : KotlinDaemonAnalyzerTestCase() { override fun setUp() { super.setUp() diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/CustomModuleInfoTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/CustomModuleInfoTest.kt index eb1c6129bc5..ae5856dd243 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/CustomModuleInfoTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/CustomModuleInfoTest.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor import org.junit.Assert -public class CustomModuleInfoTest : KotlinLightCodeInsightFixtureTestCase() { +class CustomModuleInfoTest : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE fun testModuleInfoForMembersOfLightClassForDecompiledFile() { diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/HighlightingWithDependentLibrariesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/HighlightingWithDependentLibrariesTest.kt index e761cecada4..3834eb9dc29 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/HighlightingWithDependentLibrariesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/HighlightingWithDependentLibrariesTest.kt @@ -29,7 +29,7 @@ import com.intellij.openapi.module.Module import com.intellij.openapi.roots.ModifiableRootModel import com.intellij.openapi.roots.ContentEntry -public class HighlightingWithDependentLibrariesTest : KotlinLightCodeInsightFixtureTestCase() { +class HighlightingWithDependentLibrariesTest : KotlinLightCodeInsightFixtureTestCase() { private val TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/highlightingWithDependentLibraries" override fun getProjectDescriptor() = object : KotlinLightProjectDescriptor() { @@ -42,15 +42,15 @@ public class HighlightingWithDependentLibrariesTest : KotlinLightCodeInsightFixt } private fun createLibrary(jarFile: File, name: String): Library { - val library = LibraryTablesRegistrar.getInstance()!!.getLibraryTable(getProject()).createLibrary(name)!! - val model = library.getModifiableModel() + val library = LibraryTablesRegistrar.getInstance()!!.getLibraryTable(project).createLibrary(name)!! + val model = library.modifiableModel model.addRoot(VfsUtil.getUrlForLibraryRoot(jarFile), OrderRootType.CLASSES) model.commit() return library } } - public fun testHighlightingWithDependentLibraries() { + fun testHighlightingWithDependentLibraries() { myFixture.configureByFile("$TEST_DATA_PATH/module/usingLibs.kt") myFixture.checkHighlighting(false, false, false) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt index b99f2ddaeec..9c05e2be9fe 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt @@ -280,7 +280,7 @@ class IdeaModuleInfoTest : ModuleTestCase() { get() = testSourceInfo() private val Library.classes: LibraryInfo - get() = LibraryInfo(getProject()!!, this) + get() = LibraryInfo(project!!, this) private fun Module.addDependency( lib: Library, @@ -289,7 +289,7 @@ class IdeaModuleInfoTest : ModuleTestCase() { ) = ModuleRootModificationUtil.addDependency(this, lib, dependencyScope, exported) private fun module(name: String): Module { - return createModuleFromTestData(createTempDirectory()!!.getAbsolutePath(), name, StdModuleTypes.JAVA, false)!! + return createModuleFromTestData(createTempDirectory()!!.absolutePath, name, StdModuleTypes.JAVA, false)!! } private fun modules(name1: String = "a", name2: String = "b", name3: String = "c") = Triple(module(name1), module(name2), module(name3)) diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt index 00dce0e3b11..02ac9cb52e0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt @@ -78,7 +78,7 @@ class MultiModuleHighlightingTest : DaemonAnalyzerTestCase() { var atLeastOneFile = false PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file -> atLeastOneFile = true - configureByExistingFile(file.getVirtualFile()!!) + configureByExistingFile(file.virtualFile!!) checkHighlighting(myEditor, true, false) } Assert.assertTrue(atLeastOneFile) @@ -99,7 +99,7 @@ class MultiModuleHighlightingTest : DaemonAnalyzerTestCase() { val testRootDir = createTempDirectory()!! FileUtil.copyDir(testRootDirInTestData, testRootDir) val testRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(testRootDir)!! - object : WriteCommandAction.Simple(getProject()) { + object : WriteCommandAction.Simple(project) { override fun run() { testRoot.refresh(false, true) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt index b34e106a3ff..d76b2d2eac1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/PsiElementChecker.kt @@ -25,7 +25,7 @@ import org.junit.Assert object PsiElementChecker { val TEST_DATA_KEY = Key.create("Test Key") - public fun checkPsiElementStructure(lightClass: PsiClass) { + fun checkPsiElementStructure(lightClass: PsiClass) { checkPsiElement(lightClass) lightClass.innerClasses.forEach { checkPsiElementStructure(it) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInsertImportOnPasteTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInsertImportOnPasteTest.kt index ec66a8e8554..807547ef29c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInsertImportOnPasteTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInsertImportOnPasteTest.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -public abstract class AbstractInsertImportOnPasteTest : AbstractCopyPasteTest() { +abstract class AbstractInsertImportOnPasteTest : AbstractCopyPasteTest() { private val BASE_PATH = PluginTestCaseBase.getTestDataPathBase() + "/copyPaste/imports" private val NO_ERRORS_DUMP_DIRECTIVE = "// NO_ERRORS_DUMP" @@ -45,10 +45,10 @@ public abstract class AbstractInsertImportOnPasteTest : AbstractCopyPasteTest() } private fun doTestAction(cutOrCopy: String, path: String) { - myFixture.setTestDataPath(BASE_PATH) + myFixture.testDataPath = BASE_PATH val testFile = File(path) val testFileText = FileUtil.loadFile(testFile, true) - val testFileName = testFile.getName() + val testFileName = testFile.name val dependencyPsiFile1 = configureByDependencyIfExists(testFileName.replace(".kt", ".dependency.kt")) val dependencyPsiFile2 = configureByDependencyIfExists(testFileName.replace(".kt", ".dependency.java")) @@ -58,8 +58,8 @@ public abstract class AbstractInsertImportOnPasteTest : AbstractCopyPasteTest() if (InTextDirectivesUtils.isDirectiveDefined(testFileText, DELETE_DEPENDENCIES_BEFORE_PASTE_DIRECTIVE)) { assert(dependencyPsiFile1 != null || dependencyPsiFile2 != null) runWriteAction { - dependencyPsiFile1?.getVirtualFile()?.delete(null) - dependencyPsiFile2?.getVirtualFile()?.delete(null) + dependencyPsiFile1?.virtualFile?.delete(null) + dependencyPsiFile2?.virtualFile?.delete(null) } } @@ -71,9 +71,9 @@ public abstract class AbstractInsertImportOnPasteTest : AbstractCopyPasteTest() val namesToImportDump = KotlinCopyPasteReferenceProcessor.declarationsToImportSuggested.joinToString("\n") KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".expected.names")), namesToImportDump) - val resultFile = myFixture.getFile() as KtFile + val resultFile = myFixture.file as KtFile val resultText = if (InTextDirectivesUtils.isDirectiveDefined(testFileText, NO_ERRORS_DUMP_DIRECTIVE)) - resultFile.getText() + resultFile.text else resultFile.dumpTextWithErrors() KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".expected.kt")), resultText) diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt index 4f5c99bd37c..cf31cd857a5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt @@ -40,7 +40,7 @@ import java.io.File import kotlin.test.assertFalse import java.util.* -public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() { companion object { val ENTRY_POINT_ANNOTATION = "test.anno.EntryPoint" } @@ -49,11 +49,11 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest override fun setUp() { super.setUp() - EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.add(ENTRY_POINT_ANNOTATION) + EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(ENTRY_POINT_ANNOTATION) } override fun tearDown() { - EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.remove(ENTRY_POINT_ANNOTATION) + EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.remove(ENTRY_POINT_ANNOTATION) super.tearDown() } @@ -64,11 +64,11 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest val inspectionClass = Class.forName(InTextDirectivesUtils.findStringWithPrefixes(options, "// INSPECTION_CLASS: ")!!) val toolWrapper = LocalInspectionToolWrapper(inspectionClass.newInstance() as LocalInspectionTool) - val inspectionsTestDir = optionsFile.getParentFile()!! - val srcDir = inspectionsTestDir.getParentFile()!! + val inspectionsTestDir = optionsFile.parentFile!! + val srcDir = inspectionsTestDir.parentFile!! with(myFixture) { - setTestDataPath("${KotlinTestUtils.getHomeDirectory()}/$srcDir") + testDataPath = "${KotlinTestUtils.getHomeDirectory()}/$srcDir" val afterFiles = srcDir.listFiles { it -> it.name == "inspectionData" }?.single()?.listFiles { it -> it.extension == "after" } ?: emptyArray() val psiFiles = srcDir.walkTopDown().onEnter { it.name != "inspectionData" }.mapNotNull { @@ -93,8 +93,8 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest val isJs = srcDir.endsWith("js") - val isWithRuntime = psiFiles.any { InTextDirectivesUtils.findStringWithPrefixes(it.getText(), "// WITH_RUNTIME") != null } - val fullJdk = psiFiles.any { InTextDirectivesUtils.findStringWithPrefixes(it.getText(), "// FULL_JDK") != null } + val isWithRuntime = psiFiles.any { InTextDirectivesUtils.findStringWithPrefixes(it.text, "// WITH_RUNTIME") != null } + val fullJdk = psiFiles.any { InTextDirectivesUtils.findStringWithPrefixes(it.text, "// FULL_JDK") != null } if (isJs) { assertFalse(isWithRuntime) @@ -103,23 +103,23 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest try { if (isJs) { - ConfigLibraryUtil.configureKotlinJsRuntime(myFixture.getModule()) + ConfigLibraryUtil.configureKotlinJsRuntime(myFixture.module) } if (isWithRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk( - myFixture.getModule(), + myFixture.module, if (fullJdk) PluginTestCaseBase.fullJdk() else PluginTestCaseBase.mockJdk() ) } - val scope = AnalysisScope(getProject(), psiFiles.map { it.getVirtualFile()!! }) + val scope = AnalysisScope(project, psiFiles.map { it.virtualFile!! }) scope.invalidate() - val inspectionManager = (InspectionManager.getInstance(getProject()) as InspectionManagerEx) - val globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, toolWrapper) + val inspectionManager = (InspectionManager.getInstance(project) as InspectionManagerEx) + val globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, project, inspectionManager, toolWrapper) InspectionTestUtil.runTool(toolWrapper, scope, globalContext) - InspectionTestUtil.compareToolResults(globalContext, toolWrapper, false, inspectionsTestDir.getPath()) + InspectionTestUtil.compareToolResults(globalContext, toolWrapper, false, inspectionsTestDir.path) if (afterFiles.isNotEmpty()) { globalContext.getPresentation(toolWrapper).problemDescriptors.forEach { @@ -140,10 +140,10 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest } finally { if (isWithRuntime) { - ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(myFixture.getModule(), IdeaTestUtil.getMockJdk17()) + ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(myFixture.module, IdeaTestUtil.getMockJdk17()) } if (isJs) { - ConfigLibraryUtil.unConfigureKotlinJsRuntimeAndSdk(myFixture.getModule(), IdeaTestUtil.getMockJdk17()) + ConfigLibraryUtil.unConfigureKotlinJsRuntimeAndSdk(myFixture.module, IdeaTestUtil.getMockJdk17()) } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt index 28f7dedff24..38901420880 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.idea.test.KotlinMultiFileTestCase import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import java.io.File -public abstract class AbstractMultiFileInspectionTest : KotlinMultiFileTestCase() { +abstract class AbstractMultiFileInspectionTest : KotlinMultiFileTestCase() { init { myDoCompare = false } @@ -43,18 +43,18 @@ public abstract class AbstractMultiFileInspectionTest : KotlinMultiFileTestCase( val config = JsonParser().parse(FileUtil.loadFile(configFile, true)) as JsonObject val inspection = LocalInspectionToolWrapper(Class.forName(config.getString("inspectionClass")).newInstance() as LocalInspectionTool) - val withRuntime = config["withRuntime"]?.getAsBoolean() ?: false + val withRuntime = config["withRuntime"]?.asBoolean ?: false if (withRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk()) } - val withFullJdk = config["withFullJdk"]?.getAsBoolean() ?: false + val withFullJdk = config["withFullJdk"]?.asBoolean ?: false doTest({ rootDir, rootAfter -> try { if (withRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk( - getModule(), + module, if (withFullJdk) PluginTestCaseBase.fullJdk() else PluginTestCaseBase.mockJdk() ) } @@ -70,11 +70,11 @@ public abstract class AbstractMultiFileInspectionTest : KotlinMultiFileTestCase( ) InspectionTestUtil.runTool(inspection, scope, globalContext) - InspectionTestUtil.compareToolResults(globalContext, inspection, false, configFile.getParent()) + InspectionTestUtil.compareToolResults(globalContext, inspection, false, configFile.parent) } finally { if (withRuntime) { - ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(getModule(), IdeaTestUtil.getMockJdk17()) + ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(module, IdeaTestUtil.getMockJdk17()) } } }, @@ -86,11 +86,11 @@ public abstract class AbstractMultiFileInspectionTest : KotlinMultiFileTestCase( return testName.substring(0, testName.lastIndexOf('_')).replace('_', '/') } - protected override fun getTestRoot() : String { + override fun getTestRoot() : String { return "/multiFileInspections/" } - protected override fun getTestDataPath() : String { + override fun getTestDataPath() : String { return PluginTestCaseBase.getTestDataPathBase() } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOverrideImplementTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOverrideImplementTest.kt index 1e5395e1036..65c3dc5a39d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOverrideImplementTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOverrideImplementTest.kt @@ -46,7 +46,7 @@ import org.junit.Assert import java.io.File import kotlin.test.assertEquals -public abstract class AbstractOverrideImplementTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractOverrideImplementTest : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor(): LightProjectDescriptor = KotlinLightProjectDescriptor.INSTANCE protected fun doImplementFileTest(memberToOverride: String? = null) { @@ -165,7 +165,7 @@ public abstract class AbstractOverrideImplementTest : KotlinLightCodeInsightFixt } private fun generateImplementation(method: PsiMethod) { - getProject().executeWriteCommand("") { + project.executeWriteCommand("") { val aClass = (myFixture.file as PsiClassOwner).classes[0] val methodMember = PsiMethodMember(method, PsiSubstitutor.EMPTY) diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementTest.kt index b58d5c52cf2..192c1a9dd07 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementTest.kt @@ -18,217 +18,217 @@ package org.jetbrains.kotlin.idea.codeInsight import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -public class OverrideImplementTest : AbstractOverrideImplementTest() { +class OverrideImplementTest : AbstractOverrideImplementTest() { override fun setUp() { super.setUp() myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/codeInsight/overrideImplement" } - public fun testEmptyClassBodyFunctionMethod() { + fun testEmptyClassBodyFunctionMethod() { doImplementFileTest() } - public fun testFunctionMethod() { + fun testFunctionMethod() { doImplementFileTest() } - public fun testFunctionProperty() { + fun testFunctionProperty() { doImplementFileTest() } - public fun testFunctionWithTypeParameters() { + fun testFunctionWithTypeParameters() { doImplementFileTest() } - public fun testGenericTypesSeveralMethods() { + fun testGenericTypesSeveralMethods() { doImplementFileTest() } - public fun testJavaInterfaceMethod() { + fun testJavaInterfaceMethod() { doImplementDirectoryTest() } - public fun testJavaParameters() { + fun testJavaParameters() { doImplementDirectoryTest() } - public fun testFunctionFromTraitInJava() { + fun testFunctionFromTraitInJava() { doImplementJavaDirectoryTest("foo.KotlinTrait", "bar") } - public fun testGenericMethod() { + fun testGenericMethod() { doImplementFileTest() } - public fun testImplementJavaRawSubclass() { + fun testImplementJavaRawSubclass() { doImplementDirectoryTest() } - public fun testProperty() { + fun testProperty() { doImplementFileTest() } - public fun testTraitGenericImplement() { + fun testTraitGenericImplement() { doImplementFileTest() } - public fun testDefaultValues() { + fun testDefaultValues() { doImplementFileTest() } - public fun testRespectCaretPosition() { + fun testRespectCaretPosition() { doMultiImplementFileTest() } - public fun testGenerateMulti() { + fun testGenerateMulti() { doMultiImplementFileTest() } - public fun testTraitNullableFunction() { + fun testTraitNullableFunction() { doImplementFileTest() } - public fun testOverrideUnitFunction() { + fun testOverrideUnitFunction() { doOverrideFileTest() } - public fun testOverrideNonUnitFunction() { + fun testOverrideNonUnitFunction() { doOverrideFileTest() } - public fun testOverrideFunctionProperty() { + fun testOverrideFunctionProperty() { doOverrideFileTest() } - public fun testOverridePrimitiveProperty() { + fun testOverridePrimitiveProperty() { doMultiImplementFileTest() } - public fun testOverrideGenericFunction() { + fun testOverrideGenericFunction() { doOverrideFileTest() } - public fun testMultiOverride() { + fun testMultiOverride() { doMultiOverrideFileTest() } - public fun testDelegatedMembers() { + fun testDelegatedMembers() { doMultiOverrideFileTest() } - public fun testOverrideExplicitFunction() { + fun testOverrideExplicitFunction() { doOverrideFileTest() } - public fun testOverrideExtensionProperty() { + fun testOverrideExtensionProperty() { doOverrideFileTest() } - public fun testOverrideMutableExtensionProperty() { + fun testOverrideMutableExtensionProperty() { doOverrideFileTest() } - public fun testComplexMultiOverride() { + fun testComplexMultiOverride() { doMultiOverrideFileTest() } - public fun testOverrideRespectCaretPosition() { + fun testOverrideRespectCaretPosition() { doMultiOverrideFileTest() } - public fun testOverrideJavaMethod() { + fun testOverrideJavaMethod() { doOverrideDirectoryTest("getAnswer") } - public fun testJavaMethodWithPackageVisibility() { + fun testJavaMethodWithPackageVisibility() { doOverrideDirectoryTest("getFooBar") } - public fun testJavaMethodWithPackageProtectedVisibility() { + fun testJavaMethodWithPackageProtectedVisibility() { doOverrideDirectoryTest("getFooBar") } - public fun testPrivateJavaMethod() { + fun testPrivateJavaMethod() { doMultiOverrideDirectoryTest() } - public fun testImplementSamAdapters() { + fun testImplementSamAdapters() { doImplementDirectoryTest() } - public fun testOverrideFromFunctionPosition() { + fun testOverrideFromFunctionPosition() { doMultiOverrideFileTest() } - public fun testOverrideFromClassName() { + fun testOverrideFromClassName() { doMultiOverrideFileTest() } - public fun testOverrideFromLBrace() { + fun testOverrideFromLBrace() { doMultiOverrideFileTest() } - public fun testOverrideSamAdapters() { + fun testOverrideSamAdapters() { doOverrideDirectoryTest("foo") } - public fun testSameTypeName() { + fun testSameTypeName() { doOverrideDirectoryTest() } - public fun testPropagationKJK() { + fun testPropagationKJK() { doOverrideDirectoryTest() } - public fun testMultipleSupers() { + fun testMultipleSupers() { doMultiOverrideFileTest() } - public fun testNoAnyMembersInInterface() { + fun testNoAnyMembersInInterface() { doMultiOverrideFileTest() } - public fun testLocalClass() { + fun testLocalClass() { doImplementFileTest() } - public fun testStarProjections() { + fun testStarProjections() { doImplementFileTest() } - public fun testEscapeIdentifiers() { + fun testEscapeIdentifiers() { doOverrideFileTest() } - public fun testVarArgs() { + fun testVarArgs() { doOverrideFileTest() } - public fun testDoNotOverrideFinal() { + fun testDoNotOverrideFinal() { doMultiOverrideFileTest() } - public fun testSuperPreference() { + fun testSuperPreference() { doMultiOverrideFileTest() } - public fun testAmbiguousSuper() { + fun testAmbiguousSuper() { doMultiOverrideFileTest() } - public fun testImplementFunctionType() { + fun testImplementFunctionType() { doMultiImplementFileTest() } - public fun testQualifySuperType() { + fun testQualifySuperType() { doOverrideFileTest("f") } - public fun testGenericSuperClass() { + fun testGenericSuperClass() { doOverrideFileTest("iterator") } - public fun testDuplicatedAnyMembersBug() { + fun testDuplicatedAnyMembersBug() { doMultiOverrideFileTest() } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementWithLibTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementWithLibTest.kt index af2e6116d03..75f48d30394 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementWithLibTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OverrideImplementWithLibTest.kt @@ -20,7 +20,7 @@ import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -public class OverrideImplementWithLibTest : AbstractOverrideImplementTest() { +class OverrideImplementWithLibTest : AbstractOverrideImplementTest() { private val TEST_PATH = PluginTestCaseBase.getTestDataPathBase() + "/codeInsight/overrideImplement/withLib" override fun setUp() { @@ -30,11 +30,11 @@ public class OverrideImplementWithLibTest : AbstractOverrideImplementTest() { override fun getProjectDescriptor() = JdkAndMockLibraryProjectDescriptor(TEST_PATH + "/" + getTestName(true) + "Src", false) - public fun testFakeOverride() { + fun testFakeOverride() { doOverrideFileTest() } - public fun testGenericSubstituted() { + fun testGenericSubstituted() { doOverrideFileTest() } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/console/KotlinReplTest.kt b/idea/tests/org/jetbrains/kotlin/idea/console/KotlinReplTest.kt index 91b5121d2aa..9ebf1065c1a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/console/KotlinReplTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/console/KotlinReplTest.kt @@ -28,8 +28,7 @@ import kotlin.properties.Delegates import kotlin.test.assertFalse import kotlin.test.assertTrue -@FixMethodOrder(MethodSorters.JVM) -public class KotlinReplTest : PlatformTestCase() { +@FixMethodOrder(MethodSorters.JVM) class KotlinReplTest : PlatformTestCase() { private var consoleRunner: KotlinConsoleRunner by Delegates.notNull() private var commandsSent = 0 diff --git a/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/AbstractJavaToKotlinCopyPasteConversionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/AbstractJavaToKotlinCopyPasteConversionTest.kt index f4d446e8d08..7b214c9ba7d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/AbstractJavaToKotlinCopyPasteConversionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/conversion/copy/AbstractJavaToKotlinCopyPasteConversionTest.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File import kotlin.test.assertEquals -public abstract class AbstractJavaToKotlinCopyPasteConversionTest : AbstractCopyPasteTest() { +abstract class AbstractJavaToKotlinCopyPasteConversionTest : AbstractCopyPasteTest() { private val BASE_PATH = PluginTestCaseBase.getTestDataPathBase() + "/copyPaste/conversion" private var oldEditorOptions: KotlinEditorOptions? = null @@ -37,9 +37,9 @@ public abstract class AbstractJavaToKotlinCopyPasteConversionTest : AbstractCopy override fun setUp() { super.setUp() - oldEditorOptions = KotlinEditorOptions.getInstance().getState() - KotlinEditorOptions.getInstance().setEnableJavaToKotlinConversion(true) - KotlinEditorOptions.getInstance().setDonTShowConversionDialog(true) + oldEditorOptions = KotlinEditorOptions.getInstance().state + KotlinEditorOptions.getInstance().isEnableJavaToKotlinConversion = true + KotlinEditorOptions.getInstance().isDonTShowConversionDialog = true } override fun tearDown() { @@ -47,12 +47,12 @@ public abstract class AbstractJavaToKotlinCopyPasteConversionTest : AbstractCopy super.tearDown() } - public fun doTest(path: String) { - myFixture.setTestDataPath(BASE_PATH) + fun doTest(path: String) { + myFixture.testDataPath = BASE_PATH val testName = getTestName(false) myFixture.configureByFiles(testName + ".java") - val fileText = myFixture.getEditor().getDocument().getText() + val fileText = myFixture.editor.document.text val noConversionExpected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// NO_CONVERSION_EXPECTED").isNotEmpty() myFixture.performEditorAction(IdeActions.ACTION_COPY) @@ -69,6 +69,6 @@ public abstract class AbstractJavaToKotlinCopyPasteConversionTest : AbstractCopy assertEquals(noConversionExpected, !ConvertJavaCopyPastePostProcessor.conversionPerformed, if (noConversionExpected) "Conversion to Kotlin should not be suggested" else "No conversion to Kotlin suggested") - KotlinTestUtils.assertEqualsToFile(File(path.replace(".java", ".expected.kt")), myFixture.getFile().getText()) + KotlinTestUtils.assertEqualsToFile(File(path.replace(".java", ".expected.kt")), myFixture.file.text) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/coverage/AbstractKotlinCoverageOutputFilesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/coverage/AbstractKotlinCoverageOutputFilesTest.kt index 338f123b5ef..10e7266e7ba 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/coverage/AbstractKotlinCoverageOutputFilesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/coverage/AbstractKotlinCoverageOutputFilesTest.kt @@ -25,14 +25,14 @@ import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.idea.util.application.runWriteAction -public abstract class AbstractKotlinCoverageOutputFilesTest(): KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractKotlinCoverageOutputFilesTest(): KotlinLightCodeInsightFixtureTestCase() { private val TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/coverage/outputFiles" override fun getTestDataPath(): String? = TEST_DATA_PATH - public fun doTest(path: String) { + fun doTest(path: String) { val kotlinFile = myFixture.configureByFile(path) as KtFile - val outDir = myFixture.getTempDirFixture().findOrCreateDir("coverageTestOut") + val outDir = myFixture.tempDirFixture.findOrCreateDir("coverageTestOut") try { FileUtil.loadLines(File(path.replace(".kt", ".classes.txt"))).forEach { runWriteAction { diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt index 91221f6ceb1..1101546798b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.test.InTextDirectivesUtils import java.io.File -public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() { +abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() { protected fun doStepIntoTest(path: String) { doTest(path, "STEP_INTO") } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractSmartStepIntoTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractSmartStepIntoTest.kt index 05a0b18d7fd..5249b58276c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractSmartStepIntoTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractSmartStepIntoTest.kt @@ -23,21 +23,21 @@ import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescrip import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.test.InTextDirectivesUtils -public abstract class AbstractSmartStepIntoTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractSmartStepIntoTest : KotlinLightCodeInsightFixtureTestCase() { private val fixture: JavaCodeInsightTestFixture get() = myFixture protected fun doTest(path: String) { fixture.configureByFile(path) - val offset = fixture.getCaretOffset() - val line = fixture.getDocument(fixture.getFile()!!)!!.getLineNumber(offset) + val offset = fixture.caretOffset + val line = fixture.getDocument(fixture.file!!)!!.getLineNumber(offset) - val position = MockSourcePosition(_file = fixture.getFile(), _line = line, _offset = offset, _editor = fixture.getEditor()) + val position = MockSourcePosition(_file = fixture.file, _line = line, _offset = offset, _editor = fixture.editor) - val actual = KotlinSmartStepIntoHandler().findSmartStepTargets(position).map { it.getPresentation() } + val actual = KotlinSmartStepIntoHandler().findSmartStepTargets(position).map { it.presentation } - val expected = InTextDirectivesUtils.findListWithPrefixes(fixture.getFile()?.getText()!!.replace("\\,", "+++"), "// EXISTS: ").map { it.replace("+++", ",") } + val expected = InTextDirectivesUtils.findListWithPrefixes(fixture.file?.text!!.replace("\\,", "+++"), "// EXISTS: ").map { it.replace("+++", ",") } for (actualTargetName in actual) { assert(actualTargetName in expected) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt index 4ca35d8d229..67855076eb7 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt @@ -116,9 +116,9 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { } protected val dp: DebugProcessImpl - get() = getDebugProcess() ?: throw AssertionError("createLocalProcess() should be called before getDebugProcess()") + get() = debugProcess ?: throw AssertionError("createLocalProcess() should be called before getDebugProcess()") - public fun doOnBreakpoint(action: SuspendContextImpl.() -> Unit) { + fun doOnBreakpoint(action: SuspendContextImpl.() -> Unit) { super.onBreakpoint(SuspendContextRunnable { try { initContexts(it) @@ -141,7 +141,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { } protected fun SuspendContextImpl.doStepInto(ignoreFilters: Boolean, smartStepFilter: MethodFilter?) { - dp.getManagerThread()!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, smartStepFilter)) + dp.managerThread!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, smartStepFilter)) } protected fun SuspendContextImpl.doStepOut() { @@ -190,12 +190,12 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { val filters = createSmartStepIntoFilters() if (chooseFromList == 0) { filters.forEach { - dp.getManagerThread()!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, it)) + dp.managerThread!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, it)) } } else { try { - dp.getManagerThread()!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, filters.get(chooseFromList - 1))) + dp.managerThread!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, filters.get(chooseFromList - 1))) } catch(e: IndexOutOfBoundsException) { throw AssertionError("Couldn't find smart step into command at: \n" + @@ -220,7 +220,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { when (stepTarget) { is KotlinLambdaSmartStepTarget -> KotlinLambdaMethodFilter(stepTarget.getLambda(), stepTarget.getCallingExpressionLines()!!, stepTarget.isInline) is KotlinMethodSmartStepTarget -> KotlinBasicStepMethodFilter(stepTarget.resolvedElement, stepTarget.getCallingExpressionLines()!!) - is MethodSmartStepTarget -> BasicStepMethodFilter(stepTarget.getMethod(), stepTarget.getCallingExpressionLines()) + is MethodSmartStepTarget -> BasicStepMethodFilter(stepTarget.method, stepTarget.getCallingExpressionLines()) else -> null } } @@ -229,7 +229,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { protected fun SuspendContextImpl.printContext() { runReadAction { - if (this.getFrameProxy() == null) { + if (this.frameProxy == null) { return@runReadAction println("Context thread is null", ProcessOutputTypes.SYSTEM) } @@ -243,18 +243,18 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { return "null" } - val virtualFile = sourcePosition.getFile().getVirtualFile() + val virtualFile = sourcePosition.file.virtualFile if (virtualFile == null) { return "VirtualFile for position is null" } - val libraryEntry = LibraryUtil.findLibraryEntry(virtualFile, getProject()) + val libraryEntry = LibraryUtil.findLibraryEntry(virtualFile, project) if (libraryEntry != null && (libraryEntry is JdkOrderEntry || - libraryEntry.getPresentableName() == KOTLIN_LIBRARY_NAME)) { - return FileUtil.getNameWithoutExtension(virtualFile.getName()) + ".!EXT!" + libraryEntry.presentableName == KOTLIN_LIBRARY_NAME)) { + return FileUtil.getNameWithoutExtension(virtualFile.name) + ".!EXT!" } - return virtualFile.getName() + ":" + (sourcePosition.getLine() + 1) + return virtualFile.name + ":" + (sourcePosition.line + 1) } protected fun finish() { @@ -267,14 +267,14 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { if (file == null) return val document = runReadAction { PsiDocumentManager.getInstance(myProject).getDocument(file) } ?: return - val breakpointManager = XDebuggerManager.getInstance(myProject).getBreakpointManager() + val breakpointManager = XDebuggerManager.getInstance(myProject).breakpointManager val kotlinFieldBreakpointType = findBreakpointType(KotlinFieldBreakpointType::class.java) - val virtualFile = file.getVirtualFile() + val virtualFile = file.virtualFile val runnable = { var offset = -1; while (true) { - val fileText = document.getText() + val fileText = document.text offset = fileText.indexOf("point!", offset + 1) if (offset == -1) break @@ -402,10 +402,10 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { } private fun createBreakpoint(fileName: String, lineMarker: String, ordinal: Int?) { - val project = getProject()!! + val project = project!! val sourceFiles = runReadAction { FilenameIndex.getAllFilesByExt(project, "kt").filter { - it.getName().contains(fileName) && + it.name.contains(fileName) && it.contentsToByteArray().toString("UTF-8").contains(lineMarker) } } @@ -415,10 +415,10 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { val runnable = Runnable() { val psiSourceFile = PsiManager.getInstance(project).findFile(sourceFiles.first())!! - val breakpointManager = XDebuggerManager.getInstance(myProject).getBreakpointManager() + val breakpointManager = XDebuggerManager.getInstance(myProject).breakpointManager val document = PsiDocumentManager.getInstance(project).getDocument(psiSourceFile)!! - val index = psiSourceFile.getText()!!.indexOf(lineMarker) + val index = psiSourceFile.text!!.indexOf(lineMarker) val lineNumber = document.getLineNumber(index) + 1 // lineMarker is for previous line createLineBreakpoint(breakpointManager, psiSourceFile, lineNumber, ordinal, null) diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt index b291737fbaa..bdf293c99c1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt @@ -40,7 +40,7 @@ import java.io.File import kotlin.test.assertNull import kotlin.test.assertTrue -public abstract class AbstractCodeFragmentHighlightingTest : AbstractPsiCheckerTest() { +abstract class AbstractCodeFragmentHighlightingTest : AbstractPsiCheckerTest() { override fun doTest(filePath: String) { myFixture.configureByCodeFragment(filePath) myFixture.checkHighlighting(true, false, false) @@ -51,11 +51,11 @@ public abstract class AbstractCodeFragmentHighlightingTest : AbstractPsiCheckerT project.executeWriteCommand("Imports insertion") { val fileText = FileUtil.loadFile(File(filePath), true) - val file = myFixture.getFile() as KtFile + val file = myFixture.file as KtFile InTextDirectivesUtils.findListWithPrefixes(fileText, "// IMPORT: ").forEach { val descriptor = file.resolveImportReference(FqName(it)).singleOrNull() ?: error("Could not resolve descriptor to import: $it") - ImportInsertHelper.getInstance(getProject()).importDescriptor(file, descriptor) + ImportInsertHelper.getInstance(project).importDescriptor(file, descriptor) } } @@ -63,13 +63,13 @@ public abstract class AbstractCodeFragmentHighlightingTest : AbstractPsiCheckerT } } -public abstract class AbstractCodeFragmentCompletionTest : AbstractJvmBasicCompletionTest() { +abstract class AbstractCodeFragmentCompletionTest : AbstractJvmBasicCompletionTest() { override fun setUpFixture(testPath: String) { myFixture.configureByCodeFragment(testPath) } } -public abstract class AbstractCodeFragmentCompletionHandlerTest : AbstractCompletionHandlerTest(CompletionType.BASIC) { +abstract class AbstractCodeFragmentCompletionHandlerTest : AbstractCompletionHandlerTest(CompletionType.BASIC) { override fun setUpFixture(testPath: String) { myFixture.configureByCodeFragment(testPath) } @@ -77,12 +77,12 @@ public abstract class AbstractCodeFragmentCompletionHandlerTest : AbstractComple override fun doTest(testPath: String) { super.doTest(testPath) - val fragment = myFixture.getFile() as KtCodeFragment + val fragment = myFixture.file as KtCodeFragment fragment.checkImports(testPath) } } -public abstract class AbstractCodeFragmentAutoImportTest : AbstractPsiCheckerTest() { +abstract class AbstractCodeFragmentAutoImportTest : AbstractPsiCheckerTest() { override fun doTest(filePath: String) { myFixture.configureByCodeFragment(filePath) myFixture.doHighlighting() @@ -120,26 +120,26 @@ private fun KtCodeFragment.checkImports(testPath: String) { private fun JavaCodeInsightTestFixture.configureByCodeFragment(filePath: String) { configureByFile(filePath) - val elementAt = getFile()?.findElementAt(getCaretOffset()) + val elementAt = file?.findElementAt(caretOffset) val file = createCodeFragment(filePath, elementAt!!) - val typeStr = InTextDirectivesUtils.findStringWithPrefixes(getFile().getText(), "// ${ExpectedCompletionUtils.RUNTIME_TYPE} ") + val typeStr = InTextDirectivesUtils.findStringWithPrefixes(getFile().text, "// ${ExpectedCompletionUtils.RUNTIME_TYPE} ") if (typeStr != null) { file.putCopyableUserData(KtCodeFragment.RUNTIME_TYPE_EVALUATOR, { - val codeFragment = KtPsiFactory(getProject()).createBlockCodeFragment("val xxx: $typeStr" , PsiTreeUtil.getParentOfType(elementAt, KtElement::class.java)) + val codeFragment = KtPsiFactory(project).createBlockCodeFragment("val xxx: $typeStr", PsiTreeUtil.getParentOfType(elementAt, KtElement::class.java)) val context = codeFragment.analyzeFully() - val typeReference: KtTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().getFirstChild(), KtTypeReference::class.java)!! + val typeReference: KtTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().firstChild, KtTypeReference::class.java)!! context[BindingContext.TYPE, typeReference] }) } - configureFromExistingVirtualFile(file.getVirtualFile()!!) + configureFromExistingVirtualFile(file.virtualFile!!) } private fun createCodeFragment(filePath: String, contextElement: PsiElement): KtCodeFragment { val fileForFragment = File(filePath + ".fragment") val codeFragmentText = FileUtil.loadFile(fileForFragment, true).trim() - val psiFactory = KtPsiFactory(contextElement.getProject()) + val psiFactory = KtPsiFactory(contextElement.project) if (fileForFragment.readLines().size == 1) { return psiFactory.createExpressionCodeFragment( codeFragmentText, diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index 4018b78a061..ac06ae2aed0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -61,7 +61,7 @@ import java.io.File import java.util.* import javax.swing.tree.TreeNode -public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { +abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { private val logger = Logger.getLogger(KotlinEvaluateExpressionCache::class.java)!! private var appender: AppenderSkeleton? = null @@ -72,16 +72,16 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB override fun setUp() { super.setUp() - val classRenderer = NodeRendererSettings.getInstance()!!.getClassRenderer()!! + val classRenderer = NodeRendererSettings.getInstance()!!.classRenderer!! oldShowFqTypeNames = classRenderer.SHOW_FQ_TYPE_NAMES classRenderer.SHOW_FQ_TYPE_NAMES = true - oldLogLevel = logger.getLevel() - logger.setLevel(Level.DEBUG) + oldLogLevel = logger.level + logger.level = Level.DEBUG appender = object : AppenderSkeleton() { override fun append(event: LoggingEvent?) { - println(event?.getRenderedMessage(), ProcessOutputTypes.SYSTEM) + println(event?.renderedMessage, ProcessOutputTypes.SYSTEM) } override fun close() {} override fun requiresLayout() = false @@ -91,13 +91,13 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB } override fun tearDown() { - logger.setLevel(oldLogLevel) + logger.level = oldLogLevel logger.removeAppender(appender) appender = null oldLogLevel = null - NodeRendererSettings.getInstance()!!.getClassRenderer()!!.SHOW_FQ_TYPE_NAMES = oldShowFqTypeNames + NodeRendererSettings.getInstance()!!.classRenderer!!.SHOW_FQ_TYPE_NAMES = oldShowFqTypeNames super.tearDown() } @@ -223,7 +223,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB } fun getExtraVars(): Set { - return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext.getSourcePosition(), evaluationContext, hashSetOf()) + return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext.sourcePosition, evaluationContext, hashSetOf()) } private inner class Printer() { @@ -313,16 +313,16 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB } private fun findFilesWithBlocks(mainFile: File): List { - val mainFileName = mainFile.getName() - return mainFile.getParentFile()?.listFiles()?.filter { it.name.startsWith(mainFileName) && it.name != mainFileName } ?: Collections.emptyList() + val mainFileName = mainFile.name + return mainFile.parentFile?.listFiles()?.filter { it.name.startsWith(mainFileName) && it.name != mainFileName } ?: Collections.emptyList() } private fun createContextElement(context: SuspendContextImpl): PsiElement { val contextElement = ContextUtil.getContextElement(debuggerContext)!! - Assert.assertTrue("KotlinCodeFragmentFactory should be accepted for context element otherwise default evaluator will be called. ContextElement = ${contextElement.getText()}", + Assert.assertTrue("KotlinCodeFragmentFactory should be accepted for context element otherwise default evaluator will be called. ContextElement = ${contextElement.text}", KotlinCodeFragmentFactory().isContextAccepted(contextElement)) - val labelsAsText = InTextDirectivesUtils.findLinesWithPrefixesRemoved(contextElement.getContainingFile().getText(), "// DEBUG_LABEL: ") + val labelsAsText = InTextDirectivesUtils.findLinesWithPrefixesRemoved(contextElement.containingFile.text, "// DEBUG_LABEL: ") if (labelsAsText.isEmpty()) return contextElement val markupMap = hashMapOf() @@ -331,16 +331,16 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB assert(labelParts.size == 2) { "Wrong format for DEBUG_LABEL directive: // DEBUG_LABEL: {localVariableName} = {labelText}"} val localVariableName = labelParts[0].trim() val labelName = labelParts[1].trim() - val localVariable = context.getFrameProxy()!!.visibleVariableByName(localVariableName) + val localVariable = context.frameProxy!!.visibleVariableByName(localVariableName) assert(localVariable != null) { "Couldn't find localVariable for label: name = $localVariableName" } - val localVariableValue = context.getFrameProxy()!!.getValue(localVariable) + val localVariableValue = context.frameProxy!!.getValue(localVariable) assert(localVariableValue != null) { "Local variable $localVariableName should be an ObjectReference" } localVariableValue!! markupMap.put(localVariableValue, ValueMarkup(labelName, null, labelName)) } val (text, labels) = KotlinCodeFragmentFactory.createCodeFragmentForLabeledObjects(contextElement.project, markupMap) - return KotlinCodeFragmentFactory().createWrappingContext(text, labels, KotlinCodeFragmentFactory.getContextElement(contextElement), getProject())!! + return KotlinCodeFragmentFactory().createWrappingContext(text, labels, KotlinCodeFragmentFactory.getContextElement(contextElement), project)!! } private fun SuspendContextImpl.evaluate(text: String, codeFragmentKind: CodeFragmentKind, expectedResult: String) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractSelectExpressionForDebuggerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractSelectExpressionForDebuggerTest.kt index 27020e8e70b..d303c2e9b32 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractSelectExpressionForDebuggerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractSelectExpressionForDebuggerTest.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.junit.Assert -public abstract class AbstractSelectExpressionForDebuggerTest : LightCodeInsightFixtureTestCase() { +abstract class AbstractSelectExpressionForDebuggerTest : LightCodeInsightFixtureTestCase() { fun doTest(path: String) { doTest(path, true) @@ -35,12 +35,12 @@ public abstract class AbstractSelectExpressionForDebuggerTest : LightCodeInsight fun doTest(path: String, allowMethodCalls: Boolean) { myFixture.configureByFile(path) - val elementAt = myFixture.getFile()?.findElementAt(myFixture.getCaretOffset())!! + val elementAt = myFixture.file?.findElementAt(myFixture.caretOffset)!! val selectedExpression = KotlinEditorTextProvider.findExpressionInner(elementAt, allowMethodCalls) - val expected = InTextDirectivesUtils.findStringWithPrefixes(myFixture.getFile()?.getText()!!, "// EXPECTED: ") + val expected = InTextDirectivesUtils.findStringWithPrefixes(myFixture.file?.text!!, "// EXPECTED: ") val actualResult = if (selectedExpression != null) - KotlinEditorTextProvider.getElementInfo(selectedExpression) { it.getText() } + KotlinEditorTextProvider.getElementInfo(selectedExpression) { it.text } else "null" diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt index 61f82915521..bdb3a34f41b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt @@ -35,33 +35,33 @@ import java.io.File private val LIBRARY_SRC_PATH = KotlinTestUtils.getHomeDirectory() + "/idea/idea-completion/testData/codeFragmentInLibrarySource/customLibrary/" -public class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTest() { +class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTest() { override fun getProjectDescriptor() = object: JdkAndMockLibraryProjectDescriptor(LIBRARY_SRC_PATH, false) { override fun configureModule(module: Module, model: ModifiableRootModel) { super.configureModule(module, model) - val library = model.getModuleLibraryTable().getLibraryByName(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME)!! - val modifiableModel = library.getModifiableModel() + val library = model.moduleLibraryTable.getLibraryByName(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME)!! + val modifiableModel = library.modifiableModel modifiableModel.addRoot(findLibrarySourceDir(), OrderRootType.SOURCES) modifiableModel.commit() } } - public fun testCompletionInCustomLibrary() { + fun testCompletionInCustomLibrary() { testCompletionInLibraryCodeFragment("", "EXIST: parameter") } - public fun testSecondCompletionInCustomLibrary() { + fun testSecondCompletionInCustomLibrary() { testCompletionInLibraryCodeFragment("Sh", "EXIST: ShortRange", "EXIST: Short", "INVOCATION_COUNT: 2") } - public fun testExtensionCompletionInCustomLibrary() { + fun testExtensionCompletionInCustomLibrary() { testCompletionInLibraryCodeFragment("3.extOn", "EXIST: extOnInt") } - public fun testJavaTypesCompletion() { + fun testJavaTypesCompletion() { testCompletionInLibraryCodeFragment("Hash", "EXIST: HashMap", "EXIST: HashSet") } @@ -73,14 +73,14 @@ public class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTes private fun setupFixtureByCodeFragment(fragmentText: String) { val sourceFile = findLibrarySourceDir().findChild("customLibrary.kt")!! - val jetFile = PsiManager.getInstance(getProject()).findFile(sourceFile) as KtFile - val fooFunctionFromLibrary = jetFile.getDeclarations().first() as KtFunction + val jetFile = PsiManager.getInstance(project).findFile(sourceFile) as KtFile + val fooFunctionFromLibrary = jetFile.declarations.first() as KtFunction val codeFragment = KtPsiFactory(fooFunctionFromLibrary).createExpressionCodeFragment( fragmentText, - KotlinCodeFragmentFactory.getContextElement(fooFunctionFromLibrary.getBodyExpression()) + KotlinCodeFragmentFactory.getContextElement(fooFunctionFromLibrary.bodyExpression) ) codeFragment.forceResolveScope(GlobalSearchScope.allScope(project)) - myFixture.configureFromExistingVirtualFile(codeFragment.getVirtualFile()) + myFixture.configureFromExistingVirtualFile(codeFragment.virtualFile) } private fun findLibrarySourceDir(): VirtualFile { diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/AbstractInternalCompiledClassesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/AbstractInternalCompiledClassesTest.kt index 75eafc5e8d1..f6f89785fb2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/AbstractInternalCompiledClassesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/AbstractInternalCompiledClassesTest.kt @@ -24,9 +24,9 @@ import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.junit.Assert -public abstract class AbstractInternalCompiledClassesTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractInternalCompiledClassesTest : KotlinLightCodeInsightFixtureTestCase() { private fun isFileWithHeader(predicate: (KotlinClassHeader) -> Boolean) : VirtualFile.() -> Boolean = { - val header = KotlinBinaryClassCache.getKotlinBinaryClass(this)?.getClassHeader() + val header = KotlinBinaryClassCache.getKotlinBinaryClass(this)?.classHeader header != null && predicate(header) } @@ -40,10 +40,10 @@ public abstract class AbstractInternalCompiledClassesTest : KotlinLightCodeInsig doTestNoPsiFilesAreBuiltFor("synthetic", isSyntheticClass()) protected fun doTestNoPsiFilesAreBuiltFor(fileKind: String, acceptFile: VirtualFile.() -> Boolean) { - val project = getProject() + val project = project doTest(fileKind, acceptFile) { val psiFile = PsiManager.getInstance(project).findFile(this) - Assert.assertNull("PSI files for $fileKind classes should not be build, is was build for: ${this.getPresentableName()}", + Assert.assertNull("PSI files for $fileKind classes should not be build, is was build for: ${this.presentableName}", psiFile) } } @@ -63,11 +63,11 @@ public abstract class AbstractInternalCompiledClassesTest : KotlinLightCodeInsig } protected fun VirtualFile.checkRecursively(body: VirtualFile.() -> Unit) { - if (!isDirectory()) { + if (!isDirectory) { body() } else { - for (file in getChildren()!!) { + for (file in children!!) { file.checkRecursively(body) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/InternalCompiledClassesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/InternalCompiledClassesTest.kt index 5c372773f05..75ca611d4ed 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/InternalCompiledClassesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/InternalCompiledClassesTest.kt @@ -21,7 +21,7 @@ import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -public class InternalCompiledClassesTest : AbstractInternalCompiledClassesTest() { +class InternalCompiledClassesTest : AbstractInternalCompiledClassesTest() { private val TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/decompiler/internalClasses" fun testSyntheticClassesAreInvisible() = doTestNoPsiFilesAreBuiltForSyntheticClasses() diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt index 0705e431e64..acf9c2af6da 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File import java.util.LinkedHashMap -public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTestCase() { +abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTestCase() { protected fun doTest(path: String): Unit = doTestEx(path) @@ -40,7 +40,7 @@ public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTes protected fun doTestEx(path: String, additionalConfig: (() -> Unit)? = null) { configureByFile(path) - getModule().configureAs(getProjectDescriptor()) + module.configureAs(getProjectDescriptor()) if (additionalConfig != null) { additionalConfig() @@ -60,19 +60,19 @@ public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTes private fun checkAnnotatedLibraryCode(forceResolve: Boolean) { SourceNavigationHelper.setForceResolve(forceResolve) - val actualCode = NavigationTestUtils.getNavigateElementsText(getProject(), collectInterestingNavigationElements()) + val actualCode = NavigationTestUtils.getNavigateElementsText(project, collectInterestingNavigationElements()) val expectedCode = getExpectedAnnotatedLibraryCode() UsefulTestCase.assertSameLines(expectedCode, actualCode) } private fun collectInterestingReferences(): Collection { - val psiFile = getFile() + val psiFile = file val referenceContainersToReferences = LinkedHashMap() - for (offset in 0..psiFile.getTextLength() - 1) { + for (offset in 0..psiFile.textLength - 1) { val ref = psiFile.findReferenceAt(offset) val refs = when (ref) { is KtReference -> listOf(ref) - is PsiMultiReference -> ref.getReferences().filterIsInstance() + is PsiMultiReference -> ref.references.filterIsInstance() else -> emptyList() } @@ -82,15 +82,15 @@ public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTes } private fun MutableMap.addReference(ref: KtReference) { - if (containsKey(ref.getElement())) return + if (containsKey(ref.element)) return val target = ref.resolve() ?: return - val targetNavPsiFile = target.getNavigationElement().getContainingFile() ?: return + val targetNavPsiFile = target.navigationElement.containingFile ?: return - val targetNavFile = targetNavPsiFile.getVirtualFile() ?: return + val targetNavFile = targetNavPsiFile.virtualFile ?: return - if (ProjectFileIndex.SERVICE.getInstance(getProject()).isInLibrarySource(targetNavFile)) { - put(ref.getElement(), ref) + if (ProjectFileIndex.SERVICE.getInstance(project).isInLibrarySource(targetNavFile)) { + put(ref.element, ref) } } @@ -98,11 +98,11 @@ public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTes collectInterestingReferences().map { val target = it.resolve() TestCase.assertNotNull(target) - target!!.getNavigationElement() + target!!.navigationElement } private fun getExpectedAnnotatedLibraryCode(): String { - val document = getDocument(getFile()) + val document = getDocument(file) TestCase.assertNotNull(document) return KotlinTestUtils.getLastCommentedLines(document) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt index d1a4ad35a55..8bf2005d02d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt @@ -35,27 +35,27 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.test.fail -public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() { - public fun testJdkClass() { +class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() { + fun testJdkClass() { checkNavigationFromLibrarySource("Thread", "java.lang.Thread") } - public fun testOurKotlinClass() { + fun testOurKotlinClass() { checkNavigationFromLibrarySource("Foo", "a.Foo") } - public fun testBuiltinClass() { + fun testBuiltinClass() { checkNavigationFromLibrarySource("String", "kotlin.String") } // This test is not exactly for navigation, but separating it to another class doesn't worth it. - public fun testLightClassForLibrarySource() { + fun testLightClassForLibrarySource() { val navigationElement = navigationElementForReferenceInLibrarySource("Foo") assertTrue(navigationElement is KtClassOrObject, "Foo should navigate to JetClassOrObject") val lightClass = LightClassUtil.getPsiClass(navigationElement as KtClassOrObject) assertTrue(lightClass is KtLightClassForDecompiledDeclaration, "Light classes for decompiled declaration should be provided for library source") - assertEquals("Foo", lightClass!!.getName()) + assertEquals("Foo", lightClass!!.name) } private fun checkNavigationFromLibrarySource(referenceText: String, targetFqName: String) { @@ -63,13 +63,13 @@ public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() { } private fun navigationElementForReferenceInLibrarySource(referenceText: String): PsiElement { - val libraryOrderEntry = ModuleRootManager.getInstance(myModule!!).getOrderEntries().first { it is LibraryOrderEntry } + val libraryOrderEntry = ModuleRootManager.getInstance(myModule!!).orderEntries.first { it is LibraryOrderEntry } val libSourcesRoot = libraryOrderEntry.getUrls(OrderRootType.SOURCES)[0] val vf = VirtualFileManager.getInstance().findFileByUrl(libSourcesRoot + "/usage.kt")!! - val psiFile = getPsiManager().findFile(vf)!! - val indexOf = psiFile.getText()!!.indexOf(referenceText) + val psiFile = psiManager.findFile(vf)!! + val indexOf = psiFile.text!!.indexOf(referenceText) val reference = psiFile.findReferenceAt(indexOf) - return reference.sure { "Couldn't find reference" }.resolve().sure { "Couldn't resolve reference" }.getNavigationElement()!! + return reference.sure { "Couldn't find reference" }.resolve().sure { "Couldn't resolve reference" }.navigationElement!! } override fun getProjectDescriptor(): LightProjectDescriptor { @@ -79,13 +79,13 @@ public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() { private fun checkNavigationElement(element: PsiElement, expectedFqName: String) { when (element) { is PsiClass -> { - assertEquals(expectedFqName, element.getQualifiedName()) + assertEquals(expectedFqName, element.qualifiedName) } is KtClass -> { - assertEquals(expectedFqName, element.getFqName()!!.asString()) + assertEquals(expectedFqName, element.fqName!!.asString()) } else -> { - fail("Navigation element should be JetClass or PsiClass: " + element.javaClass + ", " + element.getText()) + fail("Navigation element should be JetClass or PsiClass: " + element.javaClass + ", " + element.text) } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToStdlibSourceTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToStdlibSourceTest.kt index b6e84194e7e..3c7d079a661 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToStdlibSourceTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToStdlibSourceTest.kt @@ -24,29 +24,29 @@ import org.jetbrains.kotlin.idea.test.ModuleKind import org.jetbrains.kotlin.idea.test.closeAndDeleteProject import org.jetbrains.kotlin.idea.test.configureAs -public class NavigateToStdlibSourceTest : KotlinCodeInsightTestCase() { +class NavigateToStdlibSourceTest : KotlinCodeInsightTestCase() { private val FILE_TEXT = "fun foo() { println() }" - public fun testRefToPrintlnWithJVM() { + fun testRefToPrintlnWithJVM() { doTest("Console.kt", ModuleKind.KOTLIN_JVM_WITH_STDLIB_SOURCES) } - public fun testRefToPrintlnWithJVMAndJS() { + fun testRefToPrintlnWithJVMAndJS() { doTest("Console.kt", ModuleKind.KOTLIN_JVM_WITH_STDLIB_SOURCES, ModuleKind.KOTLIN_JAVASCRIPT) } - public fun testRefToPrintlnWithJS() { + fun testRefToPrintlnWithJS() { doTest("core.kt", ModuleKind.KOTLIN_JAVASCRIPT) } - public fun testRefToPrintlnWithJSAndJVM() { + fun testRefToPrintlnWithJSAndJVM() { doTest("core.kt", ModuleKind.KOTLIN_JAVASCRIPT, ModuleKind.KOTLIN_JVM_WITH_STDLIB_SOURCES) } private fun doTest(sourceFileName: String, mainModule: ModuleKind, additionalModule: ModuleKind? = null) { val navigationElement = configureAndResolve(FILE_TEXT, mainModule, additionalModule) - TestCase.assertEquals(sourceFileName, navigationElement.getContainingFile().getName()) + TestCase.assertEquals(sourceFileName, navigationElement.containingFile.name) } override fun tearDown() { @@ -63,14 +63,14 @@ public class NavigateToStdlibSourceTest : KotlinCodeInsightTestCase() { additionalModuleKind: ModuleKind? = null ): PsiElement { configureByText(KotlinFileType.INSTANCE, text) - getModule().configureAs(mainModuleKind) + module.configureAs(mainModuleKind) if (additionalModuleKind != null) { val additionalModule = this.createModule("additional-module") additionalModule.configureAs(additionalModuleKind) } - val ref = getFile().findReferenceAt(getEditor().getCaretModel().getOffset()) - return ref!!.resolve()!!.getNavigationElement() + val ref = file.findReferenceAt(editor.caretModel.offset) + return ref!!.resolve()!!.navigationElement } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt index 0c36c2c4672..35fb2533de5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt @@ -34,7 +34,7 @@ import org.junit.Assert import java.io.File import java.util.* -public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCase() { +abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCase() { fun doTest(sourcePath: String) { val classFile = getClassFileToDecompile(sourcePath) val txtFilePath = File("$sourcePath/${lastSegment(sourcePath)}.txt") @@ -44,7 +44,7 @@ public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCa protected fun testClsStubsForFile(classFile: VirtualFile, txtFile: File?) { val stubTreeFromCls = KotlinClsStubBuilder().buildFileStub(FileContentImpl.createByFile(classFile))!! myFixture.configureFromExistingVirtualFile(classFile) - val psiFile = myFixture.getFile() + val psiFile = myFixture.file val stubTreeFromDecompiledText = KtFileStubBuilder().buildStubTree(psiFile) val expectedText = stubTreeFromDecompiledText.serializeToString() Assert.assertEquals(expectedText, stubTreeFromCls.serializeToString()) @@ -73,8 +73,8 @@ fun VirtualFile.findClassFileByName(className: String): VirtualFile { val files = LinkedHashSet() VfsUtilCore.iterateChildrenRecursively( this, - { virtualFile -> virtualFile.isDirectory() || virtualFile.getName().equals("$className.class") }, - { virtualFile -> if (!virtualFile.isDirectory()) files.addIfNotNull(virtualFile); true }) + { virtualFile -> virtualFile.isDirectory || virtualFile.name.equals("$className.class") }, + { virtualFile -> if (!virtualFile.isDirectory) files.addIfNotNull(virtualFile); true }) return files.single() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubConsistencyTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubConsistencyTest.kt index 6a6b481e194..28bb8a7c240 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubConsistencyTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubConsistencyTest.kt @@ -25,8 +25,8 @@ import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName -public class ClsStubConsistencyTest : StubConsistencyBaseTest() { - override fun getVirtualFileFinder(): VirtualFileFinder = JvmVirtualFileFinder.SERVICE.getInstance(getProject()) +class ClsStubConsistencyTest : StubConsistencyBaseTest() { + override fun getVirtualFileFinder(): VirtualFileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project) override fun getFileIds(): List = listOf(ClassId.topLevel(FqName("kotlin.collections.CollectionsKt"))) override fun createStubBuilder() = KotlinClsStubBuilder() diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinJavaScriptStubConsistencyTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinJavaScriptStubConsistencyTest.kt index f115cf886be..460beb14cd5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinJavaScriptStubConsistencyTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinJavaScriptStubConsistencyTest.kt @@ -25,14 +25,14 @@ import org.jetbrains.kotlin.load.kotlin.OldPackageFacadeClassUtils import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder import org.jetbrains.kotlin.name.FqName -public class KotlinJavaScriptStubConsistencyTest : StubConsistencyBaseTest() { +class KotlinJavaScriptStubConsistencyTest : StubConsistencyBaseTest() { override fun getFileIds() = listOf( "java.util", "jquery", "jquery.ui", "kotlin", "kotlin.browser", "kotlin.dom", "kotlin.js" ).map { OldPackageFacadeClassUtils.getPackageClassId(FqName(it)) } override fun getVirtualFileFinder(): VirtualFileFinder = - JsVirtualFileFinder.SERVICE.getInstance(getProject()) + JsVirtualFileFinder.SERVICE.getInstance(project) override fun createStubBuilder() = KotlinJavaScriptStubBuilder() diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/StubConsistencyBaseTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/StubConsistencyBaseTest.kt index 51f059c8bed..600ca048bf1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/StubConsistencyBaseTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/StubConsistencyBaseTest.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.stubs.elements.KtFileStubBuilder import org.junit.Assert -public abstract class StubConsistencyBaseTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class StubConsistencyBaseTest : KotlinLightCodeInsightFixtureTestCase() { protected abstract fun getFileIds(): List protected abstract fun getVirtualFileFinder(): VirtualFileFinder @@ -35,12 +35,12 @@ public abstract class StubConsistencyBaseTest : KotlinLightCodeInsightFixtureTes protected abstract fun getDecompiledText(packageFile: VirtualFile): String - public fun testConsistency() { + fun testConsistency() { getFileIds().forEach { doTest(it) } } private fun doTest(id: ClassId) { - val project = getProject() + val project = project val packageFile = getVirtualFileFinder().findVirtualFileWithHeader(id)!! val decompiledText = getDecompiledText(packageFile) val fileWithDecompiledText = KtPsiFactory(project).createFile(decompiledText) diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextBaseTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextBaseTest.kt index 1a280205db6..4bd6829ad10 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextBaseTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextBaseTest.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -public abstract class AbstractDecompiledTextBaseTest( +abstract class AbstractDecompiledTextBaseTest( baseDirectory: String, private val isJsLibrary: Boolean = false ) : KotlinLightCodeInsightFixtureTestCase() { @@ -42,7 +42,7 @@ public abstract class AbstractDecompiledTextBaseTest( protected abstract fun checkPsiFile(psiFile: PsiFile) - public fun doTest(path: String) { + fun doTest(path: String) { val fileToDecompile = getFileToDecompile() val psiFile = PsiManager.getInstance(project).findFile(fileToDecompile)!! checkPsiFile(psiFile) diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextFromJsMetadataTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextFromJsMetadataTest.kt index 742cc12530d..b5acf0683fd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextFromJsMetadataTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextFromJsMetadataTest.kt @@ -24,11 +24,11 @@ import org.jetbrains.kotlin.idea.test.ModuleKind import org.jetbrains.kotlin.idea.test.configureAs import kotlin.test.assertTrue -public abstract class AbstractDecompiledTextFromJsMetadataTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory, true) { - protected override fun getFileToDecompile(): VirtualFile = +abstract class AbstractDecompiledTextFromJsMetadataTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory, true) { + override fun getFileToDecompile(): VirtualFile = NavigateToDecompiledLibraryTest.getKjsmFile(TEST_PACKAGE, getTestName(false), myModule!!) - protected override fun checkPsiFile(psiFile: PsiFile) = + override fun checkPsiFile(psiFile: PsiFile) = assertTrue(psiFile is KtDecompiledFile, "Expecting decompiled kotlin javascript file, was: " + psiFile.javaClass) override fun setUp() { @@ -37,6 +37,6 @@ public abstract class AbstractDecompiledTextFromJsMetadataTest(baseDirectory: St } } -public abstract class AbstractCommonDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledText") +abstract class AbstractCommonDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledText") -public abstract class AbstractJsDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledTextJs") +abstract class AbstractJsDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledTextJs") diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt index 215fc7e4746..791dd6896dd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/AbstractDecompiledTextTest.kt @@ -22,14 +22,14 @@ import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest import kotlin.test.assertTrue -public abstract class AbstractDecompiledTextTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory) { - protected override fun getFileToDecompile(): VirtualFile = +abstract class AbstractDecompiledTextTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory) { + override fun getFileToDecompile(): VirtualFile = NavigateToDecompiledLibraryTest.getClassFile(TEST_PACKAGE, getTestName(false), myModule!!) - protected override fun checkPsiFile(psiFile: PsiFile) = + override fun checkPsiFile(psiFile: PsiFile) = assertTrue(psiFile is KtClsFile, "Expecting decompiled kotlin file, was: " + psiFile.javaClass) } -public abstract class AbstractCommonDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledText") +abstract class AbstractCommonDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledText") -public abstract class AbstractJvmDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledTextJvm") +abstract class AbstractJvmDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledTextJvm") diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt index 72db3478499..ddfd45cb632 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor -public class DecompiledTextConsistencyTest : TextConsistencyBaseTest() { +class DecompiledTextConsistencyTest : TextConsistencyBaseTest() { override fun getPackages(): List = emptyList() diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt index c32efd09740..e6ee4d88c5c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import org.junit.Assert import java.io.File -public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClassesTest() { +class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClassesTest() { override fun getProjectDescriptor(): LightProjectDescriptor { return KotlinJdkAndLibraryProjectDescriptor(File(KotlinTestUtils.getTestDataPathBase() + "/cli/jvm/wrongAbiVersionLib/bin")) @@ -47,9 +47,9 @@ public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClas } private fun checkFileWithWrongAbiVersion(file: VirtualFile) { - val psiFile = PsiManager.getInstance(getProject()!!).findFile(file) + val psiFile = PsiManager.getInstance(project!!).findFile(file) Assert.assertTrue(psiFile is KtClsFile) - val decompiledText = psiFile!!.getText()!! + val decompiledText = psiFile!!.text!! Assert.assertTrue(decompiledText.contains(INCOMPATIBLE_ABI_VERSION_GENERAL_COMMENT)) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDecompiledTextConsistencyTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDecompiledTextConsistencyTest.kt index 12089b124fa..b18270e5863 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDecompiledTextConsistencyTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDecompiledTextConsistencyTest.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.utils.sure -public class KotlinJavaScriptDecompiledTextConsistencyTest : TextConsistencyBaseTest() { +class KotlinJavaScriptDecompiledTextConsistencyTest : TextConsistencyBaseTest() { override fun getPackages(): List = listOf( "java.util", "jquery", "jquery.ui", "kotlin", "kotlin.browser", "kotlin.dom", "kotlin.js" ).map { FqName(it) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt index 210b99e06eb..eb925934e03 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass import org.junit.Assert -public abstract class TextConsistencyBaseTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class TextConsistencyBaseTest : KotlinLightCodeInsightFixtureTestCase() { protected abstract fun getPackages(): List @@ -48,7 +48,7 @@ public abstract class TextConsistencyBaseTest : KotlinLightCodeInsightFixtureTes protected abstract fun isFromFacade(descriptor: CallableMemberDescriptor, facadeFqName: FqName): Boolean - public fun testConsistency() { + fun testConsistency() { getPackages().forEach { doTestPackage(it) } getFacades().forEach { doTestFacade(it) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt index 57f8260b8e5..2552c627e0a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt @@ -20,16 +20,16 @@ import com.intellij.testFramework.EditorTestUtil import com.intellij.testFramework.LightCodeInsightTestCase import com.intellij.testFramework.LightPlatformCodeInsightTestCase -public class TypedHandlerTest : LightCodeInsightTestCase() { +class TypedHandlerTest : LightCodeInsightTestCase() { val dollar = '$' - public fun testTypeStringTemplateStart(): Unit = doCharTypeTest( + fun testTypeStringTemplateStart(): Unit = doCharTypeTest( '{', """val x = "$" """, """val x = "$dollar{}" """ ) - public fun testAutoIndentRightOpenBrace(): Unit = doCharTypeTest( + fun testAutoIndentRightOpenBrace(): Unit = doCharTypeTest( '{', "fun test() {\n" + @@ -41,7 +41,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoIndentLeftOpenBrace(): Unit = doCharTypeTest( + fun testAutoIndentLeftOpenBrace(): Unit = doCharTypeTest( '{', "fun test() {\n" + @@ -53,31 +53,31 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testTypeStringTemplateStartWithCloseBraceAfter(): Unit = doCharTypeTest( + fun testTypeStringTemplateStartWithCloseBraceAfter(): Unit = doCharTypeTest( '{', """fun foo() { "$" }""", """fun foo() { "$dollar{}" }""" ) - public fun testTypeStringTemplateStartBeforeString(): Unit = doCharTypeTest( + fun testTypeStringTemplateStartBeforeString(): Unit = doCharTypeTest( '{', """fun foo() { "$something" }""", """fun foo() { "$dollar{}something" }""" ) - public fun testKT3575(): Unit = doCharTypeTest( + fun testKT3575(): Unit = doCharTypeTest( '{', """val x = "$]" """, """val x = "$dollar{}]" """ ) - public fun testAutoCloseBraceInFunctionDeclaration(): Unit = doCharTypeTest( + fun testAutoCloseBraceInFunctionDeclaration(): Unit = doCharTypeTest( '{', "fun foo() ", "fun foo() {}" ) - public fun testAutoCloseBraceInLocalFunctionDeclaration(): Unit = doCharTypeTest( + fun testAutoCloseBraceInLocalFunctionDeclaration(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -89,7 +89,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoCloseBraceInAssignment(): Unit = doCharTypeTest( + fun testAutoCloseBraceInAssignment(): Unit = doCharTypeTest( '{', "fun foo() {\n" + " val a = \n" + @@ -100,7 +100,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedIfSurroundOnSameLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedIfSurroundOnSameLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -112,7 +112,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedElseSurroundOnSameLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedElseSurroundOnSameLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -124,7 +124,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedTryOnSameLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedTryOnSameLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -136,7 +136,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedCatchOnSameLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedCatchOnSameLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -148,7 +148,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedFinallyOnSameLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedFinallyOnSameLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -160,7 +160,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedWhileSurroundOnSameLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedWhileSurroundOnSameLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -172,7 +172,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedWhileSurroundOnNewLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedWhileSurroundOnNewLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -188,7 +188,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedIfSurroundOnOtherLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedIfSurroundOnOtherLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -202,7 +202,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedElseSurroundOnOtherLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedElseSurroundOnOtherLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -216,7 +216,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedTryOnOtherLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedTryOnOtherLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -230,7 +230,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedIfSurroundOnNewLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedIfSurroundOnNewLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -246,7 +246,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedElseSurroundOnNewLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedElseSurroundOnNewLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -262,7 +262,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testDoNotAutoCloseBraceInUnfinishedTryOnNewLine(): Unit = doCharTypeTest( + fun testDoNotAutoCloseBraceInUnfinishedTryOnNewLine(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -278,7 +278,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoCloseBraceInsideFor(): Unit = doCharTypeTest( + fun testAutoCloseBraceInsideFor(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -292,7 +292,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoCloseBraceInsideForAfterCloseParen(): Unit = doCharTypeTest( + fun testAutoCloseBraceInsideForAfterCloseParen(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -306,7 +306,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoCloseBraceBeforeIf(): Unit = doCharTypeTest( + fun testAutoCloseBraceBeforeIf(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -318,7 +318,7 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoCloseBraceInIfCondition(): Unit = doCharTypeTest( + fun testAutoCloseBraceInIfCondition(): Unit = doCharTypeTest( '{', "fun foo() {\n" + @@ -330,99 +330,99 @@ public class TypedHandlerTest : LightCodeInsightTestCase() { "}" ) - public fun testAutoInsertParenInStringLiteral(): Unit = doCharTypeTest( + fun testAutoInsertParenInStringLiteral(): Unit = doCharTypeTest( '(', """fun f() { println("$dollar{f}") }""", """fun f() { println("$dollar{f()}") }""" ) - public fun testAutoInsertParenInCode(): Unit = doCharTypeTest( + fun testAutoInsertParenInCode(): Unit = doCharTypeTest( '(', """fun f() { val a = f }""", """fun f() { val a = f() }""" ) - public fun testSplitStringByEnter(): Unit = doCharTypeTest( + fun testSplitStringByEnter(): Unit = doCharTypeTest( '\n', """val s = "foobar"""", "val s = \"foo\" +\n" + " \"bar\"" ) - public fun testSplitStringByEnter_Empty(): Unit = doCharTypeTest( + fun testSplitStringByEnter_Empty(): Unit = doCharTypeTest( '\n', """val s = """"", "val s = \"\" +\n" + " \"\"" ) - public fun testSplitStringByEnter_BeforeEscapeSequence(): Unit = doCharTypeTest( + fun testSplitStringByEnter_BeforeEscapeSequence(): Unit = doCharTypeTest( '\n', """val s = "foo\nbar"""", "val s = \"foo\" +\n" + " \"\\nbar\"" ) - public fun testSplitStringByEnter_BeforeSubstitution(): Unit = doCharTypeTest( + fun testSplitStringByEnter_BeforeSubstitution(): Unit = doCharTypeTest( '\n', """val s = "foo${dollar}bar"""", "val s = \"foo\" +\n" + " \"${dollar}bar\"" ) - public fun testSplitStringByEnter_AddParentheses(): Unit = doCharTypeTest( + fun testSplitStringByEnter_AddParentheses(): Unit = doCharTypeTest( '\n', """val l = "foobar".length()""", "val l = (\"foo\" +\n" + " \"bar\").length()" ) - public fun testSplitStringByEnter_ExistingParentheses(): Unit = doCharTypeTest( + fun testSplitStringByEnter_ExistingParentheses(): Unit = doCharTypeTest( '\n', """val l = ("asdf" + "foobar").length()""", "val l = (\"asdf\" + \"foo\" +\n" + " \"bar\").length()" ) - public fun testSplitStringByEnter_TripleQuotedString(): Unit = doCharTypeTest( + fun testSplitStringByEnter_TripleQuotedString(): Unit = doCharTypeTest( '\n', "val l = \"\"\"foobar\"\"\"", "val l = \"\"\"foo\nbar\"\"\"" ) - public fun testTypeLtInFunDeclaration() { + fun testTypeLtInFunDeclaration() { doLtGtTest("fun ") } - public fun testTypeLtInOngoingConstructorCall() { + fun testTypeLtInOngoingConstructorCall() { doLtGtTest("fun test() { Collection }") } - public fun testTypeLtInClassDeclaration() { + fun testTypeLtInClassDeclaration() { doLtGtTest("class Some {}") } - public fun testTypeLtInPropertyType() { + fun testTypeLtInPropertyType() { doLtGtTest("val a: List ") } - public fun testTypeLtInExtensionFunctionReceiver() { + fun testTypeLtInExtensionFunctionReceiver() { doLtGtTest("fun Collection ") } - public fun testTypeLtInFunParam() { + fun testTypeLtInFunParam() { doLtGtTest("fun some(a : HashSet)") } - public fun testTypeLtInFun() { + fun testTypeLtInFun() { doLtGtTestNoAutoClose("fun some() { < }") } - public fun testTypeLtInLess() { + fun testTypeLtInLess() { doLtGtTestNoAutoClose("fun some() { val a = 12; a < }") } - public fun testMoveThroughGT() { + fun testMoveThroughGT() { LightPlatformCodeInsightTestCase.configureFromFileText("a.kt", "val a: List>>") EditorTestUtil.performTypingAction(LightPlatformCodeInsightTestCase.getEditor(), '>') EditorTestUtil.performTypingAction(LightPlatformCodeInsightTestCase.getEditor(), '>') diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInCompletionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInCompletionTest.kt index 0133dd8619b..f7500404577 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInCompletionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInCompletionTest.kt @@ -23,16 +23,16 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.psi.KtClass import org.junit.Assert -public class QuickDocInCompletionTest(): LightPlatformCodeInsightFixtureTestCase() { +class QuickDocInCompletionTest(): LightPlatformCodeInsightFixtureTestCase() { override fun getTestDataPath(): String { return PluginTestCaseBase.getTestDataPathBase() + "/kdoc/inCompletion/" } - public fun testSimple() { + fun testSimple() { myFixture.configureByFile(getTestName(true) + ".kt") val lookupElements = myFixture.completeBasic() - val lookupObject = lookupElements.first().getObject() + val lookupObject = lookupElements.first().`object` val element = KotlinQuickDocumentationProvider().getDocumentationElementForLookupItem( - myFixture.getPsiManager(), lookupObject, null) + myFixture.psiManager, lookupObject, null) Assert.assertTrue(element is KtClass) } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInHierarchyTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInHierarchyTest.kt index cedff6a55ee..983e9c03b33 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInHierarchyTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocInHierarchyTest.kt @@ -32,25 +32,25 @@ import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.KotlinQuickDocumentationProvider import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -public class QuickDocInHierarchyTest() : CodeInsightTestCase() { +class QuickDocInHierarchyTest() : CodeInsightTestCase() { override fun getTestDataPath(): String { return PluginTestCaseBase.getTestDataPathBase() + "/kdoc/inTypeHierarchy/" } - public fun testSimple() { + fun testSimple() { configureByFile(getTestName(true) + ".kt") val context = MapDataContext() - context.put(CommonDataKeys.PROJECT, getProject()) - context.put(CommonDataKeys.EDITOR, getEditor()) + context.put(CommonDataKeys.PROJECT, project) + context.put(CommonDataKeys.EDITOR, editor) val hierarchyTreeStructure = TypeHierarchyTreeStructure( - getProject(), + project, LanguageTypeHierarchy.INSTANCE.forLanguage(KotlinLanguage.INSTANCE).getTarget(context) as PsiClass?, HierarchyBrowserBaseEx.SCOPE_PROJECT ) - val hierarchyNodeDescriptor = hierarchyTreeStructure.getBaseDescriptor() as TypeHierarchyNodeDescriptor - val doc = KotlinQuickDocumentationProvider().generateDoc(hierarchyNodeDescriptor.getPsiClass() as PsiElement, null)!! + val hierarchyNodeDescriptor = hierarchyTreeStructure.baseDescriptor as TypeHierarchyNodeDescriptor + val doc = KotlinQuickDocumentationProvider().generateDoc(hierarchyNodeDescriptor.psiClass as PsiElement, null)!! TestCase.assertTrue("Invalid doc\n: $doc", doc.contains("Very special class")) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocNavigationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocNavigationTest.kt index 428d8fcf530..fea376d6676 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocNavigationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocNavigationTest.kt @@ -24,17 +24,17 @@ import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.junit.Assert -public class QuickDocNavigationTest() : LightPlatformCodeInsightFixtureTestCase() { +class QuickDocNavigationTest() : LightPlatformCodeInsightFixtureTestCase() { override fun getTestDataPath(): String { return PluginTestCaseBase.getTestDataPathBase() + "/kdoc/navigate/" } - public fun testSimple() { + fun testSimple() { myFixture.configureByFile(getTestName(true) + ".kt") - val source = myFixture.getElementAtCaret().getParentOfType(false) + val source = myFixture.elementAtCaret.getParentOfType(false) val target = KotlinQuickDocumentationProvider().getDocumentationElementForLink( - myFixture.getPsiManager(), "C", source); + myFixture.psiManager, "C", source); Assert.assertTrue(target is KtClass) - Assert.assertEquals("C", (target as KtClass).getName()) + Assert.assertEquals("C", (target as KtClass).name) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt index 87ac0bb6f60..9b2a42e27a2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/filters/AbstractKotlinExceptionFilterTest.kt @@ -41,7 +41,7 @@ import java.net.URLClassLoader private var MOCK_LIBRARY_JAR: File? = null private val MOCK_LIBRARY_SOURCES = PluginTestCaseBase.getTestDataPathBase() + "/debugger/mockLibraryForExceptionFilter" -public abstract class AbstractKotlinExceptionFilterTest: KotlinCodeInsightTestCase() { +abstract class AbstractKotlinExceptionFilterTest: KotlinCodeInsightTestCase() { override fun getTestDataPath() = "" protected fun doTest(path: String) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/folding/FoldingAfterOptimizeImportsTest.kt b/idea/tests/org/jetbrains/kotlin/idea/folding/FoldingAfterOptimizeImportsTest.kt index b6cd10a31b7..a4f1ac1e761 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/folding/FoldingAfterOptimizeImportsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/folding/FoldingAfterOptimizeImportsTest.kt @@ -33,7 +33,7 @@ class FoldingAfterOptimizeImportsTest : AbstractKotlinFoldingTest() { get() = myFixture!! private val fileText: String - get() = fixture.getFile()!!.getText()!! + get() = fixture.file!!.text!! fun testFoldingAfterOptimizeImports() { doTest() @@ -48,11 +48,11 @@ class FoldingAfterOptimizeImportsTest : AbstractKotlinFoldingTest() { doTestWithSettings(fileText) { fileText -> - CodeFoldingManager.getInstance(fixture.getProject())!!.buildInitialFoldings(getEditor()) + CodeFoldingManager.getInstance(fixture.project)!!.buildInitialFoldings(editor) getFoldingRegion(0).checkRegion(false, findStringWithPrefixes("// REGION BEFORE: ")) - CommandProcessor.getInstance()?.executeCommand(fixture.getProject(), - KotlinImportOptimizer().processFile(fixture.getFile()), + CommandProcessor.getInstance()?.executeCommand(fixture.project, + KotlinImportOptimizer().processFile(fixture.file), "Optimize Imports", null, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION) getFoldingRegion(0).checkRegion(false, findStringWithPrefixes("// REGION AFTER: ")) @@ -62,21 +62,21 @@ class FoldingAfterOptimizeImportsTest : AbstractKotlinFoldingTest() { private fun getFoldingRegion(number: Int): FoldRegion { fixture.doHighlighting() - val model = getEditor().getFoldingModel() - val foldingRegions = model.getAllFoldRegions() + val model = editor.foldingModel + val foldingRegions = model.allFoldRegions assert(foldingRegions.size >= number) { "There is no enough folding regions in file: in file - ${foldingRegions.size} , expected = ${number}" } return foldingRegions[number] } - override fun getTestDataPath() = File(PluginTestCaseBase.getTestDataPathBase(), "/folding/afterOptimizeImports/").getPath() + File.separator + override fun getTestDataPath() = File(PluginTestCaseBase.getTestDataPathBase(), "/folding/afterOptimizeImports/").path + File.separator private fun findStringWithPrefixes(prefix: String) = InTextDirectivesUtils.findStringWithPrefixes(fileText, prefix) ?: throw AssertionError("Couldn't find line with prefix $prefix") - private fun FoldRegion.getPosition() = "${getStartOffset()}:${getEndOffset()}" + private fun FoldRegion.getPosition() = "${startOffset}:${endOffset}" private fun FoldRegion.checkRegion(isExpanded: Boolean, position: String): Unit { - assert(isValid()) { "Region should be valid: $this" } + assert(isValid) { "Region should be valid: $this" } assert(isExpanded == isExpanded()) { "isExpanded should be $isExpanded. Actual = ${isExpanded()}" } assert(position == getPosition()) { "Region position is wrong: expected = $position, actual = ${getPosition()}" } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt index 882234bccbc..b6c85796450 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractHighlightExitPointsTest.kt @@ -23,17 +23,17 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import org.jetbrains.kotlin.test.InTextDirectivesUtils import kotlin.test.assertEquals -public abstract class AbstractHighlightExitPointsTest : LightCodeInsightFixtureTestCase() { - public fun doTest(testDataPath: String) { +abstract class AbstractHighlightExitPointsTest : LightCodeInsightFixtureTestCase() { + fun doTest(testDataPath: String) { myFixture.configureByFile(testDataPath) - HighlightUsagesHandler.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile()); + HighlightUsagesHandler.invoke(myFixture.project, myFixture.editor, myFixture.file); - val text = myFixture.getFile().getText() + val text = myFixture.file.text val expectedToBeHighlighted = InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "//HIGHLIGHTED:") - val searchResultsTextAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES) - val highlighters = myFixture.getEditor().getMarkupModel().getAllHighlighters() - .filter { it.getTextAttributes() == searchResultsTextAttributes } - val actual = highlighters.map { text.substring(it.getStartOffset(), it.getEndOffset()) } + val searchResultsTextAttributes = EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES) + val highlighters = myFixture.editor.markupModel.allHighlighters + .filter { it.textAttributes == searchResultsTextAttributes } + val actual = highlighters.map { text.substring(it.startOffset, it.endOffset) } assertEquals(expectedToBeHighlighted, actual) } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt index 664833015ac..fbb6ff803f1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt @@ -24,7 +24,7 @@ import com.intellij.testFramework.ExpectedHighlightingData import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor -public abstract class AbstractUsageHighlightingTest: KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractUsageHighlightingTest: KotlinLightCodeInsightFixtureTestCase() { companion object { // Not standard to leave it in text after configureByFile and remove manually after collecting highlighting information val CARET_TAG = "~" @@ -32,25 +32,25 @@ public abstract class AbstractUsageHighlightingTest: KotlinLightCodeInsightFixtu protected fun doTest(filePath: String) { myFixture.configureByFile(filePath) - val document = myFixture.getEditor().getDocument() - val data = ExpectedHighlightingData(document, false, false, true, false, myFixture.getFile()) + val document = myFixture.editor.document + val data = ExpectedHighlightingData(document, false, false, true, false, myFixture.file) data.init() - val caret = document.getText().indexOf(CARET_TAG) + val caret = document.text.indexOf(CARET_TAG) assert(caret != -1) { "Caret marker '$CARET_TAG' expected" } - WriteCommandAction.runWriteCommandAction(myFixture.getProject()) { + WriteCommandAction.runWriteCommandAction(myFixture.project) { document.deleteString(caret, caret + CARET_TAG.length) } - getEditor().getCaretModel().moveToOffset(caret) + editor.caretModel.moveToOffset(caret) myFixture.testAction(HighlightUsagesAction()) - val highlighters = myFixture.getEditor().getMarkupModel().getAllHighlighters() + val highlighters = myFixture.editor.markupModel.allHighlighters val infos = highlighters.map { highlighter -> - var startOffset = highlighter.getStartOffset() - var endOffset = highlighter.getEndOffset() + var startOffset = highlighter.startOffset + var endOffset = highlighter.endOffset if (startOffset > caret) startOffset += CARET_TAG.length if (endOffset > caret) endOffset += CARET_TAG.length @@ -58,7 +58,7 @@ public abstract class AbstractUsageHighlightingTest: KotlinLightCodeInsightFixtu HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(startOffset, endOffset).create() } - data.checkResult(infos, StringBuilder(document.getText()).insert(caret, CARET_TAG).toString()) + data.checkResult(infos, StringBuilder(document.text).insert(caret, CARET_TAG).toString()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/NoErrorsInStdlibTest.kt b/idea/tests/org/jetbrains/kotlin/idea/highlighter/NoErrorsInStdlibTest.kt index 0fa3a7269ea..9e7940ee408 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/NoErrorsInStdlibTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/NoErrorsInStdlibTest.kt @@ -31,27 +31,27 @@ import java.io.File import kotlin.test.assertEquals import kotlin.test.assertTrue -public class NoErrorsInStdlibTest : KotlinLightCodeInsightFixtureTestCase() { - public fun testNoErrors() { +class NoErrorsInStdlibTest : KotlinLightCodeInsightFixtureTestCase() { + fun testNoErrors() { val root = myFixture.copyDirectoryToProject("../libraries/stdlib/src", "") - val psiManager = getPsiManager() // workaround for KT-3974 IllegalAccessError when accessing protected method inherited by outer class + val psiManager = psiManager // workaround for KT-3974 IllegalAccessError when accessing protected method inherited by outer class var totalErrors = 0 var hasAtLeastOneFile = false VfsUtil.processFileRecursivelyWithoutIgnored(root) { file -> - if (!file!!.isDirectory()) { + if (!file!!.isDirectory) { val psiFile = psiManager.findFile(file) if (psiFile is KtFile) { hasAtLeastOneFile = true val bindingContext = psiFile.analyzeFully() - val errors = bindingContext.getDiagnostics().all().filter { it.getSeverity() == Severity.ERROR } + val errors = bindingContext.diagnostics.all().filter { it.severity == Severity.ERROR } if (errors.isNotEmpty()) { System.err.println("${psiFile.getName()}: ${errors.size} errors") AnalyzerWithCompilerReport.reportDiagnostics( - bindingContext.getDiagnostics(), PrintingMessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR + bindingContext.diagnostics, PrintingMessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR ) totalErrors += errors.size diff --git a/idea/tests/org/jetbrains/kotlin/idea/imports/AbstractOptimizeImportsTest.kt b/idea/tests/org/jetbrains/kotlin/idea/imports/AbstractOptimizeImportsTest.kt index 4aa7419bf05..76155edac6e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/imports/AbstractOptimizeImportsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/imports/AbstractOptimizeImportsTest.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.* import org.jetbrains.kotlin.psi.* -public abstract class AbstractOptimizeImportsTest() : AbstractImportsTest() { +abstract class AbstractOptimizeImportsTest() : AbstractImportsTest() { override fun doTest(file: KtFile) { KotlinImportOptimizer().processFile(file).run() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt index 6858a65a33b..f59cc9faf56 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt @@ -35,17 +35,17 @@ class KotlinCleanupInspectionTest(): KotlinLightCodeInsightFixtureTestCase() { myFixture.enableInspections(KotlinCleanupInspection::class.java) myFixture.configureByFiles(*files) - val project = myFixture.getProject() + val project = myFixture.project val managerEx = InspectionManager.getInstance(project) val globalContext = managerEx.createNewGlobalContext(false) as GlobalInspectionContextBase - val analysisScope = AnalysisScope(myFixture.getFile()) - val profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile() + val analysisScope = AnalysisScope(myFixture.file) + val profile = InspectionProjectProfileManager.getInstance(project).inspectionProfile globalContext.codeCleanup(project, analysisScope, profile, "Cleanup", null, true) myFixture.checkResultByFile(result) } - public fun testCleanup() { + fun testCleanup() { doTest("cleanup.kt.after", "cleanup.kt", "JavaAnn.java", "deprecatedSymbols.kt") } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractMultiFileIntentionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractMultiFileIntentionTest.kt index 9839a20f5c8..ad1bd29b6c2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractMultiFileIntentionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractMultiFileIntentionTest.kt @@ -36,14 +36,14 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import org.junit.Assert import java.io.File -public abstract class AbstractMultiFileIntentionTest : KotlinMultiFileTestCase() { +abstract class AbstractMultiFileIntentionTest : KotlinMultiFileTestCase() { protected fun doTest(path: String) { val config = JsonParser().parse(FileUtil.loadFile(File(path), true)) as JsonObject val mainFilePath = config.getString("mainFile") val intentionAction = Class.forName(config.getString("intentionClass")).newInstance() as IntentionAction - val isApplicableExpected = config["isApplicable"]?.getAsBoolean() ?: true + val isApplicableExpected = config["isApplicable"]?.asBoolean ?: true - val withRuntime = config["withRuntime"]?.getAsBoolean() ?: false + val withRuntime = config["withRuntime"]?.asBoolean ?: false if (withRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk()) } @@ -52,20 +52,20 @@ public abstract class AbstractMultiFileIntentionTest : KotlinMultiFileTestCase() val mainFile = rootDir.findFileByRelativePath(mainFilePath)!! val conflictFile = rootDir.findFileByRelativePath("$mainFilePath.conflicts") val document = FileDocumentManager.getInstance().getDocument(mainFile)!! - val editor = EditorFactory.getInstance()!!.createEditor(document, getProject()!!)!! - editor.getCaretModel().moveToOffset(extractCaretOffset(document)) - val mainPsiFile = PsiManager.getInstance(getProject()!!).findFile(mainFile)!! + val editor = EditorFactory.getInstance()!!.createEditor(document, project!!)!! + editor.caretModel.moveToOffset(extractCaretOffset(document)) + val mainPsiFile = PsiManager.getInstance(project!!).findFile(mainFile)!! try { Assert.assertTrue("isAvailable() for ${intentionAction.javaClass} should return $isApplicableExpected", - isApplicableExpected == intentionAction.isAvailable(getProject(), editor, mainPsiFile)) + isApplicableExpected == intentionAction.isAvailable(project, editor, mainPsiFile)) config.getNullableString("intentionText")?.let { - TestCase.assertEquals("Intention text mismatch", it, intentionAction.getText()) + TestCase.assertEquals("Intention text mismatch", it, intentionAction.text) } if (isApplicableExpected) { - getProject().executeWriteCommand(intentionAction.getText()) { - intentionAction.invoke(getProject(), editor, mainPsiFile) + project.executeWriteCommand(intentionAction.text) { + intentionAction.invoke(project, editor, mainPsiFile) } } @@ -75,7 +75,7 @@ public abstract class AbstractMultiFileIntentionTest : KotlinMultiFileTestCase() KotlinTestUtils.assertEqualsToFile(File(conflictFile!!.path), e.message!!) } finally { - PsiDocumentManager.getInstance(getProject()!!).commitAllDocuments() + PsiDocumentManager.getInstance(project!!).commitAllDocuments() FileDocumentManager.getInstance().saveAllDocuments() EditorFactory.getInstance()!!.releaseEditor(editor) @@ -93,11 +93,11 @@ public abstract class AbstractMultiFileIntentionTest : KotlinMultiFileTestCase() return testName.substring(0, testName.lastIndexOf('_')).replace('_', '/') } - protected override fun getTestRoot() : String { + override fun getTestRoot() : String { return "/multiFileIntentions/" } - protected override fun getTestDataPath() : String { + override fun getTestDataPath() : String { return PluginTestCaseBase.getTestDataPathBase() } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt b/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt index d08ecadec30..bb552a67aef 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt @@ -24,19 +24,19 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -public abstract class AbstractBytecodeToolWindowTest: KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractBytecodeToolWindowTest: KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory() override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE - public fun doTest(testPath: String) { + fun doTest(testPath: String) { val mainDir = File(testPath) - val mainFileName = mainDir.getName() + ".kt" - mainDir.listFiles { file, name -> name != mainFileName }.forEach { myFixture.configureByFile(testPath + "/" + it.getName()) } + val mainFileName = mainDir.name + ".kt" + mainDir.listFiles { file, name -> name != mainFileName }.forEach { myFixture.configureByFile(testPath + "/" + it.name) } val mainFileText = File("$testPath/$mainFileName").readText() myFixture.configureByText(KotlinFileType.INSTANCE, mainFileText) - val file = myFixture.getFile() as KtFile + val file = myFixture.file as KtFile val enableInline = InTextDirectivesUtils.getPrefixedBoolean(mainFileText, "// INLINE:") ?: true val bytecodes = KotlinBytecodeToolWindow.getBytecodeForFile(file, enableInline, true, true) diff --git a/idea/tests/org/jetbrains/kotlin/idea/jsonUtils/jsonUtils.kt b/idea/tests/org/jetbrains/kotlin/idea/jsonUtils/jsonUtils.kt index 5ced23067f6..f2c979840d2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/jsonUtils/jsonUtils.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/jsonUtils/jsonUtils.kt @@ -23,5 +23,5 @@ fun JsonObject.getString(name: String): String { } fun JsonObject.getNullableString(name: String): String? { - return this[name]?.getAsString() + return this[name]?.asString } diff --git a/idea/tests/org/jetbrains/kotlin/idea/kdoc/AbstractKDocTypingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/kdoc/AbstractKDocTypingTest.kt index 1bd91dbcd18..1f47342537d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/kdoc/AbstractKDocTypingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/kdoc/AbstractKDocTypingTest.kt @@ -21,13 +21,13 @@ import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils -public abstract class AbstractKDocTypingTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractKDocTypingTest : KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath(): String = KotlinTestUtils.getHomeDirectory() override fun getProjectDescriptor() = KotlinLightProjectDescriptor.INSTANCE protected fun doTest(fileName: String) { myFixture.configureByFile(fileName) - val textToType = InTextDirectivesUtils.findStringWithPrefixes(myFixture.getFile().getText(), "// TYPE:") + val textToType = InTextDirectivesUtils.findStringWithPrefixes(myFixture.file.text, "// TYPE:") if (textToType == null) { throw IllegalArgumentException("Cannot find directive TYPE in input file") } diff --git a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt index 4ea3f08c587..f3df8390dac 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt @@ -25,41 +25,41 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtFile import org.junit.Assert -public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { +class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { override fun getTestDataPath(): String { return PluginTestCaseBase.getTestDataPathBase() + "/kdoc/finder/" } - public fun testConstructor() { + fun testConstructor() { myFixture.configureByFile(getTestName(false) + ".kt") - val declaration = (myFixture.getFile() as KtFile).getDeclarations()[0] + val declaration = (myFixture.file as KtFile).declarations[0] val descriptor = declaration.resolveToDescriptor() as ClassDescriptor - val constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor()!! + val constructorDescriptor = descriptor.unsubstitutedPrimaryConstructor!! val doc = KDocFinder.findKDoc(constructorDescriptor) Assert.assertEquals("Doc for constructor of class C.", doc!!.getContent()) } - public fun testOverridden() { + fun testOverridden() { myFixture.configureByFile(getTestName(false) + ".kt") - val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Bar" } + val declaration = (myFixture.file as KtFile).declarations.single { it.name == "Bar" } val descriptor = declaration.resolveToDescriptor() as ClassDescriptor val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getContributedFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor) Assert.assertEquals("Doc for method xyzzy", doc!!.getContent()) } - public fun testOverriddenWithSubstitutedType() { + fun testOverriddenWithSubstitutedType() { myFixture.configureByFile(getTestName(false) + ".kt") - val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Bar" } + val declaration = (myFixture.file as KtFile).declarations.single { it.name == "Bar" } val descriptor = declaration.resolveToDescriptor() as ClassDescriptor val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getContributedFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor) Assert.assertEquals("Doc for method xyzzy", doc!!.getContent()) } - public fun testProperty() { + fun testProperty() { myFixture.configureByFile(getTestName(false) + ".kt") - val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Foo" } + val declaration = (myFixture.file as KtFile).declarations.single { it.name == "Foo" } val descriptor = declaration.resolveToDescriptor() as ClassDescriptor val propertyDescriptor = descriptor.defaultType.memberScope.getContributedVariables(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() val doc = KDocFinder.findKDoc(propertyDescriptor) diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractKotlinGotoImplementationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractKotlinGotoImplementationTest.kt index ca598b1b2ba..5b1000158b4 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractKotlinGotoImplementationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractKotlinGotoImplementationTest.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -public abstract class AbstractKotlinGotoImplementationTest : LightCodeInsightTestCase() { +abstract class AbstractKotlinGotoImplementationTest : LightCodeInsightTestCase() { override fun getTestDataPath(): String = KotlinTestUtils.getHomeDirectory() + File.separator diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixSpecialTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixSpecialTest.kt index a50c081de25..3263ca46d27 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixSpecialTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixSpecialTest.kt @@ -32,18 +32,17 @@ import org.junit.runner.RunWith @TestMetadata("idea/testData/quickfix.special") @TestDataPath("\$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners::class) -public class DeprecatedSymbolUsageFixSpecialTest : KotlinLightCodeInsightFixtureTestCase() { +@RunWith(JUnit3RunnerWithInners::class) class DeprecatedSymbolUsageFixSpecialTest : KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory() override fun getProjectDescriptor() = ProjectDescriptorWithStdlibSources.INSTANCE private val TEST_DATA_DIR = "idea/testData/quickfix.special/deprecatedSymbolUsage" - public fun testMemberInCompiledClass() { + fun testMemberInCompiledClass() { doTest("matches(input)") } - public fun testDefaultParameterValuesFromLibrary() { + fun testDefaultParameterValuesFromLibrary() { doTest("""prefix + joinTo(StringBuilder(), separator, "", postfix, limit, truncated, transform)""") } @@ -51,11 +50,11 @@ public class DeprecatedSymbolUsageFixSpecialTest : KotlinLightCodeInsightFixture val testPath = KotlinTestUtils.navigationMetadata(TEST_DATA_DIR + "/" + getTestName(true) + ".kt") myFixture.configureByFile(testPath) - val offset = getEditor().caretModel.offset - val element = getFile().findElementAt(offset) + val offset = editor.caretModel.offset + val element = file.findElementAt(offset) val nameExpression = element!!.parents.firstIsInstance() - getProject().executeWriteCommand("") { - DeprecatedSymbolUsageFix(nameExpression, ReplaceWith(pattern, emptyList())).invoke(getProject(), getEditor(), getFile()) + project.executeWriteCommand("") { + DeprecatedSymbolUsageFix(nameExpression, ReplaceWith(pattern, emptyList())).invoke(project, editor, file) } myFixture.checkResultByFile("$testPath.after") diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt index c6dbadbed41..94bfcc0cea6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.util.findElementsByCommentPrefix import java.io.File -public abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixtureTestCase() { private data class ElementInfo(val checked: Boolean, val toAbstract: Boolean) companion object { @@ -47,21 +47,21 @@ public abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixture val fixture: JavaCodeInsightTestFixture get() = myFixture - protected override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() protected fun doTest(path: String, action: (mainFile: PsiFile) -> Unit) { val mainFile = File(path) val afterFile = File("$path.after") val conflictFile = File("$path.messages") - fixture.testDataPath = "${KotlinTestUtils.getHomeDirectory()}/${mainFile.getParent()}" + fixture.testDataPath = "${KotlinTestUtils.getHomeDirectory()}/${mainFile.parent}" - val mainFileName = mainFile.getName() + val mainFileName = mainFile.name val mainFileBaseName = FileUtil.getNameWithoutExtension(mainFileName) val extraFiles = mainFile.parentFile.listFiles { file, name -> name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java")) } - val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.getName()) } + val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.name) } val file = fixture.configureByFile(mainFileName) val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null @@ -81,7 +81,7 @@ public abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixture assert(!conflictFile.exists()) { "Conflict file $conflictFile should not exist" } KotlinTestUtils.assertEqualsToFile(afterFile, file.text!!) for ((extraPsiFile, extraFile) in extraFilesToPsi) { - KotlinTestUtils.assertEqualsToFile(File("${extraFile.getPath()}.after"), extraPsiFile.text) + KotlinTestUtils.assertEqualsToFile(File("${extraFile.path}.after"), extraPsiFile.text) } } catch(e: Exception) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt index 6b188e0f46c..6479e7dbb1c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt @@ -29,7 +29,7 @@ import com.intellij.codeInsight.template.impl.TemplateManagerImpl import com.intellij.codeInsight.template.TemplateManager import com.intellij.openapi.command.WriteCommandAction -public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { +class InplaceRenameTest : LightPlatformCodeInsightTestCase() { init { System.setProperty("idea.platform.prefix", "Idea") } @@ -37,23 +37,23 @@ public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { override fun isRunInWriteAction(): Boolean = false override fun getTestDataPath(): String = PluginTestCaseBase.getTestDataPathBase() + "/refactoring/rename/inplace/" - public fun testLocalVal() { + fun testLocalVal() { doTestInplaceRename("y") } - public fun testForLoop() { + fun testForLoop() { doTestInplaceRename("j") } - public fun testTryCatch() { + fun testTryCatch() { doTestInplaceRename("e1") } - public fun testFunctionLiteral() { + fun testFunctionLiteral() { doTestInplaceRename("y") } - public fun testFunctionLiteralIt() { + fun testFunctionLiteralIt() { configureByFile(getTestName(false) + ".kt") val newName = "y" @@ -62,16 +62,16 @@ public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { val file = LightPlatformCodeInsightTestCase.getFile()!! val editor = LightPlatformCodeInsightTestCase.getEditor()!! - val element = file.findReferenceAt(editor.getCaretModel().getOffset())!!.getElement() + val element = file.findReferenceAt(editor.caretModel.offset)!!.element assertNotNull(element) - val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.getName(), element!!, + val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element!!, LightPlatformCodeInsightTestCase.getCurrentEditorDataContext()) val handler = RenameKotlinImplicitLambdaParameter() assertTrue(handler.isRenaming(dataContext), "In-place rename not allowed for " + element) - val project = editor.getProject()!! + val project = editor.project!! val templateManager = TemplateManager.getInstance(project) as TemplateManagerImpl try { templateManager.setTemplateTesting(true) @@ -84,11 +84,11 @@ public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { var state = TemplateManagerImpl.getTemplateState(editor) assert(state != null) - val range = state!!.getCurrentVariableRange() + val range = state!!.currentVariableRange assert(range != null) object : WriteCommandAction.Simple(project) { override fun run() { - editor.getDocument().replaceString(range!!.getStartOffset(), range.getEndOffset(), newName) + editor.document.replaceString(range!!.startOffset, range.endOffset, newName) } }.execute().throwException() @@ -104,31 +104,31 @@ public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { checkResultByFile(getTestName(false) + ".kt.after") } - public fun testFunctionLiteralParenthesis() { + fun testFunctionLiteralParenthesis() { doTestInplaceRename("y") } - public fun testLocalFunction() { + fun testLocalFunction() { doTestInplaceRename("bar") } - public fun testFunctionParameterNotInplace() { + fun testFunctionParameterNotInplace() { doTestInplaceRename(null) } - public fun testGlobalFunctionNotInplace() { + fun testGlobalFunctionNotInplace() { doTestInplaceRename(null) } - public fun testTopLevelValNotInplace() { + fun testTopLevelValNotInplace() { doTestInplaceRename(null) } - public fun testLabelFromFunction() { + fun testLabelFromFunction() { doTestInplaceRename("foo") } - public fun testMultiDeclaration() { + fun testMultiDeclaration() { doTestInplaceRename("foo") } @@ -141,7 +141,7 @@ public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { assertNotNull(element) - val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.getName(), element!!, + val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element!!, LightPlatformCodeInsightTestCase.getCurrentEditorDataContext()) val handler = VariableInplaceRenameHandler() diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidatorTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidatorTest.kt index d247454f8e4..a886739d2d6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidatorTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/KotlinNamesValidatorTest.kt @@ -21,7 +21,7 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.refactoring.KotlinNamesValidator import org.junit.Assert -public class KotlinNamesValidatorTest : LightCodeInsightFixtureTestCase() { +class KotlinNamesValidatorTest : LightCodeInsightFixtureTestCase() { val validator: NamesValidator = KotlinNamesValidator() private fun isKeyword(string: String) = validator.isKeyword(string, null) @@ -32,7 +32,7 @@ public class KotlinNamesValidatorTest : LightCodeInsightFixtureTestCase() { myFixture.configureByFiles() } - public fun testKeywords() { + fun testKeywords() { Assert.assertTrue(isKeyword("val")); Assert.assertTrue(isKeyword("class")); Assert.assertTrue(isKeyword("fun")); @@ -43,7 +43,7 @@ public class KotlinNamesValidatorTest : LightCodeInsightFixtureTestCase() { Assert.assertFalse(isKeyword("-")); } - public fun testIdentifiers() { + fun testIdentifiers() { Assert.assertTrue(isIdentifier("abc")); Assert.assertTrue(isIdentifier("q_q")); Assert.assertTrue(isIdentifier("constructor")); diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt index 28fa3d69cac..da36c6db66d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt @@ -59,7 +59,7 @@ import java.io.File import java.util.* import kotlin.test.assertEquals -public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor() = LightCodeInsightFixtureTestCase.JAVA_LATEST val fixture: JavaCodeInsightTestFixture get() = myFixture @@ -79,7 +79,7 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe private fun doIntroduceParameterTest(path: String, asLambda: Boolean) { doTest(path) { file -> - val fileText = file.getText() + val fileText = file.text open class HelperImpl: KotlinIntroduceParameterHelper { override fun configure(descriptor: IntroduceParameterDescriptor): IntroduceParameterDescriptor { @@ -135,11 +135,11 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe var elementToWorkOn: ElementToWorkOn? = null ElementToWorkOn.processElementToWorkOn( - getEditor(), + editor, file, "Introduce parameter", null, - getProject(), + project, object : ElementToWorkOn.ElementsProcessor { override fun accept(e: ElementToWorkOn): Boolean { return true @@ -152,8 +152,8 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe } }) - val expr = elementToWorkOn!!.getExpression() - val localVar = elementToWorkOn!!.getLocalVariable() + val expr = elementToWorkOn!!.expression + val localVar = elementToWorkOn!!.localVariable val context = expr ?: localVar val method = Util.getContainingMethod(context) ?: throw AssertionError("No containing method found") @@ -163,18 +163,18 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe val (initializer, occurrences) = if (expr == null) { - localVar.getInitializer()!! to CodeInsightUtil.findReferenceExpressions(method, localVar) + localVar.initializer!! to CodeInsightUtil.findReferenceExpressions(method, localVar) } else { expr to ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences() } - val type = initializer.getType() + val type = initializer.type val parametersToRemove = Util.findParametersToRemove(method, initializer, occurrences) - val codeStyleManager = JavaCodeStyleManager.getInstance(getProject()) + val codeStyleManager = JavaCodeStyleManager.getInstance(project) val info = codeStyleManager.suggestUniqueVariableName( - codeStyleManager.suggestVariableName(VariableKind.PARAMETER, localVar?.getName(), initializer, type), + codeStyleManager.suggestVariableName(VariableKind.PARAMETER, localVar?.name, initializer, type), expr, true ) @@ -183,7 +183,7 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe initializer ) - IntroduceParameterProcessor(getProject(), + IntroduceParameterProcessor(project, method, methodToSearchFor, initializer, @@ -198,7 +198,7 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe null, parametersToRemove).run() - getEditor().getSelectionModel().removeSelection() + editor.selectionModel.removeSelection() } } @@ -227,9 +227,9 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe } } val handler = KotlinIntroducePropertyHandler(helper) - val editor = fixture.getEditor() + val editor = fixture.editor handler.selectElements(editor, file) { elements, previousSibling -> - handler.doInvoke(getProject(), editor, file, elements, explicitPreviousSibling ?: previousSibling) + handler.doInvoke(project, editor, file, elements, explicitPreviousSibling ?: previousSibling) } } } @@ -251,13 +251,13 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe if (it.isNotEmpty()) { @Suppress("CAST_NEVER_SUCCEEDS") val args = it.map { it.toBoolean() }.toTypedArray() as Array - ExtractionOptions::class.java.getConstructors().first { it.getParameterTypes().size == args.size }.newInstance(*args) as ExtractionOptions + ExtractionOptions::class.java.constructors.first { it.parameterTypes.size == args.size }.newInstance(*args) as ExtractionOptions } else ExtractionOptions.DEFAULT } val renderer = DescriptorRenderer.DEBUG_TEXT - val editor = fixture.getEditor() + val editor = fixture.editor val handler = ExtractKotlinFunctionHandler( helper = object : ExtractionEngineHelper(EXTRACT_FUNCTION) { override fun adjustExtractionData(data: ExtractionData): ExtractionData { @@ -312,17 +312,17 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe val afterFile = File("$path.after") val conflictFile = File("$path.conflicts") - fixture.setTestDataPath("${KotlinTestUtils.getHomeDirectory()}/${mainFile.getParent()}") + fixture.testDataPath = "${KotlinTestUtils.getHomeDirectory()}/${mainFile.parent}" - val mainFileName = mainFile.getName() + val mainFileName = mainFile.name val mainFileBaseName = FileUtil.getNameWithoutExtension(mainFileName) - val extraFiles = mainFile.getParentFile().listFiles { file, name -> + val extraFiles = mainFile.parentFile.listFiles { file, name -> name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java")) } - val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.getName()) } + val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.name) } val file = fixture.configureByFile(mainFileName) - val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.getText(), "// WITH_RUNTIME") != null + val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null if (addKotlinRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk()) } @@ -331,11 +331,11 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe action(file) assert(!conflictFile.exists()) { "Conflict file $conflictFile should not exist" } - KotlinTestUtils.assertEqualsToFile(afterFile, file.getText()!!) + KotlinTestUtils.assertEqualsToFile(afterFile, file.text!!) if (checkAdditionalAfterdata) { for ((extraPsiFile, extraFile) in extraFilesToPsi) { - KotlinTestUtils.assertEqualsToFile(File("${extraFile.getPath()}.after"), extraPsiFile.getText()) + KotlinTestUtils.assertEqualsToFile(File("${extraFile.path}.after"), extraPsiFile.text) } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt index 16474418aed..2951ea4ed6f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMoveTest.kt @@ -57,7 +57,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -public abstract class AbstractMoveTest : KotlinMultiFileTestCase() { +abstract class AbstractMoveTest : KotlinMultiFileTestCase() { protected fun doTest(path: String) { val config = JsonParser().parse(FileUtil.loadFile(File(path), true)) as JsonObject @@ -68,16 +68,16 @@ public abstract class AbstractMoveTest : KotlinMultiFileTestCase() { val conflictFile = File(testDir + "/conflicts.txt") - val withRuntime = config["withRuntime"]?.getAsBoolean() ?: false + val withRuntime = config["withRuntime"]?.asBoolean ?: false if (withRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk()) } doTest({ rootDir, rootAfter -> val mainFile = rootDir.findFileByRelativePath(mainFilePath)!! - val mainPsiFile = PsiManager.getInstance(getProject()!!).findFile(mainFile)!! + val mainPsiFile = PsiManager.getInstance(project!!).findFile(mainFile)!! val document = FileDocumentManager.getInstance().getDocument(mainFile)!! - val editor = EditorFactory.getInstance()!!.createEditor(document, getProject()!!)!! + val editor = EditorFactory.getInstance()!!.createEditor(document, project!!)!! val caretOffset = extractCaretOffset(document) val elementAtCaret = if (caretOffset >= 0) { @@ -95,10 +95,10 @@ public abstract class AbstractMoveTest : KotlinMultiFileTestCase() { assert(!conflictFile.exists()) } catch(e: ConflictsInTestsException) { - KotlinTestUtils.assertEqualsToFile(conflictFile, e.getMessages().sorted().joinToString("\n")) + KotlinTestUtils.assertEqualsToFile(conflictFile, e.messages.sorted().joinToString("\n")) } finally { - PsiDocumentManager.getInstance(getProject()!!).commitAllDocuments() + PsiDocumentManager.getInstance(project!!).commitAllDocuments() FileDocumentManager.getInstance().saveAllDocuments() EditorFactory.getInstance()!!.releaseEditor(editor) @@ -116,11 +116,11 @@ public abstract class AbstractMoveTest : KotlinMultiFileTestCase() { return testName.substring(0, testName.lastIndexOf('_')).replace('_', '/') } - protected override fun getTestRoot() : String { + override fun getTestRoot() : String { return "/refactoring/move/" } - protected override fun getTestDataPath() : String { + override fun getTestDataPath() : String { return PluginTestCaseBase.getTestDataPathBase() } } @@ -134,10 +134,10 @@ enum class MoveAction { val options = MockMoveMembersOptions(targetClassName, arrayOf(member)) if (visibility != null) { - options.setMemberVisibility(visibility) + options.memberVisibility = visibility } - MoveMembersProcessor(elementAtCaret.getProject(), options).run() + MoveMembersProcessor(elementAtCaret.project, options).run() } }, @@ -147,9 +147,9 @@ enum class MoveAction { val targetPackage = config.getString("targetPackage") MoveClassesOrPackagesProcessor( - mainFile.getProject(), + mainFile.project, arrayOf(classToMove), - MultipleRootsMoveDestination(PackageWrapper(mainFile.getManager(), targetPackage)), + MultipleRootsMoveDestination(PackageWrapper(mainFile.manager, targetPackage)), /* searchInComments = */ false, /* searchInNonJavaFiles = */ true, /* moveCallback = */ null @@ -159,14 +159,14 @@ enum class MoveAction { MOVE_PACKAGES { override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) { - val project = mainFile.getProject() + val project = mainFile.project val sourcePackage = config.getString("sourcePackage") val targetPackage = config.getString("targetPackage") MoveClassesOrPackagesProcessor( project, arrayOf(JavaPsiFacade.getInstance(project).findPackage(sourcePackage)!!), - MultipleRootsMoveDestination(PackageWrapper(mainFile.getManager(), targetPackage)), + MultipleRootsMoveDestination(PackageWrapper(mainFile.manager, targetPackage)), /* searchInComments = */ false, /* searchInNonJavaFiles = */ true, /* moveCallback = */ null @@ -176,7 +176,7 @@ enum class MoveAction { MOVE_TOP_LEVEL_CLASSES_TO_INNER { override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) { - val project = mainFile.getProject() + val project = mainFile.project val classToMove = elementAtCaret!!.getNonStrictParentOfType()!! val targetClass = config.getString("targetClass") @@ -194,10 +194,10 @@ enum class MoveAction { MOVE_INNER_CLASS { override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) { - val project = mainFile.getProject() + val project = mainFile.project val classToMove = elementAtCaret!!.getNonStrictParentOfType()!! - val newClassName = config.getNullableString("newClassName") ?: classToMove.getName()!! + val newClassName = config.getNullableString("newClassName") ?: classToMove.name!! val outerInstanceParameterName = config.getNullableString("outerInstanceParameterName") val targetPackage = config.getString("targetPackage") @@ -207,14 +207,14 @@ enum class MoveAction { newClassName, outerInstanceParameterName != null, outerInstanceParameterName, - JavaPsiFacade.getInstance(project).findPackage(targetPackage)!!.getDirectories()[0] + JavaPsiFacade.getInstance(project).findPackage(targetPackage)!!.directories[0] ).run() } }, MOVE_FILES { override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) { - val project = mainFile.getProject() + val project = mainFile.project val targetPackage = config.getNullableString("targetPackage") if (targetPackage != null) { @@ -222,7 +222,7 @@ enum class MoveAction { MoveFilesOrDirectoriesProcessor( project, arrayOf(mainFile), - JavaPsiFacade.getInstance(project).findPackage(targetPackage)!!.getDirectories()[0], + JavaPsiFacade.getInstance(project).findPackage(targetPackage)!!.directories[0], /* searchInComments = */ false, /* searchInNonJavaFiles = */ true, /* moveCallback = */ null, @@ -245,7 +245,7 @@ enum class MoveAction { MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS { override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) { - val project = mainFile.getProject() + val project = mainFile.project val elementToMove = elementAtCaret!!.getNonStrictParentOfType()!! val moveTarget = config.getNullableString("targetPackage")?.let { packageName -> diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/KotlinNameSuggesterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/KotlinNameSuggesterTest.kt index 2fa4ccbf9a8..e083d72c7a0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/KotlinNameSuggesterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/KotlinNameSuggesterTest.kt @@ -29,66 +29,66 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils -public class KotlinNameSuggesterTest : LightCodeInsightFixtureTestCase() { - public fun testArrayList() { doTest() } +class KotlinNameSuggesterTest : LightCodeInsightFixtureTestCase() { + fun testArrayList() { doTest() } - public fun testGetterSure() { doTest() } + fun testGetterSure() { doTest() } - public fun testNameArrayOfClasses() { doTest() } + fun testNameArrayOfClasses() { doTest() } - public fun testNameArrayOfStrings() { doTest() } + fun testNameArrayOfStrings() { doTest() } - public fun testNamePrimitiveArray() { doTest() } + fun testNamePrimitiveArray() { doTest() } - public fun testNameCallExpression() { doTest() } + fun testNameCallExpression() { doTest() } - public fun testNameClassCamelHump() { doTest() } + fun testNameClassCamelHump() { doTest() } - public fun testNameLong() { doTest() } + fun testNameLong() { doTest() } - public fun testNameReferenceExpression() { doTest() } + fun testNameReferenceExpression() { doTest() } - public fun testNameString() { doTest() } + fun testNameString() { doTest() } - public fun testAnonymousObject() { doTest() } + fun testAnonymousObject() { doTest() } - public fun testAnonymousObjectWithSuper() { doTest() } + fun testAnonymousObjectWithSuper() { doTest() } - public fun testArrayOfObjectsType() { doTest() } + fun testArrayOfObjectsType() { doTest() } - public fun testURL() { doTest() } + fun testURL() { doTest() } - public fun testParameterNameByArgumentExpression() { doTest() } + fun testParameterNameByArgumentExpression() { doTest() } - public fun testParameterNameByParenthesizedArgumentExpression() { doTest() } + fun testParameterNameByParenthesizedArgumentExpression() { doTest() } - public fun testIdWithDigits() { doTest() } + fun testIdWithDigits() { doTest() } - public fun testIdWithNonASCII() { doTest() } + fun testIdWithNonASCII() { doTest() } - public fun testFunction1() { doTest() } + fun testFunction1() { doTest() } - public fun testFunction2() { doTest() } + fun testFunction2() { doTest() } - public fun testExtensionFunction1() { doTest() } + fun testExtensionFunction1() { doTest() } - public fun testExtensionFunction2() { doTest() } + fun testExtensionFunction2() { doTest() } override fun setUp() { super.setUp() - myFixture.setTestDataPath(PluginTestCaseBase.getTestDataPathBase() + "/refactoring/nameSuggester") + myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/refactoring/nameSuggester" } private fun doTest() { myFixture.configureByFile(getTestName(false) + ".kt") - val file = myFixture.getFile() as KtFile + val file = myFixture.file as KtFile val expectedResultText = KotlinTestUtils.getLastCommentInFile(file) val withRuntime = InTextDirectivesUtils.isDirectiveDefined(file.text, "//WITH_RUNTIME") try { if (withRuntime) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk()) } - KotlinRefactoringUtil.selectExpression(myFixture.getEditor(), file, object : KotlinRefactoringUtil.SelectExpressionCallback { + KotlinRefactoringUtil.selectExpression(myFixture.editor, file, object : KotlinRefactoringUtil.SelectExpressionCallback { override fun run(expression: KtExpression?) { val names = KotlinNameSuggester.suggestNamesByExpressionAndType(expression!!, null, expression.analyze(BodyResolveMode.PARTIAL), { true }, "value").sorted() val result = StringUtil.join(names, "\n").trim() diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/pullUp/AbstractPullUpTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/pullUp/AbstractPullUpTest.kt index 478e18efa14..4b29d13287d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/pullUp/AbstractPullUpTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/pullUp/AbstractPullUpTest.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo import org.jetbrains.kotlin.idea.refactoring.memberInfo.qualifiedClassNameForRendering import org.jetbrains.kotlin.test.InTextDirectivesUtils -public abstract class AbstractPullUpTest : AbstractMemberPullPushTest() { +abstract class AbstractPullUpTest : AbstractMemberPullPushTest() { private fun getTargetClassName(file: PsiFile) = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TARGET_CLASS: ") protected fun doKotlinTest(path: String) { @@ -47,7 +47,7 @@ public abstract class AbstractPullUpTest : AbstractMemberPullPushTest() { return superClasses.first() } } - KotlinPullUpHandler().invoke(getProject(), getEditor(), file) { + KotlinPullUpHandler().invoke(project, editor, file) { if (it == KotlinPullUpHandler.PULL_UP_TEST_HELPER_KEY) helper else null } } @@ -56,7 +56,7 @@ public abstract class AbstractPullUpTest : AbstractMemberPullPushTest() { // Based on com.intellij.refactoring.PullUpTest.doTest() protected fun doJavaTest(path: String) { doTest(path) { file -> - val elementAt = getFile().findElementAt(getEditor().caretModel.offset) + val elementAt = getFile().findElementAt(editor.caretModel.offset) val sourceClass = PsiTreeUtil.getParentOfType(elementAt, PsiClass::class.java)!! val targetClassName = getTargetClassName(file) diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/pushDown/AbstractPushDownTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/pushDown/AbstractPushDownTest.kt index 8579f8995ed..9419d11864d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/pushDown/AbstractPushDownTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/pushDown/AbstractPushDownTest.kt @@ -19,13 +19,13 @@ package org.jetbrains.kotlin.idea.refactoring.pushDown import org.jetbrains.kotlin.idea.refactoring.AbstractMemberPullPushTest import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo -public abstract class AbstractPushDownTest : AbstractMemberPullPushTest() { +abstract class AbstractPushDownTest : AbstractMemberPullPushTest() { protected fun doTest(path: String) { doTest(path) { file -> val helper = object: KotlinPushDownHandler.TestHelper { override fun adjustMembers(members: List) = chooseMembers(members) } - KotlinPushDownHandler().invoke(getProject(), getEditor(), file) { + KotlinPushDownHandler().invoke(project, editor, file) { if (it == KotlinPushDownHandler.PUSH_DOWN_TEST_HELPER_KEY) helper else null } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt index c5e06c42461..759d9ccded9 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt @@ -72,13 +72,13 @@ private enum class RenameType { BUNDLE_PROPERTY } -public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { +abstract class AbstractRenameTest : KotlinMultiFileTestCase() { inner class TestContext( val project: Project = getProject()!!, val javaFacade: JavaPsiFacade = getJavaFacade()!!, val module: Module = getModule()!!) - public open fun doTest(path : String) { + open fun doTest(path : String) { val fileText = FileUtil.loadFile(File(path), true) val jsonParser = JsonParser() @@ -112,7 +112,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { Assert.fail("""Hint "$hintDirective" was expected""") } - if (renameObject["checkErrorsAfter"]?.getAsBoolean() ?: false) { + if (renameObject["checkErrorsAfter"]?.asBoolean ?: false) { val psiManager = PsiManager.getInstance(myProject) val visitor = object : VirtualFileVisitor() { override fun visitFile(file: VirtualFile): Boolean { @@ -121,7 +121,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { } } - for (sourceRoot in ModuleRootManager.getInstance(myModule).getSourceRoots()) { + for (sourceRoot in ModuleRootManager.getInstance(myModule).sourceRoots) { VfsUtilCore.visitChildrenRecursively(sourceRoot, visitor) } } @@ -148,13 +148,13 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { val psiFile = PsiManager.getInstance(context.project).findFile(mainFile)!! val MARKER_TEXT = "/*rename*/" - val marker = psiFile.getText().indexOf(MARKER_TEXT) + val marker = psiFile.text.indexOf(MARKER_TEXT) assert(marker != -1) - val toRename = if (renameParamsObject["byRef"]?.getAsBoolean() ?: false) { + val toRename = if (renameParamsObject["byRef"]?.asBoolean ?: false) { val editor = createEditor(mainFile) - editor.getCaretModel().moveToOffset(marker + MARKER_TEXT.length) - TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.getInstance().getAllAccepted())!! + editor.caretModel.moveToOffset(marker + MARKER_TEXT.length) + TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.getInstance().allAccepted)!! } else { psiFile.findElementAt(marker + MARKER_TEXT.length)!!.getNonStrictParentOfType()!! @@ -185,7 +185,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { doTestCommittingDocuments { rootDir, rootAfter -> val aClass = context.javaFacade.findClass(classFQN, GlobalSearchScope.moduleScope(context.module))!! - val methodText = context.javaFacade.getElementFactory().createMethodFromText(methodSignature + "{}", null) + val methodText = context.javaFacade.elementFactory.createMethodFromText(methodSignature + "{}", null) val method = aClass.findMethodBySignature(methodText, false) if (method == null) throw IllegalStateException("Method with signature '$methodSignature' wasn't found in class $classFQN") @@ -225,10 +225,10 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { val document = FileDocumentManager.getInstance().getDocument(mainFile)!! val jetFile = PsiDocumentManager.getInstance(context.project).getPsiFile(document) as KtFile - val fileFqn = jetFile.getPackageFqName() + val fileFqn = jetFile.packageFqName Assert.assertTrue("File '${mainFilePath}' should have package containing ${fqn}", fileFqn.isSubpackageOf(fqn)) - val packageSegment = jetFile.getPackageDirective()!!.getPackageNames()[fqn.pathSegments().size - 1] + val packageSegment = jetFile.packageDirective!!.packageNames[fqn.pathSegments().size - 1] val segmentReference = packageSegment.mainReference val psiElement = segmentReference.resolve()!! @@ -321,16 +321,16 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { super.doTest(MultiFileTestCase.PerformAction { rootDir, rootAfter -> action(rootDir, rootAfter) - PsiDocumentManager.getInstance(getProject()!!).commitAllDocuments() + PsiDocumentManager.getInstance(project!!).commitAllDocuments() FileDocumentManager.getInstance().saveAllDocuments() }, getTestDirName(true)) } - protected override fun getTestRoot() : String { + override fun getTestRoot() : String { return "/refactoring/rename/" } - protected override fun getTestDataPath() : String { + override fun getTestDataPath() : String { return PluginTestCaseBase.getTestDataPathBase() } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractAdditionalResolveDescriptorRendererTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractAdditionalResolveDescriptorRendererTest.kt index faa93eccb8b..43001ec78b1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractAdditionalResolveDescriptorRendererTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractAdditionalResolveDescriptorRendererTest.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.TargetEnvironment import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.ResolveSession -public abstract class AbstractAdditionalResolveDescriptorRendererTest : AbstractDescriptorRendererTest() { +abstract class AbstractAdditionalResolveDescriptorRendererTest : AbstractDescriptorRendererTest() { override fun getDescriptor(declaration: KtDeclaration, container: ComponentProvider): DeclarationDescriptor { if (declaration is KtAnonymousInitializer || KtPsiUtil.isLocal(declaration)) { return container.get() diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt index e85c311ded0..b4986f8166a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt @@ -45,11 +45,11 @@ import org.jetbrains.kotlin.idea.KotlinFileType import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.idea.util.application.executeWriteCommand -public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory() override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE - public fun doTest(testPath: String) { + fun doTest(testPath: String) { val dumpNormal = dump(testPath, BodyResolveMode.PARTIAL) val testPathNoExt = FileUtil.getNameWithoutExtension(testPath) @@ -68,15 +68,15 @@ public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFix private fun dump(testPath: String, resolveMode: BodyResolveMode): String { myFixture.configureByText(KotlinFileType.INSTANCE, File(testPath).readText()) - val file = myFixture.getFile() as KtFile - val editor = myFixture.getEditor() - val selectionModel = editor.getSelectionModel() + val file = myFixture.file as KtFile + val editor = myFixture.editor + val selectionModel = editor.selectionModel val expression = if (selectionModel.hasSelection()) { - PsiTreeUtil.findElementOfClassAtRange(file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(), KtExpression::class.java) + PsiTreeUtil.findElementOfClassAtRange(file, selectionModel.selectionStart, selectionModel.selectionEnd, KtExpression::class.java) ?: error("No JetExpression at selection range") } else { - val offset = editor.getCaretModel().getOffset() + val offset = editor.caretModel.offset val element = file.findElementAt(offset)!! element.getNonStrictParentOfType() ?: error("No JetSimpleNameExpression at caret") } @@ -105,18 +105,18 @@ public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFix val skippedStatements = set .filter { !it.parents.any { it in set } } // do not include skipped statements which are inside other skipped statement - .sortedBy { it.getTextOffset() } + .sortedBy { it.textOffset } - myFixture.getProject().executeWriteCommand("") { + myFixture.project.executeWriteCommand("") { for (statement in skippedStatements) { - statement.replace(KtPsiFactory(getProject()).createComment("/* STATEMENT DELETED: ${statement.compactPresentation()} */")) + statement.replace(KtPsiFactory(project).createComment("/* STATEMENT DELETED: ${statement.compactPresentation()} */")) } } - val fileText = file.getText() + val fileText = file.text if (selectionModel.hasSelection()) { - val start = selectionModel.getSelectionStart() - val end = selectionModel.getSelectionEnd() + val start = selectionModel.selectionStart + val end = selectionModel.selectionEnd builder.append(fileText.substring(0, start)) builder.append("") builder.append(fileText.substring(start, end)) @@ -124,7 +124,7 @@ public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFix builder.append(fileText.substring(end)) } else { - val newCaretOffset = editor.getCaretModel().getOffset() + val newCaretOffset = editor.caretModel.offset builder.append(fileText.substring(0, newCaretOffset)) builder.append("") builder.append(fileText.substring(newCaretOffset)) @@ -148,11 +148,11 @@ public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFix val processedStatements = bindingContext.getSliceContents(BindingContext.PROCESSED) .filter { it.value } .map { it.key } - .filter { it.getParent() is KtBlockExpression } + .filter { it.parent is KtBlockExpression } val receiver = (expression as? KtSimpleNameExpression)?.getReceiverExpression() val expressionWithType = if (receiver != null) { - expression.getParent() as? KtExpression ?: expression + expression.parent as? KtExpression ?: expression } else { expression @@ -167,7 +167,7 @@ public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFix val s = DescriptorRenderer.COMPACT.render(this) - val renderType = this is VariableDescriptor && type != this.getReturnType() + val renderType = this is VariableDescriptor && type != this.returnType if (!renderType) return s return "$s smart-cast to ${type.presentation()}" } @@ -176,7 +176,7 @@ public abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFix = if (this != null) DescriptorRenderer.COMPACT.renderType(this) else "unknown type" private fun KtExpression.compactPresentation(): String { - val text = getText() + val text = text val builder = StringBuilder() var dropSpace = false for (c in text) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInJavaTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInJavaTest.kt index 03ce2436f60..541ad40dc49 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInJavaTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInJavaTest.kt @@ -20,8 +20,8 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase private val FILE_WITH_KOTLIN_CODE = PluginTestCaseBase.getTestDataPathBase() + "/resolve/referenceInJava/dependencies.kt" -public abstract class AbstractReferenceResolveInJavaTest : AbstractReferenceResolveTest() { - protected override fun doTest(path: String) { +abstract class AbstractReferenceResolveInJavaTest : AbstractReferenceResolveTest() { + override fun doTest(path: String) { assert(path.endsWith(".java")) { path } myFixture.configureByFile(FILE_WITH_KOTLIN_CODE) myFixture.configureByFile(path) diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt index ce2c4eda940..ec2e716ec0a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.junit.Assert import junit.framework.AssertionFailedError -public abstract class AbstractReferenceResolveInLibrarySourcesTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractReferenceResolveInLibrarySourcesTest : KotlinLightCodeInsightFixtureTestCase() { companion object { private val REF_CARET_MARKER = "" } @@ -34,25 +34,25 @@ public abstract class AbstractReferenceResolveInLibrarySourcesTest : KotlinLight fixture.configureByFile(path) - val expectedResolveData = AbstractReferenceResolveTest.readResolveData(fixture.getFile()!!.getText(), 0) + val expectedResolveData = AbstractReferenceResolveTest.readResolveData(fixture.file!!.text, 0) - val gotoData = NavigationTestUtils.invokeGotoImplementations(fixture.getEditor(), fixture.getFile())!! + val gotoData = NavigationTestUtils.invokeGotoImplementations(fixture.editor, fixture.file)!! Assert.assertEquals("Single target expected for origianl file", 1, gotoData.targets.size) - val testedPsiElement = gotoData.targets[0].getNavigationElement() - val testedElementFile = testedPsiElement.getContainingFile()!! + val testedPsiElement = gotoData.targets[0].navigationElement + val testedElementFile = testedPsiElement.containingFile!! - val lineContext = InTextDirectivesUtils.findStringWithPrefixes(fixture.getFile()!!.getText(), "CONTEXT:") + val lineContext = InTextDirectivesUtils.findStringWithPrefixes(fixture.file!!.text, "CONTEXT:") if (lineContext == null) { - throw AssertionFailedError("'CONTEXT: ' directive is expected to set up position in library file: ${testedElementFile.getName()}") + throw AssertionFailedError("'CONTEXT: ' directive is expected to set up position in library file: ${testedElementFile.name}") } val inContextOffset = lineContext.indexOf(REF_CARET_MARKER) if (inContextOffset == -1) throw IllegalStateException("No '$REF_CARET_MARKER' marker found in 'CONTEXT: $lineContext'") val contextStr = lineContext.replace(REF_CARET_MARKER, "") - val offsetInFile = testedElementFile.getText()!!.indexOf(contextStr) - if (offsetInFile == -1) throw IllegalStateException("Context '$contextStr' wasn't found in file ${testedElementFile.getName()}") + val offsetInFile = testedElementFile.text!!.indexOf(contextStr) + if (offsetInFile == -1) throw IllegalStateException("Context '$contextStr' wasn't found in file ${testedElementFile.name}") val offset = offsetInFile + inContextOffset @@ -61,6 +61,6 @@ public abstract class AbstractReferenceResolveInLibrarySourcesTest : KotlinLight AbstractReferenceResolveTest.checkReferenceResolve(expectedResolveData, offset, reference) } - override fun getTestDataPath() : String = File(PluginTestCaseBase.getTestDataPathBase(), "/resolve/referenceInLib").getPath() + File.separator + override fun getTestDataPath() : String = File(PluginTestCaseBase.getTestDataPathBase(), "/resolve/referenceInLib").path + File.separator override fun fileName(): String = getTestName(true) + ".kt" } diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt index c77b823ea97..ba50e904a0d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt @@ -31,10 +31,10 @@ import org.jetbrains.kotlin.test.util.configureWithExtraFile import org.junit.Assert import kotlin.test.assertTrue -public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsightFixtureTestCase() { - public class ExpectedResolveData(private val shouldBeUnresolved: Boolean?, public val referenceString: String) { +abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsightFixtureTestCase() { + class ExpectedResolveData(private val shouldBeUnresolved: Boolean?, val referenceString: String) { - public fun shouldBeUnresolved(): Boolean { + fun shouldBeUnresolved(): Boolean { return shouldBeUnresolved!! } } @@ -46,7 +46,7 @@ public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsi } protected fun performChecks() { - if (InTextDirectivesUtils.isDirectiveDefined(myFixture.getFile().getText(), MULTIRESOLVE)) { + if (InTextDirectivesUtils.isDirectiveDefined(myFixture.file.text, MULTIRESOLVE)) { doMultiResolveTest() } else { @@ -56,17 +56,17 @@ public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsi protected fun doSingleResolveTest() { forEachCaret { index, offset -> - val expectedResolveData = readResolveData(myFixture.getFile().getText(), index) - val psiReference = myFixture.getFile().findReferenceAt(offset) + val expectedResolveData = readResolveData(myFixture.file.text, index) + val psiReference = myFixture.file.findReferenceAt(offset) checkReferenceResolve(expectedResolveData, offset, psiReference) } } protected fun doMultiResolveTest() { forEachCaret { index, offset -> - val expectedReferences = getExpectedReferences(myFixture.getFile().getText(), index) + val expectedReferences = getExpectedReferences(myFixture.file.text, index) - val psiReference = myFixture.getFile().findReferenceAt(offset) + val psiReference = myFixture.file.findReferenceAt(offset) assertTrue(psiReference is PsiPolyVariantReference) psiReference as PsiPolyVariantReference @@ -74,7 +74,7 @@ public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsi val actualResolvedTo = Lists.newArrayList() for (result in results) { - actualResolvedTo.add(ReferenceUtils.renderAsGotoImplementation(result.getElement()!!)) + actualResolvedTo.add(ReferenceUtils.renderAsGotoImplementation(result.element!!)) } UsefulTestCase.assertOrderedEquals("Not matching for reference #$index", actualResolvedTo.sorted(), expectedReferences.sorted()) @@ -82,7 +82,7 @@ public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsi } private fun forEachCaret(action: (index: Int, offset: Int) -> Unit) { - val offsets = myFixture.getEditor().getCaretModel().getAllCarets().map { it.getOffset() } + val offsets = myFixture.editor.caretModel.allCarets.map { it.offset } val singleCaret = offsets.size == 1 for ((index, offset) in offsets.withIndex()) { action(if (singleCaret) -1 else index + 1, offset) @@ -94,10 +94,10 @@ public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsi override fun getTestDataPath() = "./" companion object { - public val MULTIRESOLVE: String = "MULTIRESOLVE" - public val REF_EMPTY: String = "REF_EMPTY" + val MULTIRESOLVE: String = "MULTIRESOLVE" + val REF_EMPTY: String = "REF_EMPTY" - public fun readResolveData(fileText: String, index: Int): ExpectedResolveData { + fun readResolveData(fileText: String, index: Int): ExpectedResolveData { val shouldBeUnresolved = InTextDirectivesUtils.isDirectiveDefined(fileText, REF_EMPTY) val refs = getExpectedReferences(fileText, index) @@ -126,7 +126,7 @@ public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsi } } - public fun checkReferenceResolve(expectedResolveData: ExpectedResolveData, offset: Int, psiReference: PsiReference?) { + fun checkReferenceResolve(expectedResolveData: ExpectedResolveData, offset: Int, psiReference: PsiReference?) { if (psiReference != null) { val resolvedTo = psiReference.resolve() if (resolvedTo != null) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt index 3d197320bb8..3af89d5ff44 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt @@ -55,14 +55,14 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { override fun getModule() = myModule!! fun testMainInTest() { - val createResult = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!) + val createResult = configureModule(moduleDirPath("module"), getTestProject().baseDir!!) ConfigLibraryUtil.configureKotlinRuntimeAndSdk(createResult.module, PluginTestCaseBase.mockJdk()) val runConfiguration = createConfigurationFromMain("some.main") val javaParameters = getJavaRunParameters(runConfiguration) - Assert.assertTrue(javaParameters.getClassPath().getRootDirs().contains(createResult.srcOutputDir)) - Assert.assertTrue(javaParameters.getClassPath().getRootDirs().contains(createResult.testOutputDir)) + Assert.assertTrue(javaParameters.classPath.rootDirs.contains(createResult.srcOutputDir)) + Assert.assertTrue(javaParameters.classPath.rootDirs.contains(createResult.testOutputDir)) fun functionVisitor(function: KtNamedFunction) { val options = function.bodyExpression?.allChildren?.filterIsInstance()?.map { it.text.trim().replace("//", "").trim() }?.filter { it.isNotBlank() }?.toList() ?: emptyList() @@ -111,25 +111,25 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { } fun testDependencyModuleClasspath() { - val dependencyModuleSrcDir = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!).srcOutputDir + val dependencyModuleSrcDir = configureModule(moduleDirPath("module"), getTestProject().baseDir!!).srcOutputDir - val moduleWithDependencyDir = runWriteAction { getTestProject().getBaseDir()!!.createChildDirectory(this, "moduleWithDependency") } + val moduleWithDependencyDir = runWriteAction { getTestProject().baseDir!!.createChildDirectory(this, "moduleWithDependency") } val moduleWithDependency = createModule("moduleWithDependency") - ModuleRootModificationUtil.setModuleSdk(moduleWithDependency, getTestProjectJdk()) + ModuleRootModificationUtil.setModuleSdk(moduleWithDependency, testProjectJdk) val moduleWithDependencySrcDir = configureModule( moduleDirPath("moduleWithDependency"), moduleWithDependencyDir, configModule = moduleWithDependency).srcOutputDir - ModuleRootModificationUtil.addDependency(moduleWithDependency, getModule()) + ModuleRootModificationUtil.addDependency(moduleWithDependency, module) val jetRunConfiguration = createConfigurationFromMain("some.test.main") jetRunConfiguration.setModule(moduleWithDependency) val javaParameters = getJavaRunParameters(jetRunConfiguration) - Assert.assertTrue(javaParameters.getClassPath().getRootDirs().contains(dependencyModuleSrcDir)) - Assert.assertTrue(javaParameters.getClassPath().getRootDirs().contains(moduleWithDependencySrcDir)) + Assert.assertTrue(javaParameters.classPath.rootDirs.contains(dependencyModuleSrcDir)) + Assert.assertTrue(javaParameters.classPath.rootDirs.contains(moduleWithDependencySrcDir)) } fun testClassesAndObjects() { @@ -141,7 +141,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { } fun testUpdateOnClassRename() { - val createModuleResult = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!) + val createModuleResult = configureModule(moduleDirPath("module"), getTestProject().baseDir!!) ConfigLibraryUtil.configureKotlinRuntimeAndSdk(createModuleResult.module, PluginTestCaseBase.mockJdk()) val runConfiguration = createConfigurationFromObject("renameTest.Foo", save = true) @@ -154,7 +154,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { } fun testUpdateOnPackageRename() { - val createModuleResult = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!) + val createModuleResult = configureModule(moduleDirPath("module"), getTestProject().baseDir!!) ConfigLibraryUtil.configureKotlinRuntimeAndSdk(createModuleResult.module, PluginTestCaseBase.mockJdk()) val runConfiguration = createConfigurationFromObject("renameTest.Foo", save = true) @@ -167,7 +167,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { } private fun doTest(configureRuntime: (Module, Sdk) -> Unit) { - val baseDir = getTestProject().getBaseDir()!! + val baseDir = getTestProject().baseDir!! val createModuleResult = configureModule(moduleDirPath("module"), baseDir) val srcDir = createModuleResult.srcDir @@ -182,7 +182,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { object : KtTreeVisitorVoid() { override fun visitComment(comment: PsiComment) { val declaration = comment.getStrictParentOfType()!! - val text = comment.getText() ?: return + val text = comment.text ?: return if (!text.startsWith(RUN_PREFIX)) return val expectedClass = text.substring(RUN_PREFIX.length).trim() @@ -191,7 +191,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { val dataContext = MapDataContext() dataContext.put(Location.DATA_KEY, PsiLocation(getTestProject(), declaration)) val context = ConfigurationContext.getFromContext(dataContext) - val actualClass = (context.getConfiguration()?.getConfiguration() as? JetRunConfiguration)?.getRunClass() + val actualClass = (context.configuration?.configuration as? JetRunConfiguration)?.runClass if (actualClass != null) { actualClasses.add(actualClass) } @@ -213,18 +213,18 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { private fun createConfigurationFromObject(objectFqn: String, save: Boolean = false): JetRunConfiguration { val obj = KotlinFullClassNameIndex.getInstance().get(objectFqn, getTestProject(), getTestProject().allScope()).single() - val mainFunction = obj.getDeclarations().single { it is KtFunction && it.getName() == "main" } + val mainFunction = obj.declarations.single { it is KtFunction && it.getName() == "main" } return createConfigurationFromElement(mainFunction, save) as JetRunConfiguration } - private fun configureModule(moduleDir: String, outputParentDir: VirtualFile, configModule: Module = getModule()): CreateModuleResult { + private fun configureModule(moduleDir: String, outputParentDir: VirtualFile, configModule: Module = module): CreateModuleResult { val srcPath = moduleDir + "/src" - val srcDir = PsiTestUtil.createTestProjectStructure(getProject(), configModule, srcPath, PlatformTestCase.myFilesToDelete, true) + val srcDir = PsiTestUtil.createTestProjectStructure(project, configModule, srcPath, PlatformTestCase.myFilesToDelete, true) val testPath = moduleDir + "/test" if (File(testPath).exists()) { - val testDir = PsiTestUtil.createTestProjectStructure(getProject(), configModule, testPath, PlatformTestCase.myFilesToDelete, false) - PsiTestUtil.addSourceRoot(getModule(), testDir, true) + val testDir = PsiTestUtil.createTestProjectStructure(project, configModule, testPath, PlatformTestCase.myFilesToDelete, false) + PsiTestUtil.addSourceRoot(module, testDir, true) } val (srcOutDir, testOutDir) = runWriteAction { @@ -232,8 +232,8 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { val srcOutDir = outDir.createChildDirectory(this, "production") val testOutDir = outDir.createChildDirectory(this, "test") - PsiTestUtil.setCompilerOutputPath(configModule, srcOutDir.getUrl(), false) - PsiTestUtil.setCompilerOutputPath(configModule, testOutDir.getUrl(), true) + PsiTestUtil.setCompilerOutputPath(configModule, srcOutDir.url, false) + PsiTestUtil.setCompilerOutputPath(configModule, testOutDir.url, true) Pair(srcOutDir, testOutDir) } @@ -243,7 +243,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { return CreateModuleResult(configModule, srcDir, srcOutDir, testOutDir) } - private fun moduleDirPath(moduleName: String) = "${getTestDataPath()}${getTestName(false)}/$moduleName" + private fun moduleDirPath(moduleName: String) = "${testDataPath}${getTestName(false)}/$moduleName" override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/run/" override fun getTestProjectJdk() = PluginTestCaseBase.mockJdk() diff --git a/idea/tests/org/jetbrains/kotlin/idea/run/StandaloneScriptRunConfigurationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/run/StandaloneScriptRunConfigurationTest.kt index 1333f6dfaf9..e19f9a81dad 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/run/StandaloneScriptRunConfigurationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/run/StandaloneScriptRunConfigurationTest.kt @@ -128,7 +128,7 @@ class StandaloneScriptRunConfigurationTest : KotlinCodeInsightTestCase() { MoveFilesOrDirectoriesProcessor( project, arrayOf(scriptFile), - JavaPsiFacade.getInstance(project).findPackage("dest")!!.getDirectories()[0], + JavaPsiFacade.getInstance(project).findPackage("dest")!!.directories[0], false, true, null, null ).run() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/run/runConfigurationTestUtil.kt b/idea/tests/org/jetbrains/kotlin/idea/run/runConfigurationTestUtil.kt index f84c55d887b..08945b18f21 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/run/runConfigurationTestUtil.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/run/runConfigurationTestUtil.kt @@ -39,18 +39,18 @@ fun getJavaRunParameters(configuration: RunConfiguration): JavaParameters { Assert.assertTrue(state is JavaCommandLine) configuration.checkConfiguration() - return (state as JavaCommandLine).getJavaParameters()!! + return (state as JavaCommandLine).javaParameters!! } fun createConfigurationFromElement(element: PsiElement, save: Boolean = false): RunConfiguration { val dataContext = MapDataContext() dataContext.put(Location.DATA_KEY, PsiLocation(element.project, element)) - val runnerAndConfigurationSettings = ConfigurationContext.getFromContext(dataContext).getConfiguration() + val runnerAndConfigurationSettings = ConfigurationContext.getFromContext(dataContext).configuration if (save) { RunManagerEx.getInstanceEx(element.project).setTemporaryConfiguration(runnerAndConfigurationSettings) } - return runnerAndConfigurationSettings!!.getConfiguration() + return runnerAndConfigurationSettings!!.configuration } diff --git a/idea/tests/org/jetbrains/kotlin/idea/structureView/AbstractKotlinFileStructureTest.kt b/idea/tests/org/jetbrains/kotlin/idea/structureView/AbstractKotlinFileStructureTest.kt index 7890645fb81..7e79c786c20 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/structureView/AbstractKotlinFileStructureTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/structureView/AbstractKotlinFileStructureTest.kt @@ -31,52 +31,52 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.util.configureWithExtraFile import java.io.File -public abstract class AbstractKotlinFileStructureTest : KotlinLightCodeInsightFixtureTestCase() { +abstract class AbstractKotlinFileStructureTest : KotlinLightCodeInsightFixtureTestCase() { override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/structureView/fileStructure" override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE - public fun doTest(path: String) { + fun doTest(path: String) { myFixture.configureWithExtraFile(path) - val textEditor = TextEditorProvider.getInstance()!!.getTextEditor(myFixture.getEditor()) - val popup = ViewStructureAction.createPopup(myFixture.getProject(), textEditor) + val textEditor = TextEditorProvider.getInstance()!!.getTextEditor(myFixture.editor) + val popup = ViewStructureAction.createPopup(myFixture.project, textEditor) if (popup == null) throw AssertionError("popup mustn't be null") popup.createCenterPanel() - popup.getTreeBuilder().getUi()!!.getUpdater()!!.setPassThroughMode(true) + popup.treeBuilder.ui!!.updater!!.setPassThroughMode(true) popup.update() popup.setup() val printInfo = PrintInfo(arrayOf("text"), arrayOf("location")) - val popupText = StructureViewUtil.print(popup.getTree(), false, printInfo, null) + val popupText = StructureViewUtil.print(popup.tree, false, printInfo, null) KotlinTestUtils.assertEqualsToFile(File("${FileUtil.getNameWithoutExtension(path)}.after"), popupText) } protected fun FileStructurePopup.setup() { - val fileText = FileUtil.loadFile(File(getTestDataPath(), fileName()), true) + val fileText = FileUtil.loadFile(File(testDataPath, fileName()), true) val withInherited = InTextDirectivesUtils.isDirectiveDefined(fileText, "WITH_INHERITED") setTreeActionState(KotlinInheritedMembersNodeProvider::class.java, withInherited) } - public fun FileStructurePopup.update() { - getTreeBuilder().refilter()!!.doWhenProcessed { + fun FileStructurePopup.update() { + treeBuilder.refilter()!!.doWhenProcessed { getStructure().rebuild() updateRecursively(getRootNode()) - getTreeBuilder().updateFromRoot() + treeBuilder.updateFromRoot() - TreeUtil.expandAll(getTree()) + TreeUtil.expandAll(tree) } } - fun FileStructurePopup.getFileStructureSpeedSearch() = getSpeedSearch() as FileStructurePopup.MyTreeSpeedSearch + fun FileStructurePopup.getFileStructureSpeedSearch() = speedSearch as FileStructurePopup.MyTreeSpeedSearch - fun FileStructurePopup.getStructure() = getTreeBuilder().getTreeStructure() as FilteringTreeStructure + fun FileStructurePopup.getStructure() = treeBuilder.treeStructure as FilteringTreeStructure - fun FileStructurePopup.getRootNode() = getTreeBuilder().getRootElement() as FilteringTreeStructure.FilteringNode + fun FileStructurePopup.getRootNode() = treeBuilder.rootElement as FilteringTreeStructure.FilteringNode fun FileStructurePopup.updateRecursively(node: FilteringTreeStructure.FilteringNode) { node.update() diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/DebugTextByStubTest.kt b/idea/tests/org/jetbrains/kotlin/idea/stubs/DebugTextByStubTest.kt index 73482dc34ad..5a678f9f943 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/DebugTextByStubTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/DebugTextByStubTest.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtClassBody import org.jetbrains.kotlin.psi.KtClassInitializer import org.jetbrains.kotlin.psi.debugText.getDebugText -public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { +class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { private fun createFileAndStubTree(text: String): Pair> { val file = myFixture.configureByText("test.kt", text) as KtFile val stub = KtFileStubBuilder().buildStubTree(file)!! @@ -52,14 +52,14 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { val (file, tree) = createFileAndStubTree(text) val packageDirective = tree.findChildStubByType(KtStubElementTypes.PACKAGE_DIRECTIVE) val psi = KtPackageDirective(packageDirective as KotlinPlaceHolderStub) - Assert.assertEquals(file.getPackageDirective()!!.getText(), psi.getDebugText()) + Assert.assertEquals(file.packageDirective!!.text, psi.getDebugText()) } fun function(text: String) { val (file, tree) = createFileAndStubTree(text) val function = tree.findChildStubByType(KtStubElementTypes.FUNCTION) val psi = KtNamedFunction(function as KotlinFunctionStub) - Assert.assertEquals("STUB: " + file.findChildByClass(KtNamedFunction::class.java)!!.getText(), psi.getDebugText()) + Assert.assertEquals("STUB: " + file.findChildByClass(KtNamedFunction::class.java)!!.text, psi.getDebugText()) } fun typeReference(text: String) { @@ -69,8 +69,8 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { val valueParameter = parameterList.findChildStubByType(KtStubElementTypes.VALUE_PARAMETER)!! val typeReferenceStub = valueParameter.findChildStubByType(KtStubElementTypes.TYPE_REFERENCE) val psiFromStub = KtTypeReference(typeReferenceStub as KotlinPlaceHolderStub) - val typeReferenceByPsi = file.findChildByClass(KtNamedFunction::class.java)!!.getValueParameters()[0].getTypeReference() - Assert.assertEquals(typeReferenceByPsi!!.getText(), psiFromStub.getDebugText()) + val typeReferenceByPsi = file.findChildByClass(KtNamedFunction::class.java)!!.valueParameters[0].typeReference + Assert.assertEquals(typeReferenceByPsi!!.text, psiFromStub.getDebugText()) } fun clazz(text: String, expectedText: String? = null) { @@ -78,7 +78,7 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { val clazz = tree.findChildStubByType(KtStubElementTypes.CLASS)!! val psiFromStub = KtClass(clazz as KotlinClassStub) val classByPsi = file.findChildByClass(KtClass::class.java) - val toCheckAgainst = "STUB: " + (expectedText ?: classByPsi!!.getText()) + val toCheckAgainst = "STUB: " + (expectedText ?: classByPsi!!.text) Assert.assertEquals(toCheckAgainst, psiFromStub.getDebugText()) if (expectedText != null) { Assert.assertNotEquals("Expected text should not be specified", classByPsi!!.getDebugText(), psiFromStub.getDebugText()) @@ -90,7 +90,7 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { val obj = tree.findChildStubByType(KtStubElementTypes.OBJECT_DECLARATION)!! val psiFromStub = KtObjectDeclaration(obj as KotlinObjectStub) val objectByPsi = file.findChildByClass(KtObjectDeclaration::class.java) - val toCheckAgainst = "STUB: " + (expectedText ?: objectByPsi!!.getText()) + val toCheckAgainst = "STUB: " + (expectedText ?: objectByPsi!!.text) Assert.assertEquals(toCheckAgainst, psiFromStub.getDebugText()) } @@ -99,7 +99,7 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { val property = tree.findChildStubByType(KtStubElementTypes.PROPERTY)!! val psiFromStub = KtProperty(property as KotlinPropertyStub) val propertyByPsi = file.findChildByClass(KtProperty::class.java) - val toCheckAgainst = "STUB: " + (expectedText ?: propertyByPsi!!.getText()) + val toCheckAgainst = "STUB: " + (expectedText ?: propertyByPsi!!.text) Assert.assertEquals(toCheckAgainst, psiFromStub.getDebugText()) } @@ -107,7 +107,7 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { val (file, tree) = createFileAndStubTree(text) val importList = tree.findChildStubByType(KtStubElementTypes.IMPORT_LIST) val psi = KtImportList(importList as KotlinPlaceHolderStub) - Assert.assertEquals(file.getImportList()!!.getText(), psi.getDebugText()) + Assert.assertEquals(file.importList!!.text, psi.getDebugText()) } fun testPackageDirective() { @@ -208,7 +208,7 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { fun testPropertyAccessors() { val tree = createStubTree("var c: Int\nget() = 3\nset(i: Int) {}") val propertyStub = tree.findChildStubByType(KtStubElementTypes.PROPERTY)!! - val accessors = propertyStub.getChildrenByType(KtStubElementTypes.PROPERTY_ACCESSOR, KtStubElementTypes.PROPERTY_ACCESSOR.getArrayFactory())!! + val accessors = propertyStub.getChildrenByType(KtStubElementTypes.PROPERTY_ACCESSOR, KtStubElementTypes.PROPERTY_ACCESSOR.arrayFactory)!! assertEquals("getter for STUB: var c: Int", accessors[0].getDebugText()) assertEquals("setter for STUB: var c: Int", accessors[1].getDebugText()) } @@ -216,7 +216,7 @@ public class DebugTextByStubTest : LightCodeInsightFixtureTestCase() { fun testEnumEntry() { val tree = createStubTree("enum class Enum { E1, E2(), E3(1, 2)}") val enumClass = tree.findChildStubByType(KtStubElementTypes.CLASS)!!.findChildStubByType(KtStubElementTypes.CLASS_BODY)!! - val entries = enumClass.getChildrenByType(KtStubElementTypes.ENUM_ENTRY, KtStubElementTypes.ENUM_ENTRY.getArrayFactory())!! + val entries = enumClass.getChildrenByType(KtStubElementTypes.ENUM_ENTRY, KtStubElementTypes.ENUM_ENTRY.arrayFactory)!! assertEquals("STUB: enum entry E1", entries[0].getDebugText()) assertEquals("STUB: enum entry E2 : Enum", entries[1].getDebugText()) assertEquals("STUB: enum entry E3 : Enum", entries[2].getDebugText()) diff --git a/idea/tests/org/jetbrains/kotlin/psi/StringTemplateExpressionManipulatorTest.kt b/idea/tests/org/jetbrains/kotlin/psi/StringTemplateExpressionManipulatorTest.kt index 3b9db04ecb9..59fd1fc77a8 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/StringTemplateExpressionManipulatorTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/StringTemplateExpressionManipulatorTest.kt @@ -22,8 +22,8 @@ import com.intellij.psi.ElementManipulators import org.junit.Assert.* import com.intellij.openapi.util.TextRange -public class StringTemplateExpressionManipulatorTest : KotlinLightCodeInsightFixtureTestCase() { - public fun testSingleQuoted() { +class StringTemplateExpressionManipulatorTest : KotlinLightCodeInsightFixtureTestCase() { + fun testSingleQuoted() { doTestContentChange("\"a\"", "b", "\"b\"") doTestContentChange("\"\"", "b", "\"b\"") doTestContentChange("\"a\"", "\t", "\"\\t\"") @@ -31,7 +31,7 @@ public class StringTemplateExpressionManipulatorTest : KotlinLightCodeInsightFix doTestContentChange("\"a\"", "\\t", "\"\\\\t\"") } - public fun testUnclosedQuoted() { + fun testUnclosedQuoted() { doTestContentChange("\"a", "b", "\"b") doTestContentChange("\"", "b", "\"b") doTestContentChange("\"a", "\t", "\"\\t") @@ -39,7 +39,7 @@ public class StringTemplateExpressionManipulatorTest : KotlinLightCodeInsightFix doTestContentChange("\"a", "\\t", "\"\\\\t") } - public fun testTripleQuoted() { + fun testTripleQuoted() { doTestContentChange("\"\"\"a\"\"\"", "b", "\"\"\"b\"\"\"") doTestContentChange("\"\"\"\"\"\"", "b", "\"\"\"b\"\"\"") doTestContentChange("\"\"\"a\"\"\"", "\t", "\"\"\"\t\"\"\"") @@ -47,7 +47,7 @@ public class StringTemplateExpressionManipulatorTest : KotlinLightCodeInsightFix doTestContentChange("\"\"\"a\"\"\"", "\\t", "\"\"\"\\t\"\"\"") } - public fun testUnclosedTripleQuoted() { + fun testUnclosedTripleQuoted() { doTestContentChange("\"\"\"a", "b", "\"\"\"b") doTestContentChange("\"\"\"", "b", "\"\"\"b") doTestContentChange("\"\"\"a", "\t", "\"\"\"\t") @@ -55,16 +55,16 @@ public class StringTemplateExpressionManipulatorTest : KotlinLightCodeInsightFix doTestContentChange("\"\"\"a", "\\t", "\"\"\"\\t") } - public fun testReplaceRange() { + fun testReplaceRange() { doTestContentChange("\"abc\"", "x", range = TextRange(2,3), expected = "\"axc\"") doTestContentChange("\"\"\"abc\"\"\"", "x", range = TextRange(4,5), expected = "\"\"\"axc\"\"\"") } private fun doTestContentChange(original: String, newContent: String, expected: String, range: TextRange? = null) { - val expression = KtPsiFactory(getProject()).createExpression(original) as KtStringTemplateExpression + val expression = KtPsiFactory(project).createExpression(original) as KtStringTemplateExpression val manipulator = ElementManipulators.getNotNullManipulator(expression) val newExpression = if (range == null) manipulator.handleContentChange(expression, newContent) else manipulator.handleContentChange(expression, range, newContent) - assertEquals(expected, newExpression.getText()) + assertEquals(expected, newExpression.text) } override fun getProjectDescriptor() = KotlinLightProjectDescriptor.INSTANCE diff --git a/idea/tests/org/jetbrains/kotlin/psi/injection/StringInjectionHostTest.kt b/idea/tests/org/jetbrains/kotlin/psi/injection/StringInjectionHostTest.kt index abae31f5a9e..5fdb19b7b1b 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/injection/StringInjectionHostTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/injection/StringInjectionHostTest.kt @@ -24,8 +24,8 @@ import java.util.HashMap import org.jetbrains.kotlin.test.KotlinLiteFixture import org.jetbrains.kotlin.test.ConfigurationKind -public class StringInjectionHostTest: KotlinLiteFixture() { - public fun testRegular() { +class StringInjectionHostTest: KotlinLiteFixture() { + fun testRegular() { with (quoted("")) { checkInjection("", mapOf(0 to 1)) assertOneLine() @@ -42,12 +42,12 @@ public class StringInjectionHostTest: KotlinLiteFixture() { } } - public fun testUnclosedSimpleLiteral() { - assertFalse(stringExpression("\"").isValidHost()); - assertFalse(stringExpression("\"a").isValidHost()); + fun testUnclosedSimpleLiteral() { + assertFalse(stringExpression("\"").isValidHost); + assertFalse(stringExpression("\"a").isValidHost); } - public fun testEscapeSequences() { + fun testEscapeSequences() { with (quoted("\\t")) { checkInjection("\t", mapOf(0 to 1, 1 to 3)) assertNoInjection(TextRange(1, 2)) @@ -66,7 +66,7 @@ public class StringInjectionHostTest: KotlinLiteFixture() { } } - public fun testTripleQuotes() { + fun testTripleQuotes() { with (tripleQuoted("")) { checkInjection("", mapOf(0 to 3)) assertMultiLine() @@ -83,7 +83,7 @@ public class StringInjectionHostTest: KotlinLiteFixture() { } } - public fun testEscapeSequenceInTripleQuotes() { + fun testEscapeSequenceInTripleQuotes() { with (tripleQuoted("\\t")) { checkInjection("\\t", mapOf(0 to 3, 1 to 4, 2 to 5)) checkInjection("\\", mapOf(0 to 3, 1 to 4), rangeInHost = TextRange(3, 4)) @@ -92,7 +92,7 @@ public class StringInjectionHostTest: KotlinLiteFixture() { } } - public fun testMultiLine() { + fun testMultiLine() { with (tripleQuoted("a\nb")) { checkInjection("a\nb", mapOf(0 to 3, 1 to 4, 2 to 5, 3 to 6)) assertMultiLine() @@ -108,30 +108,30 @@ public class StringInjectionHostTest: KotlinLiteFixture() { } private fun stringExpression(s: String): KtStringTemplateExpression { - return KtPsiFactory(getProject()).createExpression(s) as KtStringTemplateExpression + return KtPsiFactory(project).createExpression(s) as KtStringTemplateExpression } private fun KtStringTemplateExpression.assertNoInjection(range: TextRange): KtStringTemplateExpression { - assertTrue(isValidHost()) + assertTrue(isValidHost) assertFalse(createLiteralTextEscaper().decode(range, StringBuilder())) return this } private fun KtStringTemplateExpression.assertOneLine() { - assertTrue(createLiteralTextEscaper().isOneLine()) + assertTrue(createLiteralTextEscaper().isOneLine) } private fun KtStringTemplateExpression.assertMultiLine() { - assertFalse(createLiteralTextEscaper().isOneLine()) + assertFalse(createLiteralTextEscaper().isOneLine) } //todo[nik] make private when KT-6382 is fixed fun KtStringTemplateExpression.checkInjection(decoded: String, targetToSourceOffsets: Map, rangeInHost: TextRange? = null) { - assertTrue(isValidHost()) + assertTrue(isValidHost) for (prefix in listOf("", "prefix")) { val escaper = createLiteralTextEscaper() val chars = StringBuilder(prefix) - val range = rangeInHost ?: escaper.getRelevantTextRange() + val range = rangeInHost ?: escaper.relevantTextRange assertTrue(escaper.decode(range, chars)) assertEquals(decoded, chars.substring(prefix.length)) val extendedOffsets = HashMap(targetToSourceOffsets) diff --git a/idea/tests/org/jetbrains/kotlin/psi/patternMatching/AbstractPsiUnifierTest.kt b/idea/tests/org/jetbrains/kotlin/psi/patternMatching/AbstractPsiUnifierTest.kt index 991994c011a..fd1403f2971 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/patternMatching/AbstractPsiUnifierTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/patternMatching/AbstractPsiUnifierTest.kt @@ -32,21 +32,21 @@ import org.jetbrains.kotlin.psi.KtWhenCondition import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -public abstract class AbstractPsiUnifierTest : KotlinLightCodeInsightFixtureTestCase() { - public fun doTest(filePath: String) { +abstract class AbstractPsiUnifierTest : KotlinLightCodeInsightFixtureTestCase() { + fun doTest(filePath: String) { fun findPattern(file: KtFile): KtElement { - val selectionModel = myFixture.getEditor().getSelectionModel() - val start = selectionModel.getSelectionStart() - val end = selectionModel.getSelectionEnd() + val selectionModel = myFixture.editor.selectionModel + val start = selectionModel.selectionStart + val end = selectionModel.selectionEnd val selectionRange = TextRange(start, end) return file.findElementAt(start)?.parentsWithSelf?.last { (it is KtExpression || it is KtTypeReference || it is KtWhenCondition) - && selectionRange.contains(it.getTextRange() ?: TextRange.EMPTY_RANGE) + && selectionRange.contains(it.textRange ?: TextRange.EMPTY_RANGE) } as KtElement } myFixture.configureByFile(filePath) - val file = myFixture.getFile() as KtFile + val file = myFixture.file as KtFile DirectiveBasedActionUtils.checkForUnexpectedErrors(file) diff --git a/idea/tests/org/jetbrains/kotlin/search/KotlinReferencesSearchTest.kt b/idea/tests/org/jetbrains/kotlin/search/KotlinReferencesSearchTest.kt index f868c5baeac..267b26bdc94 100644 --- a/idea/tests/org/jetbrains/kotlin/search/KotlinReferencesSearchTest.kt +++ b/idea/tests/org/jetbrains/kotlin/search/KotlinReferencesSearchTest.kt @@ -28,24 +28,24 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.junit.Assert import java.io.File -public class KotlinReferencesSearchTest(): AbstractSearcherTest() { +class KotlinReferencesSearchTest(): AbstractSearcherTest() { override fun getTestDataPath(): String { - return File(PluginTestCaseBase.getTestDataPathBase(), "/search/references").getPath() + File.separator + return File(PluginTestCaseBase.getTestDataPathBase(), "/search/references").path + File.separator } - public fun testPlus() { + fun testPlus() { val refs = doTest() Assert.assertEquals(3, refs.size) - Assert.assertEquals("+", refs[0].getCanonicalText()) - Assert.assertEquals("plus", refs[1].getCanonicalText()) - Assert.assertEquals("plus", refs[2].getCanonicalText()) + Assert.assertEquals("+", refs[0].canonicalText) + Assert.assertEquals("plus", refs[1].canonicalText) + Assert.assertEquals("plus", refs[2].canonicalText) } - public fun testParam() { + fun testParam() { val refs = doTest() Assert.assertEquals(3, refs.size) - Assert.assertEquals("n", refs[0].getCanonicalText()) - Assert.assertEquals("component1", refs[1].getCanonicalText()) + Assert.assertEquals("n", refs[0].canonicalText) + Assert.assertEquals("component1", refs[1].canonicalText) Assert.assertTrue(refs[2] is KtDestructuringDeclarationReference) } @@ -53,8 +53,8 @@ public class KotlinReferencesSearchTest(): AbstractSearcherTest() { private val myFixtureProxy: JavaCodeInsightTestFixture get() = myFixture private inline fun doTest(): List { - myFixtureProxy.configureByFile(getFileName()) - val func = myFixtureProxy.getElementAtCaret().getParentOfType(false)!! - return ReferencesSearch.search(func).findAll().sortedBy { it.getElement().getTextRange().getStartOffset() } + myFixtureProxy.configureByFile(fileName) + val func = myFixtureProxy.elementAtCaret.getParentOfType(false)!! + return ReferencesSearch.search(func).findAll().sortedBy { it.element.textRange.startOffset } } } diff --git a/idea/tests/org/jetbrains/kotlin/shortenRefs/AbstractShortenRefsTest.kt b/idea/tests/org/jetbrains/kotlin/shortenRefs/AbstractShortenRefsTest.kt index 69c8b7fb202..30ca03a2f01 100644 --- a/idea/tests/org/jetbrains/kotlin/shortenRefs/AbstractShortenRefsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/shortenRefs/AbstractShortenRefsTest.kt @@ -20,12 +20,12 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.AbstractImportsTest -public abstract class AbstractShortenRefsTest : AbstractImportsTest() { +abstract class AbstractShortenRefsTest : AbstractImportsTest() { override fun doTest(file: KtFile) { - val selectionModel = myFixture.getEditor().getSelectionModel() + val selectionModel = myFixture.editor.selectionModel if (!selectionModel.hasSelection()) error("No selection in input file") ShortenReferences { ShortenReferences.Options(removeThis = true, removeThisLabels = true) } - .process(file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) + .process(file, selectionModel.selectionStart, selectionModel.selectionEnd) selectionModel.removeSelection() }