Preprocessor: cleanup unused code.
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="kotlin-runtime" level="project" />
|
<orderEntry type="library" name="kotlin-runtime" level="project" />
|
||||||
<orderEntry type="library" name="intellij-core" level="project" />
|
<orderEntry type="library" name="intellij-core" level="project" />
|
||||||
<orderEntry type="library" name="ant" level="project" />
|
|
||||||
<orderEntry type="module" module-name="cli" />
|
<orderEntry type="module" module-name="cli" />
|
||||||
<orderEntry type="module" module-name="frontend" />
|
<orderEntry type="module" module-name="frontend" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
+1
-40
@@ -114,7 +114,7 @@ public class Preprocessor(val logger: Logger = SystemOutLogger) {
|
|||||||
if (targetFile.exists() && targetFile.isDirectory)
|
if (targetFile.exists() && targetFile.isDirectory)
|
||||||
targetFile.deleteRecursively()
|
targetFile.deleteRecursively()
|
||||||
|
|
||||||
// if no modifications — copy
|
// if no modifications � copy
|
||||||
if (result is FileProcessingResult.Copy) {
|
if (result is FileProcessingResult.Copy) {
|
||||||
FileUtil.copy(sourceFile, targetFile)
|
FileUtil.copy(sourceFile, targetFile)
|
||||||
} else if (result is FileProcessingResult.Modify) {
|
} else if (result is FileProcessingResult.Modify) {
|
||||||
@@ -144,45 +144,6 @@ public class Preprocessor(val logger: Logger = SystemOutLogger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun processFileMultiEvaluators(sourceFile: File, evaluators: List<Evaluator>): List<FileProcessingResult> {
|
|
||||||
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<Evaluator, FileProcessingResult>()
|
|
||||||
|
|
||||||
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<Profile>) {
|
|
||||||
|
|
||||||
val (sourceFiles, sourceDirectories) = sourceRoot.listFiles().partition { !it.isDirectory }
|
|
||||||
|
|
||||||
// TODO: keep processed file list for each profile
|
|
||||||
val processedFiles = profiles.toMap({ it }, { hashSetOf<File>()})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.convertLineSeparators(): String = StringUtil.convertLineSeparators(this)
|
fun String.convertLineSeparators(): String = StringUtil.convertLineSeparators(this)
|
||||||
|
|||||||
-7
@@ -33,11 +33,4 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
println("Preprocessing sources in $sourcePath to $targetPath with profile ${profile.name}")
|
println("Preprocessing sources in $sourcePath to $targetPath with profile ${profile.name}")
|
||||||
Preprocessor().processSources(sourcePath, profile)
|
Preprocessor().processSources(sourcePath, profile)
|
||||||
|
|
||||||
// val pool = Executors.newCachedThreadPool()
|
|
||||||
//
|
|
||||||
// profiles.forEach { profile -> pool.submit { Preprocessor().processSources(sourcePath, profile) } }
|
|
||||||
//
|
|
||||||
// pool.shutdown()
|
|
||||||
// pool.awaitTermination(1, TimeUnit.MINUTES)
|
|
||||||
}
|
}
|
||||||
|
|||||||
-61
@@ -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<Profile>()
|
|
||||||
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Reference in New Issue
Block a user