From a58a7727d1176472736feb68efac1b7c6863db71 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 29 Sep 2015 20:39:01 +0300 Subject: [PATCH] Preprocessor: cleanup unused code. --- .../conditional-preprocessor.iml | 1 - .../Preprocessor.kt | 41 +------------ .../PreprocessorCLI.kt | 7 --- .../PreprocessorTask.kt | 61 ------------------- 4 files changed, 1 insertion(+), 109 deletions(-) delete mode 100644 compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorTask.kt diff --git a/compiler/conditional-preprocessor/conditional-preprocessor.iml b/compiler/conditional-preprocessor/conditional-preprocessor.iml index d9ba8a64b22..7aeafd8efe3 100644 --- a/compiler/conditional-preprocessor/conditional-preprocessor.iml +++ b/compiler/conditional-preprocessor/conditional-preprocessor.iml @@ -9,7 +9,6 @@ - diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt index 11521d7b460..1753babb837 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt @@ -114,7 +114,7 @@ public class Preprocessor(val logger: Logger = SystemOutLogger) { if (targetFile.exists() && targetFile.isDirectory) targetFile.deleteRecursively() - // if no modifications — copy + // if no modifications � copy if (result is FileProcessingResult.Copy) { FileUtil.copy(sourceFile, targetFile) } else if (result is FileProcessingResult.Modify) { @@ -144,45 +144,6 @@ public class Preprocessor(val logger: Logger = SystemOutLogger) { } } - - private fun processFileMultiEvaluators(sourceFile: File, evaluators: List): List { - if (sourceFile.extension != fileType.defaultExtension) - return evaluators map { FileProcessingResult.Copy } - - val sourceText = sourceFile.readText().convertLineSeparators() - val psiFile = jetPsiFactory.createFile(sourceFile.name, sourceText) - println("$psiFile") - - val results = hashMapOf() - - val fileAnnotations = psiFile.parseConditionalAnnotations() - evaluators.forEach { evaluator -> - if (!evaluator(fileAnnotations)) - results += evaluator to FileProcessingResult.Skip - } - - val visitor = CollectModificationsVisitor(evaluators - results.keySet()) - psiFile.accept(visitor) - - for ((evaluator, list) in visitor.elementModifications) { - val result = - if (list.isNotEmpty()) - FileProcessingResult.Modify(sourceText, list) - else - FileProcessingResult.Copy - results += evaluator to result - } - return evaluators.map { results[it]!! } - } - - private fun processDirectoryMultiEvaluators(sourceRoot: File, targetRelativeRoot: File, profiles: List) { - - val (sourceFiles, sourceDirectories) = sourceRoot.listFiles().partition { !it.isDirectory } - - // TODO: keep processed file list for each profile - val processedFiles = profiles.toMap({ it }, { hashSetOf()}) - - } } fun String.convertLineSeparators(): String = StringUtil.convertLineSeparators(this) diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorCLI.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorCLI.kt index af6c4a6ebc9..391a908635a 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorCLI.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorCLI.kt @@ -33,11 +33,4 @@ fun main(args: Array) { println("Preprocessing sources in $sourcePath to $targetPath with profile ${profile.name}") Preprocessor().processSources(sourcePath, profile) - -// val pool = Executors.newCachedThreadPool() -// -// profiles.forEach { profile -> pool.submit { Preprocessor().processSources(sourcePath, profile) } } -// -// pool.shutdown() -// pool.awaitTermination(1, TimeUnit.MINUTES) } diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorTask.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorTask.kt deleted file mode 100644 index c21bae8459f..00000000000 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/PreprocessorTask.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.preprocessor -/* -import org.apache.tools.ant.Task -import java.io.File - -public class PreprocessorTask: Task() { - - public class JvmProfileConfig { - public var version: Int? = null - public var output: File? = null - } - public class JsProfileConfig { - public var output: File? = null - } - - public var src: File? = null - - private val profiles = arrayListOf() - - public fun addConfiguredJvmProfile(configuration: JvmProfileConfig) { - val version = configuration.version ?: throw IllegalArgumentException("version") - val output = configuration.output ?: throw IllegalArgumentException("output") - profiles.add(Profile("JVM$version", JvmPlatformEvaluator(version), output)) - } - - public fun addConfiguredJsProfile(configuration: JsProfileConfig) { - val output = configuration.output ?: throw IllegalArgumentException("output") - profiles.add(Profile("JS", JsPlatformEvaluator(), output)) - } - - override fun execute() { - checkParameters() - profiles.forEach { profile -> - val preprocessor = Preprocessor() - log("Preprocessing sources for ${profile.name}") - preprocessor.processSources(src!!, profile) - } - } - - private fun checkParameters() { - if (src == null) throw IllegalArgumentException("src") - if (profiles.isEmpty()) throw IllegalArgumentException("profiles") - } -} -*/ \ No newline at end of file