eclipse-jdt

Is it possible to have CDT and Java IDE together in Eclipse?

泄露秘密 提交于 2019-12-03 05:49:38
I have an Eclipse CDT environment up and running and customised just the way I like it. I'm also going to be heavily dealing with Java. I don't want to install a separate version of Eclipse just to get the Java features, as I'll be switching between C -> C++ -> ADA -> Java quite often. Because of this I'd like the one IDE to support all the languages. At the moment I've got C/C++ and Ada working together (CDT + GNAT workbench). How can I get the Eclipse Java support installed with out installing Eclipse from scratch again? I've had both installed together without problems. In fact I had the

Eclipse AST not changing files which are not opened in eclipse

别来无恙 提交于 2019-12-02 08:06:12
问题 I am trying to modify source code using eclipse plugin, JDT and AST (Abstract Syntax Tree). I can read all Java files and make operation on all those file, But when i am saving those changes (Edits) in to files using TextEdit edits = rewriter.rewriteAST(); // apply the text edits to the compilation unit edits.apply(document); iCompilationUnit.getBuffer().setContents(document.get()); It only make changes in file those are open in eclipse in unsaved mode. Rest of files are not affected. Find my

How to convert AST to JDT Java model

天大地大妈咪最大 提交于 2019-12-02 05:20:12
问题 I am writing unit tests for my plugin that makes use of IType and IMethod interfaces from JDT. To write unit tests I would need to instantiate such interfaces. Answer to this question shows how to create AST model, but I don't know how to convert it into Java model? My code looks like this: String source = "package com.test\n" + "\n" + "import com.test.something;" + "\n" + "public class Class{\n" + "int sum(int a, int b)\n" + "}\n"; ASTParser parser = ASTParser.newParser(AST.JLS4); parser

Eclipse AST not changing files which are not opened in eclipse

两盒软妹~` 提交于 2019-12-02 05:07:32
I am trying to modify source code using eclipse plugin, JDT and AST (Abstract Syntax Tree). I can read all Java files and make operation on all those file, But when i am saving those changes (Edits) in to files using TextEdit edits = rewriter.rewriteAST(); // apply the text edits to the compilation unit edits.apply(document); iCompilationUnit.getBuffer().setContents(document.get()); It only make changes in file those are open in eclipse in unsaved mode. Rest of files are not affected. Find my code snippet below: CompilationUnit cu = parse(iCompilationUnit); MethodVisitor visitor = new

How to convert AST to JDT Java model

霸气de小男生 提交于 2019-12-02 00:38:45
I am writing unit tests for my plugin that makes use of IType and IMethod interfaces from JDT. To write unit tests I would need to instantiate such interfaces. Answer to this question shows how to create AST model, but I don't know how to convert it into Java model? My code looks like this: String source = "package com.test\n" + "\n" + "import com.test.something;" + "\n" + "public class Class{\n" + "int sum(int a, int b)\n" + "}\n"; ASTParser parser = ASTParser.newParser(AST.JLS4); parser.setSource(source.toCharArray()); CompilationUnit unit = (CompilationUnit) parser.createAST(null); So I

Cannot cast eclipse project to IJavaProject

丶灬走出姿态 提交于 2019-12-01 16:29:42
I have the following code IJavaProject targetProject = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (IProject project : root.getProjects()) { if (project.getName().equals(projName)) { try { if (project.hasNature("org.eclipse.jdt.core.javanature")) { targetProject = (IJavaProject) project; } } catch( ... ) { // etc ... } What I am trying to do is essentially return a project that matches a particular name as an IJavaProject. As you can see, I check to ensure that the project in question has a java nature by calling: if (project.hasNature("org.eclipse.jdt.core

Cannot cast eclipse project to IJavaProject

ⅰ亾dé卋堺 提交于 2019-12-01 15:59:16
问题 I have the following code IJavaProject targetProject = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (IProject project : root.getProjects()) { if (project.getName().equals(projName)) { try { if (project.hasNature("org.eclipse.jdt.core.javanature")) { targetProject = (IJavaProject) project; } } catch( ... ) { // etc ... } What I am trying to do is essentially return a project that matches a particular name as an IJavaProject. As you can see, I check to ensure that

In Java, can “void” be considered a primitive type?

試著忘記壹切 提交于 2019-12-01 15:12:18
I've noticed eclipse JDT uses void as a primitive type . Can this be considered correct? Pops I find that, in cases like this, you can't beat going to the Java Language Specification. It is pretty clear about the fact that void is not a primitive. First off, void is not in the list of primitive types . Later on, the JLS explicitly states: the Java programming language does not allow a "cast to void" — void is not a type http://java.sun.com/docs/books/jls/third_edition/html/statements.html#5989 (emphasis mine) Furthermore, void appears in the list of keywords , not the list of literals. The

How to get a class name of a method by using Eclipse JDT ASTParser?

雨燕双飞 提交于 2019-12-01 14:23:33
What I am trying to do is to get a class name of a method. For example, I want to get a class of 'until' and 'search' methods. Here are the code. Query query = new Query(queryStr).until(dateStr); QueryResult queryResult = twitter1.search(query); From these examples, the expected results are Query.until and SearchResource.search . But when I used this code below, I only got until and search , no class name. If I use MethodInvocation.getExpression(), I can get the names of the instances:new Query(queryStr) and twitter1. But they are not what I really want. ASTParser parser = ASTParser.newParser

How to get a class name of a method by using Eclipse JDT ASTParser?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 13:17:45
问题 What I am trying to do is to get a class name of a method. For example, I want to get a class of 'until' and 'search' methods. Here are the code. Query query = new Query(queryStr).until(dateStr); QueryResult queryResult = twitter1.search(query); From these examples, the expected results are Query.until and SearchResource.search . But when I used this code below, I only got until and search , no class name. If I use MethodInvocation.getExpression(), I can get the names of the instances:new