List of usage examples for org.eclipse.jdt.internal.core SourceType getFullyQualifiedName
@Override
public String getFullyQualifiedName()
From source file:net.sf.fjep.fatjar.wizard.FJExportWizardConfigPage.java
License:Open Source License
/** * Uses the standard container selection dialog to choose the new value for * the container field./*from w w w . j av a 2s . c o m*/ */ private void handleManifestmainclassBrowse() { try { String mainClass = getManifestmainclass(); ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); IResource[] res = { jproject.getCorrespondingResource() }; IJavaSearchScope searchScope = JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true); SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false); dialog.setMessage("Select Main-Class for JAR file"); dialog.setTitle("Fat Jar Config"); if (dialog.open() == SelectionDialog.OK) { Object[] elements = dialog.getResult(); if (elements.length == 1) { SourceType mainElement = (SourceType) elements[0]; mainClass = mainElement.getFullyQualifiedName(); manifestmainclassText.setText(mainClass); } } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:net.sf.fjep.fatjar.wizards.export.ConfigPage.java
License:Open Source License
/** * Uses the standard container selection dialog to * choose the new value for the container field. *///from w w w.j av a 2 s .c o m private void handleManifestmainclassBrowse() { String mainClass = getManifestmainclass(); ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); IResource[] res = jproject.getResource(); IJavaSearchScope searchScope = JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true); SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false); dialog.setMessage("Select Main-Class for JAR file"); dialog.setTitle("Fat Jar Config"); if (dialog.open() == SelectionDialog.OK) { Object[] elements = dialog.getResult(); if (elements.length == 1) { SourceType mainElement = (SourceType) elements[0]; mainClass = mainElement.getFullyQualifiedName(); manifestmainclassText.setText(mainClass); } } }
From source file:org.eclipse.ajdt.core.javaelements.ITDAwareSourceTypeInfo.java
License:Open Source License
private List<IJavaElement> getITDs(SourceType type) throws JavaModelException { AJProjectModelFacade model = AJProjectModelFactory.getInstance().getModelForJavaElement(type); if (model.hasModel()) { List<IJavaElement> itds = new ArrayList<IJavaElement>(); List<IJavaElement> rels = model.getRelationshipsForElement(type, AJRelationshipManager.ASPECT_DECLARATIONS); List<IMethod> childMethods = null; for (IJavaElement ije : rels) { if (ije instanceof IntertypeElement) { IntertypeElement elt = (IntertypeElement) ije; IMember member = elt.createMockDeclaration(type); // null if the ITD doesn't exist in the AspectJ hierarchy // will happen if the Java side has partial compilation // and aspectj side does not if (member != null) { // should not add this ITD if it is a duplicate // of another ITD if (!isAlreadyAnITD(itds, member)) { continue; }// www . j a v a 2s.com itds.add(member); // additional processing for interfaces if (handle.isInterface()) { if (member.getElementType() == IJavaElement.FIELD) { // Bug 262969 // Interfaces can't have fields, so ignore // Reconciling errors occur if an ITD field is // referenced outside of the aspect that declares them, // but only if the declared type of the object is an interface. itds.remove(member); } else if (member.getElementType() == IJavaElement.METHOD) { // now look to see if this ITD a method that provides // a default implementation for an interface method // use IMethod.isSimilar if (childMethods == null) { childMethods = (List<IMethod>) type.getChildrenOfType(IJavaElement.METHOD); } for (IMethod method : childMethods) { if (method.isSimilar((IMethod) member)) { itds.remove(member); break; } } } } } } else if (ije instanceof DeclareElement) { DeclareElement elt = (DeclareElement) ije; // use createElementInfo, not getElementInfo because // we don't want it cached DeclareElementInfo info = (DeclareElementInfo) elt.createElementInfo(); if (info == null || info.getAJKind() != Kind.DECLARE_PARENTS) { continue; } char[][] newSupers = info.getTypes(); augmentHierarchy(newSupers); } else if (ije instanceof AspectElement || ije instanceof BinaryAspectElement) { // likely a declare parents instantiated in a concrete aspect, but declared in a super aspect IProgramElement ipe = model.javaElementToProgramElement(ije); Map<String, List<String>> declareParentsMap = ipe.getDeclareParentsMap(); if (declareParentsMap != null) { augmentHierarchy(declareParentsMap.get(type.getFullyQualifiedName())); } } else if (ije instanceof IType) { // an ITIT itds.add(new ITIT(type, (IType) ije, model.javaElementToProgramElement(ije))); } } return itds; } return new LinkedList<IJavaElement>(); }
From source file:org.evosuite.eclipse.popup.actions.ExtendSuiteAction.java
License:Open Source License
/** * Add a new test generation job to the job queue * /*from w w w.j a v a 2s .c om*/ * @param target */ @Override protected void addTestJob(final IResource target) { IJavaElement element = JavaCore.create(target); IJavaElement packageElement = element.getParent(); String packageName = packageElement.getElementName(); final String suiteClass = (!packageName.equals("") ? packageName + "." : "") + target.getName().replace(".java", "").replace(File.separator, "."); System.out.println("Building new job for " + suiteClass); DetermineSUT det = new DetermineSUT(); IJavaProject jProject = JavaCore.create(target.getProject()); try { String classPath = target.getWorkspace().getRoot().findMember(jProject.getOutputLocation()) .getLocation().toOSString(); String SUT = det.getSUTName(suiteClass, classPath); // choose SelectionDialog typeDialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), target.getProject(), IJavaElementSearchConstants.CONSIDER_CLASSES, false); Object[] sutDefault = new Object[1]; sutDefault[0] = SUT; typeDialog.setInitialSelections(sutDefault); typeDialog.setTitle("Please select the class under test"); typeDialog.open(); // Type selected by the user Object[] result = typeDialog.getResult(); if (result.length > 0) { SourceType sourceType = (SourceType) result[0]; SUT = sourceType.getFullyQualifiedName(); } else { return; } Job job = new TestExtensionJob(shell, target, SUT, suiteClass); job.setPriority(Job.SHORT); IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); ISchedulingRule rule = ruleFactory.createRule(target.getProject()); //IFolder folder = proj.getFolder(ResourceUtil.EVOSUITE_FILES); job.setRule(rule); job.setUser(true); job.schedule(); // start as soon as possible } catch (JavaModelException e) { e.printStackTrace(); } catch (NoJUnitClassException e) { MessageDialog.openError(shell, "Evosuite", "Cannot find JUnit tests in " + suiteClass); } }
From source file:org.hibernate.eclipse.jdt.ui.internal.jpa.collect.CollectEntityInfo.java
License:Open Source License
public boolean processFieldOrGetter(Type type, List<String> list, boolean fieldFlag) { if (type == null) { return false; }//from www .ja va 2 s .c om if (type.isPrimitiveType()) { PrimitiveType pt = (PrimitiveType) type; if (!pt.getPrimitiveTypeCode().equals(PrimitiveType.BOOLEAN)) { // this is candidate for primary id Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); if ("version".equalsIgnoreCase(name)) { //$NON-NLS-1$ FieldGetterType versionFieldGetter = updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag); entityInfo.setVersionFieldGetter(versionFieldGetter); } else { entityInfo.addPrimaryIdCandidate(name); } } } } else if (type.isSimpleType()) { SimpleType st = (SimpleType) type; ITypeBinding tb = st.resolveBinding(); if (tb != null) { String entityFullyQualifiedName = ""; //$NON-NLS-1$ if (tb.getJavaElement() instanceof SourceType) { SourceType sourceT = (SourceType) tb.getJavaElement(); entityFullyQualifiedName = sourceT.getFullyQualifiedName(); entityInfo.addDependency(entityFullyQualifiedName); RefType refType2Use = tb.isEnum() ? RefType.ENUMERATED : RefType.MANY2ONE; Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); entityInfo.addReference(name, entityFullyQualifiedName, refType2Use); } } else if (tb.getJavaElement() instanceof BinaryType) { ITypeBinding tbParent = tb.getTypeDeclaration().getSuperclass(); if (tbParent != null) { if ("java.lang.Number".equals(tbParent.getBinaryName())) { //$NON-NLS-1$ // this is candidate for primary id Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); if ("version".equalsIgnoreCase(name)) { //$NON-NLS-1$ FieldGetterType versionFieldGetter = updateFieldGetter( entityInfo.getVersionFieldGetter(), fieldFlag); entityInfo.setVersionFieldGetter(versionFieldGetter); } else { entityInfo.addPrimaryIdCandidate(name); } } } else if ("java.util.Date".equals(tbParent.getBinaryName())) { //$NON-NLS-1$ // this is candidate for version Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); if ("version".equalsIgnoreCase(name)) { //$NON-NLS-1$ FieldGetterType versionFieldGetter = updateFieldGetter( entityInfo.getVersionFieldGetter(), fieldFlag); entityInfo.setVersionFieldGetter(versionFieldGetter); } } } } if ("java.lang.String".equals(tb.getBinaryName())) { //$NON-NLS-1$ Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); entityInfo.updateAnnotationColumn(name, null, false); entityInfo.addPrimaryIdCandidate(name); } } } } } else if (type.isArrayType()) { ArrayType at = (ArrayType) type; Type componentType = at; while (componentType.isArrayType()) { componentType = ((ArrayType) componentType).getComponentType(); } ITypeBinding tb = componentType.resolveBinding(); if (tb != null) { if (tb.getJavaElement() instanceof SourceType) { String entityFullyQualifiedName = ""; //$NON-NLS-1$ SourceType sourceT = (SourceType) tb.getJavaElement(); try { entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName(); } catch (JavaModelException e) { HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e); //$NON-NLS-1$ } entityInfo.addDependency(entityFullyQualifiedName); Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY); } } } } else if (type.isParameterizedType()) { ParameterizedType pt = (ParameterizedType) type; Type typeP = pt.getType(); ITypeBinding tb = typeP.resolveBinding(); if (tb != null) { ITypeBinding[] interfaces = Utils.getAllInterfaces(tb); String fullyQualifiedNameTypeName = ""; //$NON-NLS-1$ if (Utils.isImplementInterface(interfaces, "java.util.Collection")) {//$NON-NLS-1$ fullyQualifiedNameTypeName = "java.util.Collection";//$NON-NLS-1$ } if (Utils.isImplementInterface(interfaces, "java.util.Map")) {//$NON-NLS-1$ fullyQualifiedNameTypeName = "java.util.Map";//$NON-NLS-1$ } /*for (int i = 0; i < interfaces.length; i++) { if (interfaces[i].getJavaElement() instanceof BinaryType) { BinaryType binaryT = (BinaryType)interfaces[i].getJavaElement(); String tmp = binaryT.getFullyQualifiedName('.'); if (0 == "java.util.Collection".compareTo(tmp)) { //$NON-NLS-1$ fullyQualifiedNameTypeName = tmp; break; } } }*/ if (fullyQualifiedNameTypeName.length() > 0) { Iterator<Type> typeArgsIt = pt.typeArguments().iterator(); while (typeArgsIt.hasNext()) { typeP = typeArgsIt.next(); tb = typeP.resolveBinding(); String entityFullyQualifiedName = ""; //$NON-NLS-1$ if (tb.getJavaElement() instanceof SourceType) { SourceType sourceT = (SourceType) tb.getJavaElement(); try { entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName(); } catch (JavaModelException e) { HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e); //$NON-NLS-1$ } entityInfo.addDependency(entityFullyQualifiedName); Iterator<String> itVarNames = list.iterator(); while (itVarNames.hasNext()) { String name = itVarNames.next(); entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY); } } } } } } else if (type.isQualifiedType()) { QualifiedType qt = (QualifiedType) type; @SuppressWarnings("unused") ITypeBinding tb = qt.resolveBinding(); } else if (type.isWildcardType()) { WildcardType wt = (WildcardType) type; @SuppressWarnings("unused") ITypeBinding tb = wt.resolveBinding(); } return true; }
From source file:org.wso2.developerstudio.eclipse.ui.widgets.FromWS.java
License:Open Source License
public void browseClassFile() { FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog( Display.getCurrent().getActiveShell(), true, PlatformUI.getWorkbench().getProgressService(), new JavaWorkspaceScope(), IJavaSearchConstants.CLASS); dialog.setTitle("Registry Handler Class"); dialog.setMessage("Select a java class to create the Registry Handler from"); if (dialog.open() == Window.OK) { SourceType firstResult = (SourceType) dialog.getFirstResult(); IJavaProject p = (IJavaProject) firstResult.getAncestor(2); pathText.setText(firstResult.getFullyQualifiedName()); }/*from w w w . j a v a 2s . c o m*/ }
From source file:sidecarviz.core.MonitorEclipse.java
License:BSD License
/** * @param sideCarJavaEditor/* ww w . j ava 2 s . c o m*/ * @param type */ public void gotEditingClass(SideCarJavaEditor sideCarJavaEditor, SourceType type) { // getElementName(); provides the shortname, like PaperUI, or main // we want the fully qualified name final String className = type.getFullyQualifiedName(); // DebugUtils.println("Editing Class: " + className); // add to hashmap javaEditorEditedClasses.put(className, type); // TODO: Forward to Flash }