package base;import com.intellij.openapi.actionSystem.AnActionEvent;import com.intellij.openapi.project.Project;import com.intellij.psi.PsiClass;import com.yourkit.util.Strings;import util.PsiClassUtil;/*** 杭州蓝诗网络科技有限公司 版权所有 © Copyright 2018<br>* 上下文信息* @Description: <br>* @Project: hades <br>* @CreateDate: Created in 2018年8月22日 09:52 <br>* @Author: <a href="yechangjun@quannengzhanggui.com">lomoye</a>*/public class ActionContext {private String rootPath;//根路径private String domainPath;//当前实体类路径private String className;//类名private String projectName;//项目名称private PsiClass psiClass;//class信息private Project project;//项目private AnActionEvent event;//事件public static ActionContext valueOf(AnActionEvent event, PsiClass psiClass) {ActionContext context = new ActionContext();context.setEvent(event);context.setPsiClass(psiClass);Project project = event.getProject();if (project == null) {throw new RuntimeException("project is null");}context.setProject(project);String rootPath = project.getBasePath();if (Strings.isNullOrEmpty(rootPath)) {throw new RuntimeException("basePath is null");}context.setRootPath(rootPath);context.setDomainPath(PsiClassUtil.getSourcePath(psiClass));context.setClassName(psiClass.getName());context.setProjectName(rootPath.substring(rootPath.lastIndexOf("/") + 1));return context;}public String getRootPath() {return rootPath;}public void setRootPath(String rootPath) {this.rootPath = rootPath;}public String getDomainPath() {return domainPath;}public void setDomainPath(String domainPath) {this.domainPath = domainPath;}public String getClassName() {return className;}public void setClassName(String className) {this.className = className;}public String getProjectName() {return projectName;}public void setProjectName(String projectName) {this.projectName = projectName;}public PsiClass getPsiClass() {return psiClass;}public void setPsiClass(PsiClass psiClass) {this.psiClass = psiClass;}public Project getProject() {return project;}public void setProject(Project project) {this.project = project;}public AnActionEvent getEvent() {return event;}public void setEvent(AnActionEvent event) {this.event = event;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。