CodeGenUtil.EclipseUtil.findOrCreateContainer (projectRelativePath, true, CodeGenUtil.EclipseUtil.findOrCreateContainer (projectRelativePath, true,
/** * @deprecated in 2.2. Please use {@link CodeGenUtil.EclipseUtil#addClasspathEntries(Collection, String, String)} instead. */ @SuppressWarnings("unchecked") @Deprecated public static void addClasspathEntries(Collection classpathEntries, String variableName, String pluginID) throws JETException { EclipseUtil.addClasspathEntries(classpathEntries, variableName, pluginID); }
if (project.exists()) String complianceLevel = CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project); if ("1.4".equals(complianceLevel))
ASTParser astParser = CodeGenUtil.EclipseUtil.newASTParser(true); astParser.setCompilerOptions(Collections.singletonMap(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.ERROR)); astParser.setResolveBindings(true);
String complianceLevel = CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project); if ("1.5".equals(complianceLevel)) CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_COMMON", "org.eclipse.emf.common"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_ECORE", "org.eclipse.emf.ecore"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_EDIT", "org.eclipse.emf.edit"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_SWT", "org.eclipse.swt"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_JFACE", "org.eclipse.jface"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_VIEWS", "org.eclipse.ui.views"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_IDE", "org.eclipse.ui.ide"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_COMMON_UI", "org.eclipse.emf.common.ui"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_EDIT_UI", "org.eclipse.emf.edit.ui"); if ((style & EMF_XML_PROJECT_STYLE) == 0) CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "JUNIT", "org.junit"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, name, id);
String complianceLevel = CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project); if ("1.5".equals(complianceLevel)) CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_COMMON", "org.eclipse.emf.common"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_ECORE", "org.eclipse.emf.ecore"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_EDIT", "org.eclipse.emf.edit"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_SWT", "org.eclipse.swt"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_JFACE", "org.eclipse.jface"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_VIEWS", "org.eclipse.ui.views"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_IDE", "org.eclipse.ui.ide"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_COMMON_UI", "org.eclipse.emf.common.ui"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_EDIT_UI", "org.eclipse.emf.edit.ui"); if ((style & EMF_XML_PROJECT_STYLE) == 0) CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, "JUNIT", "org.junit"); CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries, name, id);
CodeGenUtil.EclipseUtil.findOrCreateContainer (new Path(path.segment(0)), true, BasicMonitor.toIProgressMonitor(CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1))); gen.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1)); gen.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1)); gen.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1)); gen.generate(genModel, GenBaseGeneratorAdapter.TESTS_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1));
CodeGenUtil.EclipseUtil.findOrCreateContainer (new Path(path.segment(0)), true, BasicMonitor.toIProgressMonitor(CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1))); gen.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1)); gen.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1)); gen.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1)); gen.generate(genModel, GenBaseGeneratorAdapter.TESTS_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(progressMonitor, 1));
CodeGenUtil.EclipseUtil.addClasspathEntries(jetEmitter.getClasspathEntries(), variableName, pluginID);
CodeGenUtil.EclipseUtil.findOrCreateContainer(projectTargetPath, true, targetPath, BasicMonitor.subProgress(progressMonitor, 1)); IFile targetFile = container.getFile(new Path(jetCompiler.getSkeleton().getClassName() + ".java"));
CodeGenUtil.EclipseUtil.addClasspathEntries(jetEmitter.getClasspathEntries(), variableName, pluginID);
CodeGenUtil.EclipseUtil.findOrCreateContainer(projectTargetPath, true, targetPath, new SubProgressMonitor(progressMonitor, 1)); IFile targetFile = container.getFile(new Path(jetCompiler.getSkeleton().getClassName() + ".java"));
CodeGenUtil.EclipseUtil.findOrCreateContainer (projectRelativePath, true, CodeGenUtil.EclipseUtil.findOrCreateContainer (projectRelativePath, true,
Generator.EMF_MODEL_PROJECT_STYLE | Generator.EMF_PLUGIN_PROJECT_STYLE); CodeGenUtil.EclipseUtil.findOrCreateContainer (new Path("/" + genModelContainerPath.segment(0) + "/model"), true, genModelProjectLocation, progressMonitor);
String complianceLevel = CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project); if ("1.5".equals(complianceLevel))
public static void addClasspathEntries(Collection<IClasspathEntry> classpathEntries, String variableName, String pluginID) throws JETException { for (ListIterator<String> i = getClasspathPaths(pluginID).listIterator(); i.hasNext(); ) { IPath path = new Path(i.next()); if (variableName == null) { classpathEntries.add (JavaCore.newLibraryEntry (path, null, null, null, new IClasspathAttribute [] { JavaCore.newClasspathAttribute(PLUGIN_ID_CLASSPATH_ATTRIBUTE_NAME, pluginID) } , true)); } else { String mangledName = variableName + (i.previousIndex() == 0 ? "" : "_" + i.previousIndex()); try { JavaCore.setClasspathVariable(mangledName, path, null); } catch (JavaModelException exception) { throw new JETException(exception); } classpathEntries.add (JavaCore.newVariableEntry (new Path(mangledName), null, null, null, new IClasspathAttribute [] { JavaCore.newClasspathAttribute(PLUGIN_ID_CLASSPATH_ATTRIBUTE_NAME, pluginID) }, true)); } } }
public static void addClasspathEntries(Collection<IClasspathEntry> classpathEntries, String variableName, String pluginID) throws JETException { for (ListIterator<String> i = getClasspathPaths(pluginID).listIterator(); i.hasNext(); ) { IPath path = new Path(i.next()); if (variableName == null) { classpathEntries.add (JavaCore.newLibraryEntry (path, null, null, null, new IClasspathAttribute [] { JavaCore.newClasspathAttribute(PLUGIN_ID_CLASSPATH_ATTRIBUTE_NAME, pluginID) } , true)); } else { String mangledName = variableName + (i.previousIndex() == 0 ? "" : "_" + i.previousIndex()); try { JavaCore.setClasspathVariable(mangledName, path, null); } catch (JavaModelException exception) { throw new JETException(exception); } classpathEntries.add (JavaCore.newVariableEntry (new Path(mangledName), null, null, null, new IClasspathAttribute [] { JavaCore.newClasspathAttribute(PLUGIN_ID_CLASSPATH_ATTRIBUTE_NAME, pluginID) }, true)); } } }
/** * Creates and returns <code>ASTParser</code>. * * @return new ASTParser object */ protected ASTParser createASTParser() { // caching parser does not parse 2nd file in the same way (javadoc of package for example) // hence, new parser is created every time this method is called ASTParser astParser = CodeGenUtil.EclipseUtil.newASTParser(true); Map<String, String> javaCoreOptions = new HashMap<String, String>(); for (Map.Entry<?, ?> entry : getJavaCoreOptions().entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (key instanceof String && value instanceof String) { javaCoreOptions.put((String)key, (String)value); } } astParser.setCompilerOptions(javaCoreOptions); return astParser; }
public static List<String> getCompilationUnitImports(String compilationUnitContents) { List<String> result = new ArrayList<String>(); ASTParser parser = cachedASTParser.getAndSet(null); if (parser == null) { parser = CodeGenUtil.EclipseUtil.newASTParser(true); } parser.setSource(compilationUnitContents.toCharArray()); CompilationUnit compilationUnit = (CompilationUnit)parser.createAST(new NullProgressMonitor()); for (Iterator<?> i = compilationUnit.imports().iterator(); i.hasNext();) { ImportDeclaration importDeclaration = (ImportDeclaration)i.next(); result.add(importDeclaration.getName().getFullyQualifiedName()); } cachedASTParser.set(parser); return result; } }
public static void addClasspathEntries(Collection<IClasspathEntry> classpathEntries, String pluginID) throws JETException { addClasspathEntries(classpathEntries, null, pluginID); }