Eclipse Helios会定期开始运行显示"计算其他信息"的作业.在此期间,Eclipse非常缓慢,接近无法使用.这项工作做什么?我可以把它关掉吗?
我只希望JDT团队中的某个人能够感知并摆脱它,使其更快,或者至少将其改为有意义的东西.
我是AST的新手(我第一次写插件).表达在现实生活中可能相当复杂.例如,我想知道如何解决对齐的左侧和右侧.
class Visitor extends ASTVisitor
{
@Override
public boolean visit(Assignment node)
{
//here, how do I get the final name to each each side of the assignment resolves?
}
}
Run Code Online (Sandbox Code Playgroud)
我还有另一个疑问,我如何获取用于调用方法的实例?
public boolean visit(MethodInvocation node)
{
//how do I get to know the object used to invoke this method?
//like, for example, MyClass is a class, and it has a field called myField
//the type of myField has a method called myMethod.
//how do I find myField? or for that …Run Code Online (Sandbox Code Playgroud) 安装 2019-12 版本的 Eclipse 后,我无法在使用深色主题和默认颜色集时设置黑色背景。如果我在 General -> Editors -> Text Editors -> Appearance color options -> Background color 中更改颜色 - 我看到行号背景颜色更改为我的选择,而文本区域保持相同的深灰色,无论我选择什么颜色.
我试图手动编辑 epf 首选项并将它们导入回来,但即使这样也行不通。Eclipse 2019-12 中是否存在一些覆盖用户选择的更改/错误?有一些关于 Eclipse 颜色的问题已经得到解答,但我相信在最近的更改后它们没有帮助。
我正在编写一个Eclipse插件,它使用JDT AST ASTParser来解析方法.我在该方法中寻找创建特定类型的对象.
当我找到a时ClassInstanceCreation,我会调用getType()它来查看实例化的类型.我想确保那里处理的完全解析类型是我认为的那个,所以我告诉结果Type对象resolveBinding().我得null回去,即使没有编译错误,即使我叫setResolveBindings(true)上我ASTParser.我给了我的ASTParser(via setSource())ICompilationUnit包含我的方法,因此解析器可以访问整个工作区上下文.
final IMethod method = ...;
final ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setResolveBindings(true);
parser.setSource(method.getCompilationUnit());
parser.setSourceRange(method.getSourceRange().getOffset(), method.getSourceRange().getLength());
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
final TypeDeclaration astRoot = (TypeDeclaration) parser.createAST(null);
final ClassInstanceCreation classInstanceCreation = walkAstAndFindMyExpression(astRoot);
final Type instantiatedType = classInstanceCreation.getType();
System.out.println("BINDING: " + instantiatedType.resolveBinding());
Run Code Online (Sandbox Code Playgroud)
为什么要resolveBinding()回来null?我怎样才能获得绑定信息?
我有一个Java应用程序,我想为用户提供编译Java源代码的能力(使用JavaCompiler接口)
如果用户在JRE上运行应用程序,我的应用程序应该告诉用户没有JavaCompiler实例可用.
那么如何在java程序中检测JDK或JRE?
运行Maven -> Update Project...带有Update project configuration from pom.xml选项选项的工具后,我开始在我的.classpath文件中注意到这些属性:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
...
</classpathentry>
Run Code Online (Sandbox Code Playgroud)
让我最引人注目的属性是:<attribute name="optional" value="true"/>.
它有什么作用?它看起来很可疑,因为我在项目中找不到关于我的java源文件的可选项.
我有一个类的IType对象.我想知道这个类是否是一个抽象类.IType或ICompilationUnit中是否有任何方法可用于确定相同的方法(反射除外).
随着Eclipse java 8支持的发布,我理解类型(JSR 308)上的null注释是可能的,如此处所述.我已经安装了JDK8和Eclipse Kepler 的Java 8功能补丁.我本来希望能够声明一个不允许这样的空值的列表:
List<@NonNull String> nonulls;
Run Code Online (Sandbox Code Playgroud)
但是,编译器告诉我"该位置不允许注释@NonNull":(
我的项目配置为使用编译器合规性级别1.8,并且org.eclipse.jdt.annotation jar包含在类路径中.
我在这里错过了什么?
问候,
我正在创建一个java代理,用于对某些类进行一些字节码修改org.eclipse.jdt.core.JDTCompilerAdapter就是其中之一.我正在使用javassit来修改一些execute()方法org.eclipse.jdt.core.JDTCompilerAdapter.所以我在我的代理项目中包含了ecj(使用gradle)
compile group: 'org.eclipse.jdt.core.compiler' ,name: 'ecj', version :'4.3.1'
Run Code Online (Sandbox Code Playgroud)
因为我需要使用ecj中的一些类.
代理的目标是拦截对execute方法的调用,修改execute方法以向我的某些类添加一些调用,以触发一些处理.
我正在针对具有2个类的Simple Java项目测试代理.该项目使用ant构建并JDTCompilerAdapter用作编译器.
这是build.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="TestProject">
<property file="build.properties" />
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<path id="PClasspath">
<pathelement location="bin"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="init" name="build">
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/> …Run Code Online (Sandbox Code Playgroud) 我正在开发一个注释处理器.这是一个经典的maven项目结构.
project
- src/main
- java // SOURCE_PATH
- resources // SOURCE_PATH
- target
- classes // CLASS_PATH and CLASS_OUTPUT
- generated-sources
- annotations // SOURCE_OUTPUT
Run Code Online (Sandbox Code Playgroud)
在与javac的maven中一切都很好.但是当我想将它集成到eclipse中时,我发现eclipse只支持CLASS_OUTPUT和SOURCE_OUTPUT.
我认为CLASS_OUTPUT也可以,因为它等于CLASS_PATH.然后我得到以下异常
org.eclipse.core.internal.resources.ResourceException: Resource '/test-annotation-use-processer/target/classes/config.properties' does not exist.
at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:335)
at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:209)
at org.eclipse.core.internal.resources.File.getContents(File.java:275)
at org.eclipse.core.internal.resources.File.getContents(File.java:268)
at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeInputFileObject.openInputStream(IdeInputFileObject.java:86)
Run Code Online (Sandbox Code Playgroud)
那么,该文件确实存在于磁盘中.我不知道日食有什么不对.
有没有办法在eclipse apt中获取资源?