Skip to content

Latest commit

 

History

History
97 lines (59 loc) · 2.73 KB

File metadata and controls

97 lines (59 loc) · 2.73 KB

PytoJava 简介

PytoJava 是是一款基于 RepoTransBench 论文开发的一个 VS Code 插件,旨在将 Python 项目自动翻译为 Java 项目,并在侧边栏中直观展示翻译后的 Java 文件,同时支持与原始 Python 文件的差异对比。

功能概览

  • 一键运行 Docker 中的 Python 翻译脚本
  • 自动在侧边栏显示翻译后的 Java 项目结构
  • 支持 Java 与原始 Python 文件差异对比
  • 全异步操作,翻译期间提供进度提示
  • 使用 VS Code 原生 OutputChannel 显示日志信息

安装与构建

前置要求

容器安装

Build a Docker image based on current logic

requirment.txt is the core of the image. ( you can edit it if you need )

start.sh is used to keep the Docker container running.

run the dockerfile to build a docker image (you can name the image which you enjoy)

docker buildx build -t translate 

Using a Visual Interface for Docker Management

use Docker Desktop to operate conveniently.

Volume Mount

you must bind the D:\ to any other dictionary in the image!

first step: find the image which you create

second step: press the run button and bind the D:\ to /mnt

run the container

find the container and press the run button

如果仅使用

  • 下载pytojava-0.2.1.vsix
  • 在VS Code中本地安装插件

first step: install

  • 打开需要翻译的Python项目目录

second step: run

  • Ctrl+Shift+P输入命令PytoJava

run a Specific Project

step 1: find the workplace

step 2: input PytoJava

then you can notice extension are running

finally you can open the diff on left

可以更改传递给docker容器的命令

docker exec happy_dubinsky python generate_javaproject_code.py

其中的 happy_dubinsky 是对应容器的名字 你应该改成你本地docker中容器的名字

后面的 python generate_javaproject_code.py 是运行对应的逻辑文件 你也可以做出改变

如果想进一步开发

下载PytoJava文件夹,并在Vs Code中打开,在终端输入

//安装相关依赖
npm install
//构建插件
npm run compile

启动调试

使用VS Code打开本项目根目录,按下F5进入调试环境 开发完成后,可使用esbuild打包插件

//打包插件
vsce package