diff --git a/src/intellij_plugin/ohosgen/.idea/.name b/src/intellij_plugin/ohosgen/.idea/.name new file mode 100644 index 0000000000000000000000000000000000000000..64160aad5e0aadfb1821207a93f0ef4be10f4f55 --- /dev/null +++ b/src/intellij_plugin/ohosgen/.idea/.name @@ -0,0 +1 @@ +plugtest \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/.idea/codeStyles/codeStyleConfig.xml b/src/intellij_plugin/ohosgen/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000000000000000000000000000000000..a55e7a179bde3e4e772c29c0c85e53354aa54618 --- /dev/null +++ b/src/intellij_plugin/ohosgen/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/.idea/gradle.xml b/src/intellij_plugin/ohosgen/.idea/gradle.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce1c62c7c60561be6b5a9bc9f115e8966e9e5a4a --- /dev/null +++ b/src/intellij_plugin/ohosgen/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/.idea/kotlinc.xml b/src/intellij_plugin/ohosgen/.idea/kotlinc.xml new file mode 100644 index 0000000000000000000000000000000000000000..4cb745724991053f20f0b3afacf4017c4ac4e5a7 --- /dev/null +++ b/src/intellij_plugin/ohosgen/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/.idea/misc.xml b/src/intellij_plugin/ohosgen/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..276827d3f2c724142cab6ee6102d8718fba692e3 --- /dev/null +++ b/src/intellij_plugin/ohosgen/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/.idea/vcs.xml b/src/intellij_plugin/ohosgen/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..c2365ab11f9ba6b763735c8fd976420234bb3521 --- /dev/null +++ b/src/intellij_plugin/ohosgen/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/.run/Run IDE with Plugin.run.xml b/src/intellij_plugin/ohosgen/.run/Run IDE with Plugin.run.xml new file mode 100644 index 0000000000000000000000000000000000000000..7747a294009ca902b7463f9ce7c2ac12d10135d2 --- /dev/null +++ b/src/intellij_plugin/ohosgen/.run/Run IDE with Plugin.run.xml @@ -0,0 +1,24 @@ + + + + + + + + true + true + false + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/build.gradle.kts b/src/intellij_plugin/ohosgen/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..7947925bf07654a4868228187b636db93fed3cdd --- /dev/null +++ b/src/intellij_plugin/ohosgen/build.gradle.kts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * 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. + */ + +plugins { + id("java") + id("org.jetbrains.kotlin.jvm") version "1.9.25" + id("org.jetbrains.intellij") version "1.17.4" +} + +group = "com.example" +version = "1.0-SNAPSHOT" + +repositories { + mavenCentral() +} + +// Configure Gradle IntelliJ Plugin +// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html +intellij { + version.set("2024.1.7") + type.set("IC") // Target IDE Platform + + plugins.set(listOf(/* Plugin Dependencies */)) +} + +tasks { + // Set the JVM compatibility versions + withType { + sourceCompatibility = "17" + targetCompatibility = "17" + } + withType { + kotlinOptions.jvmTarget = "17" + } + + patchPluginXml { + sinceBuild.set("241") + untilBuild.set("243.*") + } + + signPlugin { + certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) + privateKey.set(System.getenv("PRIVATE_KEY")) + password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + } + + publishPlugin { + token.set(System.getenv("PUBLISH_TOKEN")) + } +} diff --git a/src/intellij_plugin/ohosgen/gradle.properties b/src/intellij_plugin/ohosgen/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..24630b3f8bb9b56f0c33e5a157770fbdccbfbb92 --- /dev/null +++ b/src/intellij_plugin/ohosgen/gradle.properties @@ -0,0 +1,6 @@ +# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib +kotlin.stdlib.default.dependency=false +# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html +org.gradle.configuration-cache=true +# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html +org.gradle.caching=true diff --git a/src/intellij_plugin/ohosgen/gradlew b/src/intellij_plugin/ohosgen/gradlew new file mode 100644 index 0000000000000000000000000000000000000000..1b6c787337ffb79f0e3cf8b1e9f00f680a959de1 --- /dev/null +++ b/src/intellij_plugin/ohosgen/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# 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 +# +# https://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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/src/intellij_plugin/ohosgen/gradlew.bat b/src/intellij_plugin/ohosgen/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..e116af872a3902392bcc888d60a0e3e7485ff67a --- /dev/null +++ b/src/intellij_plugin/ohosgen/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/intellij_plugin/ohosgen/settings.gradle.kts b/src/intellij_plugin/ohosgen/settings.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..67b5a8f2c3abe6b18c6dc6cd079fca7c2102f650 --- /dev/null +++ b/src/intellij_plugin/ohosgen/settings.gradle.kts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * 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. + */ + +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +rootProject.name = "plugtest" \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/src/main/java/Dts2cpp.java b/src/intellij_plugin/ohosgen/src/main/java/Dts2cpp.java new file mode 100644 index 0000000000000000000000000000000000000000..27af547913ee36b8cef84746325a861493b423e5 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/Dts2cpp.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.progress.ProgressManager; +import com. intellij. openapi. project. Project; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import utils.MockBgTask; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class Dts2cpp extends AnAction { + + private void showProgress(@NotNull AnActionEvent e) { + Project project = e.getProject(); + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null && file.getExtension().equals("ts")) { + // 如果是 .java 文件,执行任务 + doProgress(project, file); + } + } + + private void doProgress(Project project, VirtualFile file) { + ProgressManager.getInstance().run(new MockBgTask(project, "Processing File", true)); + } + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + showProgress(e); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("ts")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/H2dtsAction.java b/src/intellij_plugin/ohosgen/src/main/java/H2dtsAction.java new file mode 100644 index 0000000000000000000000000000000000000000..72d7ac9580bab4a4d6d5d97cb87f4590780f5807 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/H2dtsAction.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class H2dtsAction extends AnAction { + + private void showProgress(AnActionEvent e) { + Project project = e.getProject(); + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null && file.getExtension().equals("h")) { + // 如果是 .java 文件,执行任务 + doProgress(project); + } + } + + private void doSleep() { + try { + Thread.sleep(500); // 模拟耗时操作 + } catch (InterruptedException ex) { + System.out.println("thread exception ex.printStackTrace();"); + } + } + private void doProgress(Project project) { + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing File", true) { + @Override + public void run(@NotNull ProgressIndicator indicator) { + indicator.setFraction(0.0); + for (int i = 0; i < 10; i++) { + indicator.setFraction((i + 1) / 10.0); + indicator.setText("Processing step " + (i + 1)); + doSleep(); + } + Messages.showInfoMessage("File processing complete!", "Main Action"); + } + }); + } + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + showProgress(e); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("h")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/H2dtscppAction.java b/src/intellij_plugin/ohosgen/src/main/java/H2dtscppAction.java new file mode 100644 index 0000000000000000000000000000000000000000..c6e4d73ab611c403f0b8c393824ae0a4f9b58f7d --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/H2dtscppAction.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class H2dtscppAction extends AnAction { + + private void showProgress(AnActionEvent e) { + Project project = e.getProject(); + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null && file.getExtension().equals("h")) { + // 如果是 .java 文件,执行任务 + doProgress(project); + } + } + + private void doSleep() { + try { + Thread.sleep(500); // 模拟耗时操作 + } catch (InterruptedException ex) { + System.out.println("thread exception ex.printStackTrace();"); + } + } + private void doProgress(Project project) { + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing File", true) { + @Override + public void run(@NotNull ProgressIndicator indicator) { + indicator.setFraction(0.0); + for (int i = 0; i < 10; i++) { + indicator.setFraction((i + 1) / 10.0); + indicator.setText("Processing step " + (i + 1)); + doSleep(); + } + Messages.showInfoMessage("File processing complete!", "Main Action"); + } + }); + } + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + showProgress(e); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("h")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/H2hdf.java b/src/intellij_plugin/ohosgen/src/main/java/H2hdf.java new file mode 100644 index 0000000000000000000000000000000000000000..f19ed3213d68b2c7a5b855e262b9005c0446a893 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/H2hdf.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class H2hdf extends AnAction { + + private void showProgress(AnActionEvent e) { + Project project = e.getProject(); + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null && file.getExtension().equals("h")) { + // 如果是 .java 文件,执行任务 + doProgress(project); + } + } + + private void doSleep() { + try { + Thread.sleep(500); // 模拟耗时操作 + } catch (InterruptedException ex) { + System.out.println("thread exception ex.printStackTrace();"); + } + } + private void doProgress(Project project) { + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing File", true) { + @Override + public void run(@NotNull ProgressIndicator indicator) { + indicator.setFraction(0.0); + for (int i = 0; i < 10; i++) { + indicator.setFraction((i + 1) / 10.0); + indicator.setText("Processing step " + (i + 1)); + doSleep(); + } + Messages.showInfoMessage("File processing complete!", "Main Action"); + } + }); + } + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + showProgress(e); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("h")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/H2sa.java b/src/intellij_plugin/ohosgen/src/main/java/H2sa.java new file mode 100644 index 0000000000000000000000000000000000000000..dfb92c22ffecac3a5d524df3e61f9e8d2fbf6980 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/H2sa.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class H2sa extends AnAction { + + private void showProgress(AnActionEvent e) { + Project project = e.getProject(); + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null && file.getExtension().equals("h")) { + // 如果是 .java 文件,执行任务 + doProgress(project); + } + } + + private void doSleep() { + try { + Thread.sleep(500); // 模拟耗时操作 + } catch (InterruptedException ex) { + System.out.println("thread exception ex.printStackTrace();"); + } + } + private void doProgress(Project project) { + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing File", true) { + @Override + public void run(@NotNull ProgressIndicator indicator) { + indicator.setFraction(0.0); + for (int i = 0; i < 10; i++) { + indicator.setFraction((i + 1) / 10.0); + indicator.setText("Processing step " + (i + 1)); + doSleep(); + } + Messages.showInfoMessage("File processing complete!", "Main Action"); + } + }); + } + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + showProgress(e); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("h")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/OhCrossCompile.java b/src/intellij_plugin/ohosgen/src/main/java/OhCrossCompile.java new file mode 100644 index 0000000000000000000000000000000000000000..6ff9f41fd9b87bad9d24405e1a18a4af31d9db07 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/OhCrossCompile.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class OhCrossCompile extends AnAction { + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + Messages.showInfoMessage("This is the OhCrossCompile!", "OhCrossCompile"); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("ts")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/OhosGenAction.java b/src/intellij_plugin/ohosgen/src/main/java/OhosGenAction.java new file mode 100644 index 0000000000000000000000000000000000000000..96f8b63e3a5c4d27e719868d26a42ac333b1c79f --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/OhosGenAction.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class OhosGenAction extends AnAction { + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + Messages.showInfoMessage("This is the OhosGenAction!", "OhosGenAction"); + } + + @Override + public void update(AnActionEvent e) { + // 获取当前选中的文件 + VirtualFile file = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); + if (file != null && file.getExtension() != null) { + if (file.getExtension().equals("ts") || file.getExtension().equals("h")) { + // 如果是 .java 文件,显示 Action + e.getPresentation().setEnabledAndVisible(true); + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } else { + // 否则隐藏 Action + e.getPresentation().setEnabledAndVisible(false); + } + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/PlugTestAction.java b/src/intellij_plugin/ohosgen/src/main/java/PlugTestAction.java new file mode 100644 index 0000000000000000000000000000000000000000..a788de62f237f2a30c4839603f7ba154becc78c1 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/PlugTestAction.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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. + */ + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class PlugTestAction extends AnAction { + + @Override + public void actionPerformed(AnActionEvent e) { + // NEEDO: insert action logic here + System.out.println(" Plug Test Action!"); + Project project = e.getProject(); + if (project == null) { + Messages.showMessageDialog( + "No active project found", + "Error", + Messages.getErrorIcon() + ); + return; + } + + String result = "Proto Message: protoMessage.toString()"; + + Messages.showMessageDialog( + project, + result, + "Protobuf Demo", + Messages.getInformationIcon() + ); + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/gen/GenCppFile.java b/src/intellij_plugin/ohosgen/src/main/java/gen/GenCppFile.java new file mode 100644 index 0000000000000000000000000000000000000000..2420afb2ba73a1174becdaf15a2ac550c488d57f --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/gen/GenCppFile.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 gen; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class GenCppFile { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/gen/GenDtsFile.java b/src/intellij_plugin/ohosgen/src/main/java/gen/GenDtsFile.java new file mode 100644 index 0000000000000000000000000000000000000000..1e9c5c9ac2eab1576da6c2ad32b51bf608b854a1 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/gen/GenDtsFile.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 gen; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class GenDtsFile { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/gen/GenHeadFile.java b/src/intellij_plugin/ohosgen/src/main/java/gen/GenHeadFile.java new file mode 100644 index 0000000000000000000000000000000000000000..97fb1c2ed814b2e196ce2d8929e5d076375d7cc7 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/gen/GenHeadFile.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 gen; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class GenHeadFile { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/parse/ParseC.java b/src/intellij_plugin/ohosgen/src/main/java/parse/ParseC.java new file mode 100644 index 0000000000000000000000000000000000000000..6646c7133b00019a406a0cddab52ed664b933b07 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/parse/ParseC.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 parse; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class ParseC { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/parse/ParseTs.java b/src/intellij_plugin/ohosgen/src/main/java/parse/ParseTs.java new file mode 100644 index 0000000000000000000000000000000000000000..343beaa0feec8822306c6e2a3cdfeff187b3cbdd --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/parse/ParseTs.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 parse; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class ParseTs { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/utils/Constants.java b/src/intellij_plugin/ohosgen/src/main/java/utils/Constants.java new file mode 100644 index 0000000000000000000000000000000000000000..ad3e577a700b4ebaba775082060d61838f106fd7 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/utils/Constants.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 utils; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class Constants { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/utils/File.java b/src/intellij_plugin/ohosgen/src/main/java/utils/File.java new file mode 100644 index 0000000000000000000000000000000000000000..84c141bace304abb79638e068ec9f35262f79304 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/utils/File.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 utils; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class File { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/utils/Log.java b/src/intellij_plugin/ohosgen/src/main/java/utils/Log.java new file mode 100644 index 0000000000000000000000000000000000000000..cca41d9bd255c1b5cdda51965ac244584b98f810 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/utils/Log.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 utils; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class Log { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/utils/MockBgTask.java b/src/intellij_plugin/ohosgen/src/main/java/utils/MockBgTask.java new file mode 100644 index 0000000000000000000000000000000000000000..c0902375f32f05f044c2bbed1d4a01ca6a7970c8 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/utils/MockBgTask.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025-2025 Huawei Device Co., Ltd. + * 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 utils; + +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.NlsContexts; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; + +/** + *

plugtest

+ * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class MockBgTask extends Task.Backgroundable { + private VirtualFile parseFile; + + public MockBgTask(@Nullable Project project, @NlsContexts.ProgressTitle @NotNull String title, boolean flag) { + super(project, title, flag); + } + + public void setFile(VirtualFile file) { + parseFile = file; + } + + @Override + public void run(@NotNull ProgressIndicator indicator) { + doAnalysis(indicator); + } + + private void doAnalysis(@NotNull ProgressIndicator indicator) { + indicator.setFraction(0.0); + // 新增文件读取逻辑 + try { + String content = new String(parseFile.contentsToByteArray(), parseFile.getCharset()); + System.out.println(content); + + String[] lines = content.split("\n"); + for (int i = 0; i < lines.length; i++) { + // 模拟处理每一行 + indicator.setFraction((i + 1) / (double) lines.length); + indicator.setText("Dts2cpp steps : " + (i + 1) + "/" + lines.length); + + // 这里添加实际业务逻辑 + processLine(lines[i]); + + Thread.sleep(50); // 调整延时更符合实际场景 + } + } catch (InterruptedException | IOException ex) { + System.out.println("Error: " + ex.getMessage() + "Failure"); + } + } + + // 示例行处理方法 + private void processLine(String line) { + // 实际业务逻辑(如语法分析/代码检查等) + } +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/utils/PluginError.java b/src/intellij_plugin/ohosgen/src/main/java/utils/PluginError.java new file mode 100644 index 0000000000000000000000000000000000000000..9a3c770609c2e0ff4fc986d232da72ed9fa288ff --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/utils/PluginError.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 utils; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class PluginError { +} diff --git a/src/intellij_plugin/ohosgen/src/main/java/utils/Widget.java b/src/intellij_plugin/ohosgen/src/main/java/utils/Widget.java new file mode 100644 index 0000000000000000000000000000000000000000..f4fec01e3f51c1f6075a1ea8d7f493d5161cd250 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/java/utils/Widget.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital. + * 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 utils; + +/** + *

类名:该类用于xxx

+ * description ${description} + * + * @author ${USER} + * date 2025-02-28 + * @since 2025-02-28 + * @version 1.0 + */ +public class Widget { +} diff --git a/src/intellij_plugin/ohosgen/src/main/resources/META-INF/plugin.xml b/src/intellij_plugin/ohosgen/src/main/resources/META-INF/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..32a236ac7af3b36b686562763690187023b071f7 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/resources/META-INF/plugin.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + com.example.napigenerator + + + NapiGenerator + + + Kaihong Digital Industry Development Co. + + + + transfer dts files to c files + ]]> + + + com.intellij.modules.platform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/intellij_plugin/ohosgen/src/main/resources/META-INF/pluginIcon.svg b/src/intellij_plugin/ohosgen/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 0000000000000000000000000000000000000000..dcf6b99db0d595df511a51a8c6ef4a64f1eb30d4 --- /dev/null +++ b/src/intellij_plugin/ohosgen/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file