Find Method Sign Line Number
package java9; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.regex.Pattern; public class TTT { public static void main(String args[]) throws IOException { List<String> readAllLines = Files.readAllLines(Paths
.get("/Users/hongtaowang/git/spring-boot-jpa-demo/src/main/java/com/my/app/web/IndexController.java")); int issueLine = 29; String preMethodSignNumber = getPreMethodSignNumber(issueLine, readAllLines); System.out.println(preMethodSignNumber); String preSignEndChar = getPreSignEndChar(readAllLines, issueLine); System.out.println(preSignEndChar); } private static String getPreSignEndChar(List<String> readAllLines, int issueLine) {
int nextMethodSignLine = getNextMethodSignNumber(issueLine, readAllLines); for (int endLineNumber = nextMethodSignLine - 1; endLineNumber > 0; endLineNumber--) {
String endChar = readAllLines.get(endLineNumber - 1); if (endChar.contains("}")) {
return (endLineNumber) + " end line " + endChar;
} } return "";
} private static int getNextMethodSignNumber(int i, List<String> readAllLines) {
int j = i;
for (; j < readAllLines.size(); j++) {
String p = readAllLines.get(j - 1);
boolean extracted = matchMethodSign(p);
if (extracted) {
break;
} }
return j;
} private static String getPreMethodSignNumber(int currentLine, List<String> readAllLines) {
for (int preLine = currentLine - 1; preLine > 0; preLine--) {
String preLineSource = readAllLines.get(preLine - 1); if (matchMethodSign(preLineSource)) {
return (preLine) + " end line " + preLineSource;
} } return "";
} private static boolean matchMethodSign(String d) {
String pattern = ".*[A-z].* .*[A-z1-9]\\(.*";
boolean isMatch = Pattern.matches(pattern, d);
if (!isMatch) {
return false;
} if (d.contains("return")) {
return false;
} if (d.contains("=")) {
return false;
} return true;
} }
Find Method Sign Line Number的更多相关文章
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...
- 无法debug断点跟踪JDK源代码——missing line number attributes的解决方法
在项目工程->Properties->Java Build Path->Libraries中导入的JRE System Library库里,给jar包添加JDK源代码包后,能够直接打 ...
- IDEA Show Line Number
刚开始用IDEA,经常发现右侧没有显示行号,然后去右键选一下,就显现了 一直没有留意这个现象,刚用vim想删几行数据代码,突然发现没有行号了 明明记得刚刚才右键显示了的 好吧,有行号用着比较顺心了.. ...
- Eclipse-debug时提示absent line number information的解决办法
unable to install breakpoint in ...(file name) due to miss line number attributes. midify compliter ...
- Unable to perform unmarshalling at line number 16 and column 63 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: 找不到元素 'hibernate-configuration' 的声明。
七月 02, 2017 4:32:37 下午 org.hibernate.Version logVersionINFO: HHH000412: Hibernate Core {5.2.10.Final ...
- MyEclipse 断点打不上 提示 absent line number information
在加入断点时,提示出 unable to install breakpoint in ...(file name) due to miss line number attributes. midify ...
- eclipse报错:unable to install breakpoint in .......due to missing line number attributes
报错信息如下: 解决方案方案1.把断点都干掉,再启动.应该是代码更新后,断点位置没有代码了或位置改变了. 方案2.在Eclipse - Preferences - Java - Complier 下 ...
- gdb 调试 报 stepping until--- has no line number information
gdb 经常用 ,但今天使用gdb 调试的时候, break 打断点, 结果也没有打出 哪一行的信息,就只是提示一个具体地址. 使用单步调试 结果爆出 stepping until exit from ...
- javax.script.ScriptException: ReferenceError: "window" is not defined in security.js at line number 10
使用jmeter执行加密登录接口的测试遇到的问题. 问题记录: 今天使用jmeter执行加密登录接口的测试,因为测试环境的应用包是以前的老版本(可能有两年了),所以需要替换加密文件:security. ...
随机推荐
- beego注解路由不刷新(不生效)
本文主要说明本人在使用beego的注解路由时不生效问题 背景: 1.按照官网进行注解路由配置,第一次设置路由,完全正确,注解路由可用. 2.修改路由注释后,发现swagger页面并未有对应的更新 3. ...
- yocto 编译C程序
1. 找到编译器位置所在(相关设置参考/opt/poky/1.7/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi文件) poky安装在 ...
- redis编译和安装出现错误
redis编译到时候出现错误,记录一下原因 1.下载redis,https://redis.io/download ,一般选择稳定版本,稳定版的版本号是偶数,当前最新版本是5.0.4,Linux可直接 ...
- 1.1.EJB概述
1.EJB概述: Enterprice JavaBeans是一个用于分布式业务应用的标准服务端组件模型.采用Enterprice JavaBeans架构编写的应用是可伸的.事务性的. 多用户安全的.采 ...
- 解决Zabbix某台主机突然频繁告警"Zabbix agent on xxxxxx is unreachable for x minutes"
一.某台主机突然某一天频繁告警zabbix agent不可达 查看zabbix agent日志没有发现异常 二.查看zabbix server日志发现这台主机的日志有大量报错信息"first ...
- Psychos in a Line CodeForces - 319B (单调栈的应用)
Psychos in a Line CodeForces - 319B There are n psychos standing in a line. Each psycho is assigned ...
- D - A or...or B Problem
题意:给定A,B,问[A,B]里取任意个数按位或,结果有多少种. 思路:这题需要找出一个分界点,即找到最高位的B是1,A是0的位置x(最低位从0开始),那么对于所有OR的结果,x处要么是1要么是0,x ...
- python+Appium自动化:各种元素定位方法
name定位 driver.find_element_by_name('飞利浦净水').click() 测试结果报错:selenium.common.exceptions.InvalidSelecto ...
- Zabbix Server安装指南
监控模板网站 在https://share.zabbix.com/,提供了各种各样的监控模板,可以自行搜索,套用.
- Java之ExceptionHelper工具类
import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.e ...