本文整理汇总了Java中org.eclipse.jdt.core.IJavaModel类的典型用法代码示例。如果您正苦于以下问题:Java IJavaModel类的具体用法?Java IJavaModel怎么用?Java IJavaModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IJavaModel类属于org.eclipse.jdt.core包,在下文中一共展示了IJavaModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ViewSiteRelationsListener
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public ViewSiteRelationsListener(
final IRunnableContext runnableContext,
final IProgressService progressService,
final ILogger logger,
final IJavaModel model,
final IObjectModel<IItem> selectedItemModel,
final IObjectListModel<IItem> selectedItemsModel,
final Label label,
final IDependenciesModel dependenciesModel,
final WritableList<IDependencyRelation> descriptions,
final INameHitMaps nameHitMaps) {
this.runnableContext = runnableContext;
this.logger = logger;
this.progressService = progressService;
this.model = model;
this.selectedItemModel = selectedItemModel;
this.selectedItemsModel = selectedItemsModel;
this.label = label;
this.dependenciesModel = dependenciesModel;
this.descriptions = descriptions;
this.nameHitMaps = nameHitMaps;
}
示例2: UpdateDependencyModelAction
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public UpdateDependencyModelAction(
final IShellProvider shellProvider,
final Canceler canceler,
final ILogger logger,
final IJavaModel model,
final IDependenciesModel dependenciesModel,
final INameHitMaps nameHitMaps) {
this.logger = logger;
this.nameHitMaps = nameHitMaps;
setToolTipText(TOOLTIP_TEXT);
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
this.shellProvider = shellProvider;
this.canceler = canceler;
this.model = model;
this.dependenciesModel = dependenciesModel;
}
示例3: ListRunner
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public ListRunner(
final ICanceler canceler,
final ILogger logger,
final IJavaElement[] selection,
final IDependenciesModel dependenciesModel,
final IObjectModel<IItem> selectedItemModel,
final IObjectListModel<IItem> selectedItemsModel,
final Label label,
final IJavaModel model,
final WritableList<IDependencyRelation> relations,
final INameHitMaps nameHitMaps) {
this.logger = logger;
this.selection = selection;
this.dependenciesModel = dependenciesModel;
this.canceler = canceler;
this.selectedItemModel = selectedItemModel;
this.selectedItemsModel = selectedItemsModel;
this.label = label;
this.model = model;
this.relations = relations;
this.nameHitMaps = nameHitMaps;
}
示例4: getJavaProject
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public static IJavaProject getJavaProject(String projectName) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace == null) {
System.out.println("No workspace");
return null;
}
IWorkspaceRoot root = workspace.getRoot();
if (root == null) {
System.out.println("No workspace root");
return null;
}
IJavaModel javacore = JavaCore.create(root);// this gets you the java version of the workspace
IJavaProject project = null;
if (javacore != null) {
project = javacore.getJavaProject(projectName); // this returns the specified project
}
WorkspaceUtilities.javaProject = project;
return project;
}
示例5: scanForCompilationUnits
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
/**
* Traverses the workspace for CompilationUnits.
*
* @return the list of all CompilationUnits in the workspace
*/
public static List<ICompilationUnit> scanForCompilationUnits() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace == null) {
System.out.println("No workspace");
return null;
}
IWorkspaceRoot root = workspace.getRoot();
if (root == null) {
System.out.println("No workspace root");
return null;
}
IJavaModel javaModel = JavaCore.create(root);
if (javaModel == null) {
System.out.println("No Java Model in workspace");
return null;
}
// Get all CompilationUnits
return WorkspaceUtilities.collectCompilationUnits(javaModel);
}
示例6: getProjectDeltas
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
private Set<IJavaElementDelta> getProjectDeltas(IJavaElementDelta delta) {
IJavaElement element = delta.getElement();
if(delta.getElement().getElementType() == IJavaElement.JAVA_PROJECT) {
return Collections.singleton(delta);
}
Set<IJavaElementDelta> result = null;
if(element instanceof IJavaModel) {
if(delta.getAddedChildren()!=null) {
for(IJavaElementDelta child: delta.getAffectedChildren()) {
Set<IJavaElementDelta> projectDeltas = getProjectDeltas(child);
if(!projectDeltas.isEmpty()) {
if(result == null)
result = newLinkedHashSet();
result.addAll(projectDeltas);
}
}
}
}
return result == null ? Collections.<IJavaElementDelta>emptySet() : result;
}
示例7: getJavaProjectsWithClasspathChange
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
private Set<IJavaProject> getJavaProjectsWithClasspathChange(IJavaElementDelta delta) {
IJavaElement element = delta.getElement();
if (element instanceof IPackageFragmentRoot) {
IPackageFragmentRoot root = (IPackageFragmentRoot) element;
if (delta.getKind() == IJavaElementDelta.REMOVED || delta.getKind() == IJavaElementDelta.ADDED
|| (delta.getFlags() & IJavaElementDelta.F_REORDER) != 0
|| (delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0
|| (delta.getFlags() & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0
|| (root.isExternal() && (delta.getFlags() & // external folders change
(IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_SOURCEATTACHED | IJavaElementDelta.F_SOURCEDETACHED)) == delta
.getFlags())) {
return Collections.singleton(root.getJavaProject());
}
} else if (element instanceof IJavaModel) {
return getPackageFragmentRootDeltas(delta.getAffectedChildren());
} else if (element instanceof IJavaProject) {
if ((delta.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0
|| (delta.getFlags() & IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0)
return Collections.singleton((IJavaProject) element);
return getPackageFragmentRootDeltas(delta.getAffectedChildren());
}
return Collections.emptySet();
}
示例8: isAffectingPackageFragmentRoots
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
private boolean isAffectingPackageFragmentRoots(IJavaElementDelta delta) {
IJavaElement element = delta.getElement();
if (element instanceof IPackageFragmentRoot) {
if (delta.getKind() == IJavaElementDelta.REMOVED
|| delta.getKind() == IJavaElementDelta.ADDED
|| (delta.getFlags() & IJavaElementDelta.F_REORDER) != 0
|| (delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0
|| (delta.getFlags() & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0
|| (((IPackageFragmentRoot) element).isExternal() && (delta.getFlags() & // external folders change
(IJavaElementDelta.F_CONTENT
| IJavaElementDelta.F_SOURCEATTACHED
| IJavaElementDelta.F_SOURCEDETACHED)) == delta.getFlags())) {
return true;
}
} else if (element instanceof IJavaModel) {
return isAffectingPackageFragmentRoots(delta.getAffectedChildren());
} else if (element instanceof IJavaProject) {
if ((delta.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0 ||
(delta.getFlags() & IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0)
return true;
return isAffectingPackageFragmentRoots(delta.getAffectedChildren());
}
return false;
}
示例9: create
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public static ResourceMapping create(IJavaElement element) {
switch (element.getElementType()) {
case IJavaElement.TYPE:
return create((IType) element);
case IJavaElement.COMPILATION_UNIT:
return create((ICompilationUnit) element);
case IJavaElement.CLASS_FILE:
return create((IClassFile) element);
case IJavaElement.PACKAGE_FRAGMENT:
return create((IPackageFragment) element);
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
return create((IPackageFragmentRoot) element);
case IJavaElement.JAVA_PROJECT:
return create((IJavaProject) element);
case IJavaElement.JAVA_MODEL:
return create((IJavaModel) element);
default:
return null;
}
}
示例10: isDeleteAvailable
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public static boolean isDeleteAvailable(final IJavaElement element) {
if (!element.exists()) return false;
if (element instanceof IJavaModel || element instanceof IJavaProject) return false;
if (element.getParent() != null && element.getParent().isReadOnly()) return false;
if (element instanceof IPackageFragmentRoot) {
IPackageFragmentRoot root = (IPackageFragmentRoot) element;
if (root.isExternal() || Checks.isClasspathDelete(root)) // TODO: rename isClasspathDelete
return false;
if (root.getResource().equals(root.getJavaProject().getProject())) return false;
}
if (element.getResource() == null
&& !RefactoringAvailabilityTester.isWorkingCopyElement(element)) return false;
if (element instanceof IMember && ((IMember) element).isBinary()) return false;
return true;
}
示例11: verifyDestination
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
@Override
protected RefactoringStatus verifyDestination(IJavaElement javaElement)
throws JavaModelException {
Assert.isNotNull(javaElement);
if (!fCheckDestination) return new RefactoringStatus();
if (!javaElement.exists())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_cannot1);
if (javaElement instanceof IJavaModel)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
if (!(javaElement instanceof IJavaProject))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_src2proj);
if (javaElement.isReadOnly())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_src2writable);
if (ReorgUtils.isPackageFragmentRoot(javaElement.getJavaProject()))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_src2nosrc);
return new RefactoringStatus();
}
示例12: testFindSdkFor_GwtUserProject
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
/**
* Tests that we find an {@link com.google.gdt.eclipse.core.sdk.Sdk} on the
* gwt-user project.
*
* @throws Exception
*/
public void testFindSdkFor_GwtUserProject() throws Exception {
GwtRuntimeTestUtilities.importGwtSourceProjects();
try {
IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
IJavaProject javaProject = javaModel.getJavaProject("gwt-user");
GwtSdk sdk = GwtSdk.findSdkFor(javaProject);
IClasspathEntry gwtUserEntry =
JavaCore.newSourceEntry(
javaModel.getJavaProject("gwt-user").getPath().append("core/src"),
new IPath[] {new Path("**/super/**")});
/*
* NOTE: Passing null for the IClasspathAttribute array tickles a bug in
* eclipse 3.3.
*/
IClasspathEntry gwtDevEntry =
JavaCore.newProjectEntry(javaModel.getJavaProject("gwt-dev").getPath(), null, false,
new IClasspathAttribute[0] /* */, false);
IClasspathEntry[] expected = new IClasspathEntry[] {gwtUserEntry, gwtDevEntry};
assertEquals(expected, sdk.getClasspathEntries());
} finally {
GwtRuntimeTestUtilities.removeGwtSourceProjects();
}
}
示例13: isDeleteAvailable
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
public static boolean isDeleteAvailable(final IJavaElement element) {
if (!element.exists())
return false;
if (element instanceof IJavaModel || element instanceof IJavaProject)
return false;
if (element.getParent() != null && element.getParent().isReadOnly())
return false;
if (element instanceof IPackageFragmentRoot) {
IPackageFragmentRoot root= (IPackageFragmentRoot) element;
if (root.isExternal() || Checks.isClasspathDelete(root)) // TODO: rename isClasspathDelete
return false;
if (root.getResource().equals(root.getJavaProject().getProject()))
return false;
}
if (element.getResource() == null && !RefactoringAvailabilityTester.isWorkingCopyElement(element))
return false;
if (element instanceof IMember && ((IMember) element).isBinary())
return false;
return true;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:RefactoringAvailabilityTester.java
示例14: verifyDestination
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
@Override
protected RefactoringStatus verifyDestination(IJavaElement javaElement) throws JavaModelException {
Assert.isNotNull(javaElement);
if (!fCheckDestination)
return new RefactoringStatus();
if (!javaElement.exists())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot1);
if (javaElement instanceof IJavaModel)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
if (!(javaElement instanceof IJavaProject))
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2proj);
if (javaElement.isReadOnly())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2writable);
if (ReorgUtils.isPackageFragmentRoot(javaElement.getJavaProject()))
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2nosrc);
return new RefactoringStatus();
}
示例15: getChildren
import org.eclipse.jdt.core.IJavaModel; //导入依赖的package包/类
@Override
public Object[] getChildren(Object element) {
try {
if (element instanceof IJavaModel) {
return concatenate(getJavaProjects((IJavaModel)element), getOpenNonJavaProjects((IJavaModel)element));
} else {
Object[] children= doGetChildren(element);
ArrayList<Object> result= new ArrayList<Object>(children.length);
for (int i= 0; i < children.length; i++) {
IReorgDestination destination= ReorgDestinationFactory.createDestination(children[i]);
if (fValidator.canElementBeDestination(destination) || fValidator.canChildrenBeDestinations(destination))
result.add(children[i]);
}
return result.toArray();
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
return new Object[0];
}
}