List of usage examples for org.eclipse.jdt.core IJavaElement getJavaProject
IJavaProject getJavaProject();
null
if this element is not contained in any Java project (for instance, the IJavaModel
is not contained in any Java project). From source file:org.codehaus.groovy.eclipse.core.model.GroovyProjectFacade.java
License:Apache License
public GroovyProjectFacade(IJavaElement elt) { this.project = elt.getJavaProject(); }
From source file:org.codehaus.groovy.eclipse.core.search.SyntheticAccessorSearchRequestor.java
License:Apache License
private boolean isInteresting(IJavaElement element) { return element instanceof IMember && GroovyNature.hasGroovyNature(element.getJavaProject().getProject()); }
From source file:org.codehaus.groovy.eclipse.launchers.AbstractGroovyLaunchShortcut.java
License:Apache License
private String getProjectLocation(IJavaElement elt) { return "${workspace_loc:/" + elt.getJavaProject().getProject().getName() + "}"; }
From source file:org.codehaus.groovy.eclipse.launchers.GroovyShellLaunchShortcut.java
License:Apache License
/** * Launches from the package explorer.//from w w w.j a va 2s. c om * * @see ILaunchShortcut#launch */ public void launch(ISelection selection, String mode) { if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() instanceof IJavaElement) { IStructuredSelection structredSelection = (IStructuredSelection) selection; IJavaElement elt = (IJavaElement) structredSelection.getFirstElement(); launchGroovy(elt.getJavaProject(), mode); } }
From source file:org.eclim.plugin.jdt.command.doc.CommentCommand.java
License:Open Source License
/** * Comment a package declaration.// ww w .j a v a 2 s . co m * * @param src The source file. * @param javadoc The Javadoc. * @param element The IJavaElement. * @param isNew true if there was no previous javadoc for this element. */ private void commentPackage(ICompilationUnit src, Javadoc javadoc, IJavaElement element, boolean isNew) throws Exception { IProject project = element.getJavaProject().getProject(); String copyright = getPreferences().getValue(project, Preferences.PROJECT_COPYRIGHT_PREFERENCE); if (copyright != null && copyright.trim().length() > 0) { File file = new File(ProjectUtils.getFilePath(project, copyright)); if (!file.exists()) { throw new IllegalArgumentException(Services.getMessage("project.copyright.not.found", file)); } @SuppressWarnings("unchecked") List<TagElement> tags = javadoc.tags(); tags.clear(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { addTag(javadoc, tags.size(), null, line); } } finally { IOUtils.closeQuietly(reader); } } else { commentOther(src, javadoc, element, isNew); } }
From source file:org.eclim.plugin.jdt.command.doc.CommentCommand.java
License:Open Source License
/** * Comment a type declaration./*from w w w . ja v a2 s .com*/ * * @param src The source file. * @param javadoc The Javadoc. * @param element The IJavaElement. * @param isNew true if there was no previous javadoc for this element. */ private void commentType(ICompilationUnit src, Javadoc javadoc, IJavaElement element, boolean isNew) throws Exception { if (element.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) { @SuppressWarnings("unchecked") List<TagElement> tags = javadoc.tags(); IProject project = element.getJavaProject().getProject(); if (isNew) { addTag(javadoc, tags.size(), null, null); addTag(javadoc, tags.size(), null, null); addTag(javadoc, tags.size(), TagElement.TAG_AUTHOR, getAuthor(project)); String version = getPreferences().getValue(project, "org.eclim.java.doc.version"); if (version != null && !StringUtils.EMPTY.equals(version.trim())) { version = StringUtils.replace(version, "\\$", "$"); addTag(javadoc, tags.size(), TagElement.TAG_VERSION, version); } } else { // check if author tag exists. int index = -1; String author = getAuthor(project); for (int ii = 0; ii < tags.size(); ii++) { TagElement tag = (TagElement) tags.get(ii); if (TagElement.TAG_AUTHOR.equals(tag.getTagName())) { String authorText = tag.fragments().size() > 0 ? ((TextElement) tag.fragments().get(0)).getText() : null; // check if author tag is the same. if (authorText != null && author.trim().equals(authorText.trim())) { index = -1; break; } index = ii + 1; } else if (tag.getTagName() != null) { if (index == -1) { index = ii; } } } // insert author tag if it doesn't exist. if (index > -1) { TagElement authorTag = javadoc.getAST().newTagElement(); TextElement authorText = javadoc.getAST().newTextElement(); authorText.setText(author); authorTag.setTagName(TagElement.TAG_AUTHOR); @SuppressWarnings("unchecked") List<ASTNode> fragments = authorTag.fragments(); fragments.add(authorText); tags.add(index, authorTag); } // add the version tag if it doesn't exist. boolean versionExists = false; for (int ii = 0; ii < tags.size(); ii++) { TagElement tag = (TagElement) tags.get(ii); if (TagElement.TAG_VERSION.equals(tag.getTagName())) { versionExists = true; break; } } if (!versionExists) { String version = getPreferences().getValue(project, "org.eclim.java.doc.version"); version = StringUtils.replace(version, "\\$", "$"); addTag(javadoc, tags.size(), TagElement.TAG_VERSION, version); } } } else { commentOther(src, javadoc, element, isNew); } }
From source file:org.eclipse.ajdt.core.model.AJProjectModelFacade.java
License:Open Source License
/** * @param je/*w w w . j ava 2s . c om*/ * @return */ private boolean isFromExternalProject(IJavaElement je) { return !je.getJavaProject().getProject().equals(project); }
From source file:org.eclipse.ajdt.core.model.AJProjectModelFactory.java
License:Open Source License
/** * A convenience method to get the model when the handle is a java element *//*from ww w . ja v a 2s . c o m*/ public AJProjectModelFacade getModelForJavaElement(IJavaElement elt) { try { return getModelForProject(elt.getJavaProject().getProject()); } catch (NullPointerException e) { return EMPTY_INSTANCE; } }
From source file:org.eclipse.ajdt.core.parserbridge.AJCompilationUnitProblemFinder.java
License:Open Source License
private CompilerOptions getCompilerOptions(IJavaElement elt) { IJavaProject project = elt.getJavaProject(); Map options = project == null ? JavaCore.getOptions() : project.getOptions(true); return new CompilerOptions(options); }
From source file:org.eclipse.ajdt.core.text.ITDAwareSelectionRequestor.java
License:Open Source License
private AJProjectModelFacade ensureModel(IJavaElement elt) { try {/* ww w. j a va 2 s .co m*/ if (model.getProject().equals(elt.getJavaProject().getProject())) { return model; } else { return AJProjectModelFactory.getInstance().getModelForJavaElement(elt); } } catch (Exception e) { // catch NPE if elt is null, or core exception if not stored to disk yet. return model; } }