Hi Marc-André,
I need your guide on low level issue and hope not much in the future.
This is my trying code (assume “UMLet” is a project name in my Eclipse workspace):
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Display;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.eclipse.cdt.build.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.model.CoreModel;
……
String name = "UMLet";
//IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(name);
project.create(null);
project.open(null);
CCorePlugin.getDefault().createCDTProject(project.getDescription(), project, null);
//ICProject soproject = CoreModel.getDefault().create(project);
//ITranslationUnit tu = CoreModel.getDefault().createTranslationUnitFrom(CoreModel.getDefault().create(project), null);
IASTTranslationUnit ast = CoreModel.getDefault().createTranslationUnitFrom(CoreModel.getDefault().create(project), null).getAST();
While build I got this error:
Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project com.umlet.plugin: Compilation failure: Compilation failure:
C:\Users\mcheng\FlexTrade\auto plugin\qfixsoden\umlet-eclipse-plugin\src\main\java\com\baselet\plugin\gui\EclipseGUI.java:[367]
IASTTranslationUnit ast = CoreModel.getDefault().createTranslationUnitFrom(CoreModel.getDefault().create(project), null).getAST();
^^^^^^^^^^^^^^^^^^^
IASTTranslationUnit cannot be resolved to a type
C:\Users\mcheng\FlexTrade\auto plugin\qfixsoden\umlet-eclipse-plugin\src\main\java\com\baselet\plugin\gui\EclipseGUI.java:[367]
IASTTranslationUnit ast = CoreModel.getDefault().createTranslationUnitFrom(CoreModel.getDefault().create(project), null).getAST();
^^^^^^^^^^^^^^^^^^^^^^^^^
The method createTranslationUnitFrom(ICProject, IPath) is ambiguous for the type CoreModel
As long as I have a separate Interface stmt like IWorkspace/ICProject/ IASTTranslationUnit xx == blabla; I will get similar error. If I merge 2 lines into one for example
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root= workspace.getRoot();
Into
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
Then it’s ok. So I think I the env can get right jar file.
Thanks.
Sent from
Mail for Windows 10