Delete commented out code
This commit is contained in:
@@ -1,144 +0,0 @@
|
||||
//package org.jetbrains.jet.j2k;
|
||||
//
|
||||
//import com.intellij.psi.PsiFile;
|
||||
//import com.intellij.psi.PsiJavaFile;
|
||||
//import org.apache.commons.cli.*;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.IOException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import java.util.logging.Logger;
|
||||
//import java.util.regex.Pattern;
|
||||
//
|
||||
//import static org.apache.commons.io.FileUtils.readFileToString;
|
||||
//import static org.apache.commons.io.FileUtils.writeStringToFile;
|
||||
//
|
||||
//@SuppressWarnings({"CallToPrintStackTrace", "UseOfSystemOutOrSystemErr"})
|
||||
//public class JavaToKotlinCli {
|
||||
// private static final Logger myLogger = Logger.getAnonymousLogger();
|
||||
//
|
||||
// private JavaToKotlinCli() {
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// CommandLineParser parser = new BasicParser();
|
||||
// Options options = new Options()
|
||||
// .addOption("h", "help", false, "Print usage information")
|
||||
// .addOption("f", "from", true, "Directory with Java sources")
|
||||
// .addOption("t", "to", true, "Directory with Kotlin sources")
|
||||
// .addOption("p", "public-only", false, "Only public and protected members")
|
||||
// .addOption("fqn", "fqn", false, "Full qualified names")
|
||||
// .addOption("d", "declarations-only", false, "Declarations only")
|
||||
// ;
|
||||
//
|
||||
// try {
|
||||
// CommandLine commandLine = parser.parse(options, args);
|
||||
//
|
||||
// if (commandLine.hasOption("help"))
|
||||
// showHelpAndExit();
|
||||
//
|
||||
// if (commandLine.hasOption("from") && commandLine.hasOption("to")) {
|
||||
// String from = commandLine.getOptionValue("from");
|
||||
// String to = commandLine.getOptionValue("to");
|
||||
//
|
||||
// for (Option o : commandLine.getOptions()) {
|
||||
// Converter.addFlag(o.getLongOpt());
|
||||
// }
|
||||
//
|
||||
// if (!from.isEmpty() && !to.isEmpty())
|
||||
// convertSourceTree(from, to);
|
||||
// else
|
||||
// showHelpAndExit();
|
||||
// } else
|
||||
// showHelpAndExit();
|
||||
// } catch (ParseException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
// private static void convertSourceTree(String javaPath, String kotlinPath) {
|
||||
// try {
|
||||
// File javaDir = new File(javaPath);
|
||||
// File kotlinDir = new File(kotlinPath);
|
||||
//
|
||||
// if (kotlinDir.exists())
|
||||
// kotlinDir.delete();
|
||||
//
|
||||
// if (!kotlinDir.exists() && !kotlinDir.mkdir())
|
||||
// myLogger.warning("Creation failed: " + kotlinDir.getAbsolutePath());
|
||||
//
|
||||
// for (File f : getJavaFiles(javaDir.getAbsolutePath())) {
|
||||
// String relative = javaDir.toURI().relativize(f.toURI()).getPath().replace(".java", ".kt");
|
||||
// File file = new File(kotlinPath, relative);
|
||||
//
|
||||
// if (file.exists())
|
||||
// file.delete();
|
||||
//
|
||||
// if (f.isDirectory())
|
||||
// if (!file.exists() && !file.mkdir())
|
||||
// myLogger.warning("Creation failed: " + file.getAbsolutePath());
|
||||
//
|
||||
// if (f.isFile()) {
|
||||
// writeStringToFile(file, fileToKotlin(f));
|
||||
// }
|
||||
// }
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// private static String fileToKotlin(File f) throws IOException {
|
||||
// final String javaCode = readJavaFileToString(f);
|
||||
// return generateKotlinCode(JavaToKotlinTranslator.createFile(JavaToKotlinTranslator.setUpJavaCoreEnvironment(), javaCode));
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// private static String generateKotlinCode(@Nullable PsiFile file) {
|
||||
// if (file != null && file instanceof PsiJavaFile) {
|
||||
// JavaToKotlinTranslator.setClassIdentifiers(file);
|
||||
// return JavaToKotlinTranslator.prettify(Converter.fileToFile((PsiJavaFile) file).toKotlin());
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// private static String readJavaFileToString(@NotNull File javaFile) throws IOException {
|
||||
// return Pattern.compile("\\s*/\\*.*\\*/", Pattern.DOTALL).matcher(readFileToString(javaFile)).replaceAll("");
|
||||
// }
|
||||
//
|
||||
// private static void showHelpAndExit() {
|
||||
// System.err.println("Usage: java -jar java2kotlin.jar -f <from> -t <to>");
|
||||
// System.exit(1);
|
||||
// }
|
||||
//
|
||||
// static public List<File> getJavaFiles(String startDirName) throws FileNotFoundException {
|
||||
// return getJavaFiles(new File(startDirName));
|
||||
// }
|
||||
//
|
||||
// private static List<File> getJavaFiles(File start) throws FileNotFoundException {
|
||||
// List<File> result = new ArrayList<File>();
|
||||
//
|
||||
// if (start.isFile())
|
||||
// return Arrays.asList(start);
|
||||
//
|
||||
// for (File file : Arrays.asList(start.listFiles())) {
|
||||
// if ((file.isFile() && file.getName().endsWith(".java")) || file.isDirectory())
|
||||
// result.add(file);
|
||||
//
|
||||
// if (file.isDirectory()) {
|
||||
// List<File> deeperList = getJavaFiles(file);
|
||||
// result.addAll(deeperList);
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.j2k.actions
|
||||
//
|
||||
//import com.intellij.openapi.actionSystem.AnAction
|
||||
//import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
//import org.jetbrains.jet.j2k.Converter
|
||||
//import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
//import com.intellij.openapi.actionSystem.LangDataKeys
|
||||
//import com.intellij.psi.PsiJavaFile
|
||||
//import com.intellij.openapi.util.io.FileUtil
|
||||
//import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
//import com.intellij.psi.PsiDocumentManager
|
||||
//import com.intellij.openapi.command.WriteCommandAction
|
||||
//import com.intellij.openapi.application.ApplicationManager
|
||||
//import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
//
|
||||
//class JavaToKotlinAction(): AnAction() {
|
||||
// public override fun actionPerformed(event : AnActionEvent?) {
|
||||
// val converter = Converter()
|
||||
// val psiFile = event!!.getData(LangDataKeys.PSI_FILE)!!
|
||||
// ApplicationManager.getApplication()?.runWriteAction(object : Runnable {
|
||||
// public override fun run() {
|
||||
// val result = converter.fileToFile(psiFile as PsiJavaFile).toKotlin()
|
||||
// val newName = FileUtil.getNameWithoutExtension(psiFile.getName()) + ".kt"
|
||||
// val newFile = psiFile.getContainingDirectory()?.createFile(newName)!!
|
||||
// val project = psiFile.getProject()
|
||||
// val psiDocumentManager = PsiDocumentManager.getInstance(project)!!
|
||||
// val document = psiDocumentManager.getDocument(newFile)!!
|
||||
// document.setText(result)
|
||||
// psiDocumentManager.doPostponedOperationsAndUnblockDocument(document)
|
||||
// psiDocumentManager.commitDocument(document)
|
||||
// CodeStyleManager.getInstance(project)!!.reformat(newFile)
|
||||
// psiFile.setName(psiFile.getName() + ".old")
|
||||
// newFile.navigate(true)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public override fun update(e : AnActionEvent?) {
|
||||
// val psiFile = e!!.getData(LangDataKeys.PSI_FILE)
|
||||
// e.getPresentation().setEnabled(psiFile is PsiJavaFile)
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user