本文整理匯總了Java中org.eclipse.jdt.core.IType類的典型用法代碼示例。如果您正苦於以下問題:Java IType類的具體用法?Java IType怎麽用?Java IType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IType類屬於org.eclipse.jdt.core包,在下文中一共展示了IType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getITypeMainByWorkspaceScope
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* search the bundle that contains the Main class. The search is done in the
* workspace scope (ie. if it is defined in the current workspace it will
* find it
*
* @return the name of the bundle containing the Main class or null if not
* found
*/
private IType getITypeMainByWorkspaceScope(String className) {
SearchPattern pattern = SearchPattern.createPattern(className, IJavaSearchConstants.CLASS,
IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
final List<IType> binaryType = new ArrayList<IType>();
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
binaryType.add((IType) match.getElement());
}
};
SearchEngine engine = new SearchEngine();
try {
engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope,
requestor, null);
} catch (CoreException e1) {
throw new RuntimeException("Error while searching the bundle: " + e1.getMessage());
// return new Status(IStatus.ERROR, Activator.PLUGIN_ID, );
}
return binaryType.isEmpty() ? null : binaryType.get(0);
}
示例2: findPathInGeneratedAnnotation
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* @param project
* @param itype
* @return
* @throws JavaModelException
*/
private static IPath findPathInGeneratedAnnotation(IProject project, IType itype) throws JavaModelException {
ICompilationUnit cu = itype.getCompilationUnit();
List<IAnnotationBinding> annotations = resolveAnnotation(cu, Generated.class).getAnnotations();
if ((annotations != null) && (annotations.size() > 0)) {
IAnnotationBinding ab = annotations.get(0);
IMemberValuePairBinding[] attributes = ab.getAllMemberValuePairs();
for (int i = 0; i < attributes.length; i++) {
IMemberValuePairBinding attribut = attributes[i];
if (attribut.getName().equalsIgnoreCase("value")) {
Object[] o = (Object[]) attribut.getValue();
if (o != null && o.length > 0 && String.valueOf(o[0]).trim().length() > 0) {
try {
IPath p = ResourceManager.find(project, String.valueOf(o[0]).trim());
return p;
} catch (Exception e) {
ResourceManager.logException(e);
return null;
}
}
}
}
}
return null;
}
示例3: findPathInModelAnnotation
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* @param project
* @param itype
* @return
* @throws JavaModelException
*/
public static IPath findPathInModelAnnotation(IProject project, IType itype) throws JavaModelException {
ICompilationUnit cu = itype.getCompilationUnit();
List<IAnnotationBinding> annotations = resolveAnnotation(cu, Model.class).getAnnotations();
if ((annotations != null) && (annotations.size() > 0)) {
IAnnotationBinding ab = annotations.get(0);
IMemberValuePairBinding[] attributes = ab.getAllMemberValuePairs();
for (int i = 0; i < attributes.length; i++) {
IMemberValuePairBinding attribut = attributes[i];
if (attribut.getName().equalsIgnoreCase("value")) {
Object[] o = (Object[]) attribut.getValue();
if (o != null && o.length > 0 && String.valueOf(o[0]).trim().length() > 0) {
try {
IPath p = ResourceManager.find(project, String.valueOf(o[0]).trim());
return p;
} catch (Exception e) {
ResourceManager.logException(e);
return null;
}
}
}
}
}
return null;
}
示例4: getClassesWithAnnotation
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
private static IType getClassesWithAnnotation(ICompilationUnit compilationUnit, Class annotationClass,
String attributName, boolean valued) throws JavaModelException {
List<IAnnotationBinding> annotations = resolveAnnotation(compilationUnit, annotationClass).getAnnotations();
if ((annotations != null) && (annotations.size() > 0)) {
IAnnotationBinding ab = annotations.get(0);
IMemberValuePairBinding[] attributes = ab.getAllMemberValuePairs();
for (int i = 0; i < attributes.length; i++) {
IMemberValuePairBinding attribut = attributes[i];
if (attribut.getName().equalsIgnoreCase(attributName)) {
if (valued) {
if (String.valueOf(attribut.getValue()).trim().length() > 0) {
return compilationUnit.findPrimaryType();
}
} else {
if (String.valueOf(attribut.getValue()).trim().length() == 0) {
return compilationUnit.findPrimaryType();
}
}
}
}
}
return null;
}
示例5: findClassesWithAnnotation
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* @param projectName
* @return
* @throws JavaModelException
*/
private static List<IType> findClassesWithAnnotation(String projectName, Class annotationClass, String attributName,
boolean valued) throws JavaModelException {
List<IType> classList = new ArrayList<IType>();
IProject project = ResourceManager.getProject(projectName);
IJavaProject javaProject = JavaCore.create(project);
IPackageFragment[] packages = javaProject.getPackageFragments();
for (IPackageFragment packageFragment : packages) {
for (final ICompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {
if (compilationUnit.exists()) {
IType type = getClassesWithAnnotation(compilationUnit, annotationClass, attributName, valued);
if (type != null)
classList.add(type);
}
}
}
return classList;
}
示例6: isGraphWalkerExecutionContextClass
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* @param testInterface
* @return
* @throws JavaModelException
*/
public static boolean isGraphWalkerExecutionContextClass(ICompilationUnit unit) throws JavaModelException {
IType[] types = unit.getAllTypes();
if (types == null || types.length == 0) {
ResourceManager.logInfo(unit.getJavaProject().getProject().getName(),
"getAllTypes return null" + unit.getPath());
return false;
}
IType execContextType = unit.getJavaProject().findType(ExecutionContext.class.getName());
for (int i = 0; i < types.length; i++) {
IType type = types[i];
String typeNname = type.getFullyQualifiedName();
String compilationUnitName = JDTManager.getJavaFullyQualifiedName(unit);
if (typeNname.equals(compilationUnitName)) {
try {
ITypeHierarchy th = types[0].newTypeHierarchy(new NullProgressMonitor());
return th.contains(execContextType);
} catch (Exception e) {
ResourceManager.logException(e);
}
}
}
return false;
}
示例7: getOrphanGraphWalkerClasses
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* @param projectName
* @return
*/
public static List<IType> getOrphanGraphWalkerClasses(IType type, boolean hint) {
try {
IProject project = ResourceManager.getResource(type.getPath().toString()).getProject();
String projectName = project.getName();
List<IType> all = findClassesWithAnnotation(projectName, GraphWalker.class, "value", true);
if (hint) {
all = GraphWalkerFacade.getSharedContexts(project, type, all);
all.remove(type);
}
Collections.sort(all, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
IType type1 = (IType) o1;
IType type2 = (IType) o2;
return type1.getFullyQualifiedName().compareTo(type2.getFullyQualifiedName());
}
});
return all;
} catch (Exception e) {
ResourceManager.logException(e);
return new ArrayList<IType>();
}
}
示例8: containsMethod
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
public static boolean containsMethod (String path, String[] requiredMethods) throws JavaModelException {
IResource resource = ResourceManager.getResource(path);
IFile file = (IFile) resource;
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
IType[] types = cu.getAllTypes();
List<String> list = new ArrayList<String>();
for (int i = 0; i < types.length; i++) {
IMethod[] methods = types[i].getMethods();
for (int j = 0; j < methods.length; j++) {
list.add(methods[j].getElementName());
}
}
for (int i = 0; i < requiredMethods.length; i++) {
String method = requiredMethods[i];
if (!list.contains(method)) return false;
}
return true;
}
示例9: ClassDetails
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
public ClassDetails(IClassFile classFile, String jarFileName, String packageName, boolean isUserDefined) {
LOGGER.debug("Extracting methods from "+classFile.getElementName());
try {
this.javaDoc=getJavaDoc(classFile);
intialize(classFile,jarFileName,packageName, isUserDefined);
for (IJavaElement iJavaElement : classFile.getChildren()) {
if (iJavaElement instanceof IType) {
IType iType = (IType) iJavaElement;
for (IMethod iMethod : iType.getMethods()) {
addMethodsToClass(iMethod);
}
}
}
} catch (JavaModelException e) {
LOGGER.error("Error occurred while fetching methods from class"+cName);
}
}
示例10: openInbuiltOperationClass
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
private void openInbuiltOperationClass(String operationName, PropertyDialogButtonBar propertyDialogButtonBar) {
String operationClassName = null;
Operations operations = XMLConfigUtil.INSTANCE.getComponent(FilterOperationClassUtility.INSTANCE.getComponentName())
.getOperations();
List<TypeInfo> typeInfos = operations.getStdOperation();
for (int i = 0; i < typeInfos.size(); i++) {
if (typeInfos.get(i).getName().equalsIgnoreCase(operationName)) {
operationClassName = typeInfos.get(i).getClazz();
break;
}
}
propertyDialogButtonBar.enableApplyButton(true);
javaProject = FilterOperationClassUtility.getIJavaProject();
if (javaProject != null) {
try {
IType findType = javaProject.findType(operationClassName);
JavaUI.openInEditor(findType);
} catch (JavaModelException | PartInitException e) {
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,Messages.CLASS_NOT_EXIST,null);
StatusManager.getManager().handle(status, StatusManager.BLOCK);
logger.error(e.getMessage(), e);
}
} else {
WidgetUtility.errorMessage(Messages.SAVE_JOB_MESSAGE);
}
}
示例11: createServiceFile
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* Parse un fichier candidat de service métier.
*
* @param document Document du service métier.
* @param javaProject Projet Java du service.
* @return Le service, <code>null</code> sinon.
*/
private ServiceFile createServiceFile(IFile file, IJavaProject javaProject) {
/* Charge l'AST du fichier Java. */
ICompilationUnit compilationUnit = JdtUtils.getCompilationUnit(file, javaProject);
if (compilationUnit == null) {
return null;
}
List<ServiceImplementation> serviceImplementations = new ArrayList<>();
try {
/* Parcourt les types du fichier Java. */
for (IType type : compilationUnit.getAllTypes()) {
handleType(type, file, serviceImplementations);
}
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
/* Créé le fichier de service. */
return new ServiceFile(serviceImplementations);
}
示例12: handleType
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
private void handleType(IType type, IFile file, List<ServiceImplementation> serviceImplementations) throws JavaModelException {
/* Parcourt les méthodes. */
for (IMethod method : type.getMethods()) {
/* Filtre pour ne garder que les méthodes publiques d'instance */
if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
continue;
}
/* Créé le ServiceImplementation. */
String javaName = method.getElementName();
ISourceRange nameRange = method.getNameRange();
FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
ServiceImplementation serviceImplementation = new ServiceImplementation(fileRegion, javaName);
serviceImplementations.add(serviceImplementation);
}
}
示例13: createWsFile
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* Parse un fichier candidat de webservice.
*
* @param file Fichier du webservice.
* @param javaProject Projet Java du fichier.
* @return Le webservice, <code>null</code> sinon.
*/
private WsFile createWsFile(IFile file, IJavaProject javaProject) {
/* Charge l'AST du fichier Java. */
ICompilationUnit compilationUnit = JdtUtils.getCompilationUnit(file, javaProject);
if (compilationUnit == null) {
return null;
}
List<WsRoute> wsRoutes = new ArrayList<>();
try {
/* Parcourt les types du fichier Java. */
for (IType type : compilationUnit.getAllTypes()) {
handleType(type, file, wsRoutes);
}
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
/* Créé le fichier de webservice. */
return new WsFile(file, wsRoutes);
}
示例14: createDaoFile
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
/**
* Parse un fichier candidat de DAO/PAO.
*
* @param file Fichier.
* @param javaProject Projet Java du fichier.
* @return Le DAO, <code>null</code> sinon.
*/
private DaoFile createDaoFile(IFile file, IJavaProject javaProject) {
/* Charge l'AST du fichier Java. */
ICompilationUnit compilationUnit = JdtUtils.getCompilationUnit(file, javaProject);
if (compilationUnit == null) {
return null;
}
List<DaoImplementation> daoImplementations = new ArrayList<>();
try {
/* Parcourt les types du fichier Java. */
for (IType type : compilationUnit.getAllTypes()) {
handleType(type, file, daoImplementations);
}
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
/* Créé le fichier de DAO/PAO. */
String daoName = StringUtils.removeExtension(compilationUnit.getElementName());
return new DaoFile(daoName, file, daoImplementations);
}
示例15: handleType
import org.eclipse.jdt.core.IType; //導入依賴的package包/類
private void handleType(IType type, IFile file, List<DaoImplementation> daoImplementations) throws JavaModelException {
/* Parcourt les méthodes. */
for (IMethod method : type.getMethods()) {
/* Filtre pour ne garder que les méthodes publiques d'instance */
if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
continue;
}
/* Créé le DaoImplementation. */
String javaName = method.getElementName();
ISourceRange nameRange = method.getNameRange();
FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
DaoImplementation daoImplementation = new DaoImplementation(fileRegion, javaName);
daoImplementations.add(daoImplementation);
}
}