MCPcopy Index your code
hub / github.com/WangJi92/arthas-idea-plugin

github.com/WangJi92/arthas-idea-plugin @2.50

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.50 ↗ · + Follow
801 symbols 2,261 edges 152 files 335 documented · 42%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

arthas idea plugin

联系方式

有问题直接加我微信wj983433479 或者 扫码添加钉钉群 32102545 沟通

帮助文档链接

more issue : https://github.com/WangJi92/arthas-idea-plugin/issues label=documentation * arthas idea plugin document * arthas + arthas idea plugin 实战视频 * arthas-idea-plugin demo

如果你喜欢这款插件,欢迎给身边的小伙伴推荐,给个github star,谢谢

一、背景

目前Arthas 官方的工具还不够足够的简单,需要记住一些命令,特别是一些扩展性特别强的高级语法,比如ognl获取spring context 为所欲为,watch、trace 不够简单,需要构造一些命令工具的信息,因此只需要一个能够简单处理字符串信息的插件即可使用。当在处理线上问题的时候需要最快速、最便捷的命令,因此Idea arthas 插件还是有存在的意义和价值的。

二、支持的功能

支持的功能都是平时处理最常用的一些功能,一些快捷的链接,在处理紧急问题时候不需要到处查找,都是一些基本的功能,自动复制到剪切板中去,方便快捷。

image

2.1 watch

watch StringUtils uncapitalize '{params,returnObj,throwExp}' -n 5 -x 3

2.2 trace

trace StringUtils uncapitalize -n 5

2.3 static ognl (字段或者方法)

2.3.1 右键static ognl

2.3.2 获取classload命令

必须要获取,不然会找不到classload,arthas 官方获取问题系统的classload,spring 项目应该无法获取到这个class的信息,因此首先执行一下这个命令

sc -d StringUtils

2.3.2 复制到界面,获取命令,执行即可

ognl  -x  3  '@StringUtils@uncapitalize(" ")' -c 8bed358

2.4 Invoke Bean Method

实际上就是根据当前的spring项目中的获取静态的spring context这样可以直接根据这个context直接获取任何的Bean方法,一般在Java后端服务中都有这样的Utils类,因此这个可以看为一个常量! 可以参考:arthas idea demo 有了这个,我们可以跟进一步的进行数据简化,由于在idea这个环节中,可以获取方法参数,spring bean的名称等等,非常的方便。

package com.wangji92.arthas.plugin.demo.common;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 提供给arthas ognl 获取context的信息
 *
 * @author 汪小哥
 * @date 30-28-2020
 */
@Component
public class ApplicationContextProvider implements ApplicationContextAware {
    private static ApplicationContext context;

    public ApplicationContext getApplicationContext() {
        return context;
    }

    @Override
    public void setApplicationContext(ApplicationContext ctx) {
        context = ctx;
    }
}

2.4.1 设置获取spring context的上下文

最新版本 推荐使用vmtool

arthas idea plugin 配置

2.4.2 右键点击需要调用的方法

这里的策略和static ognl 一样的,本质还是ognl的调用。

ognl  -x  3  '#springContext=@applicationContextProvider@context,#springContext.getBean("arthasInstallCommandAction").actionPerformed(new com.intellij.openapi.actionSystem.AnActionEvent())' -c desw22

特别说明对于ognl 字段类型的处理

2.6 常用特殊用法链接

Development Guide

CONTRIBUTING

Extension points exported contracts — how you extend this code

TypeDefaultValue (Interface)
获取类型的默认值信息 TypeValueAnalysisFactory#initialize() 初始化在这里 @author wangji @date 2024/5/19 13:13 [48 implementers]
src/com/github/idea/json/parser/typevalue/TypeDefaultValue.java
MultiTypeDefaultValue (Interface)
有多个类型 @author wangji @date 2024/5/20 22:26 [6 implementers]
src/com/github/idea/json/parser/typevalue/MultiTypeDefaultValue.java
EnumCode (Interface)
@author 汪小哥 @date 21-03-2020
src/com/github/idea/arthas/plugin/common/enums/base/EnumCode.java
EnumCodeMsg (Interface)
https://blog.csdn.net/u012881904/article/details/104763791 @author 汪小哥 @date 21-03-2020
src/com/github/idea/arthas/plugin/common/enums/base/EnumCodeMsg.java
ArthasCommandConstants (Interface)
arthas plugin 插件中使用的常量的信息 @author 汪小哥 @date 21-12-2019
src/com/github/idea/arthas/plugin/constants/ArthasCommandConstants.java

Core symbols most depended-on inside this repo

getName
called by 137
src/com/github/idea/arthas/plugin/action/terminal/tunnel/ArthasTerminalManager.java
getCode
called by 111
src/com/github/idea/arthas/plugin/common/enums/base/EnumCode.java
getPsiElement
called by 94
src/com/github/idea/arthas/plugin/common/command/CommandContext.java
getInstance
called by 68
src/com/github/idea/arthas/plugin/setting/AppSettingsState.java
newActionLink
called by 65
src/com/github/idea/arthas/plugin/utils/ActionLinkUtils.java
notifyMessage
called by 62
src/com/github/idea/arthas/plugin/utils/NotifyUtils.java
setClipboardString
called by 58
src/com/github/idea/arthas/plugin/utils/ClipboardUtils.java
toString
called by 56
src/com/github/idea/arthas/plugin/utils/StringUtils.java

Shape

Method 642
Class 148
Enum 6
Interface 5

Languages

Java100%

Modules by API surface

src/com/github/idea/arthas/plugin/utils/OgnlPsUtils.java31 symbols
src/com/github/idea/arthas/plugin/ui/ArthasShellScriptCommandDialog.java22 symbols
src/com/github/idea/arthas/plugin/ui/ArthasOgnlEnumActionDialog.java22 symbols
src/com/github/idea/arthas/plugin/ui/AppSettingsPage.java20 symbols
src/com/github/idea/arthas/plugin/action/terminal/tunnel/ArthasTerminalManager.java20 symbols
src/com/github/idea/arthas/plugin/setting/AppSettingsState.java16 symbols
src/com/github/idea/arthas/plugin/ui/ArthasTunnelTerminalPretreatmentDialog.java14 symbols
src/com/github/idea/arthas/plugin/ui/ArthasTraceMultipleCommandDialog.java14 symbols
src/com/github/idea/arthas/plugin/ui/ArthasAsyncProfileDialog.java14 symbols
src/com/github/idea/json/parser/PsiParserToJson.java13 symbols
src/com/github/idea/arthas/plugin/action/terminal/tunnel/ArthasTerminalExecutor.java12 symbols
src/com/github/idea/json/parser/toolkit/PsiToolkit.java11 symbols

For agents

$ claude mcp add arthas-idea-plugin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page