本文整理汇总了Java中org.eclipse.jdt.core.search.TypeNameMatch.getType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeNameMatch.getType方法的具体用法?Java TypeNameMatch.getType怎么用?Java TypeNameMatch.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.search.TypeNameMatch
的用法示例。
在下文中一共展示了TypeNameMatch.getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findType
import org.eclipse.jdt.core.search.TypeNameMatch; //导入方法依赖的package包/类
/**
* Find type
*
* @param className
* @param monitor
* @return type or <code>null</code>
*/
public IType findType(String className, IProgressMonitor monitor) {
final IType[] result = { null };
TypeNameMatchRequestor nameMatchRequestor = new TypeNameMatchRequestor() {
@Override
public void acceptTypeNameMatch(TypeNameMatch match) {
result[0] = match.getType();
}
};
int lastDot = className.lastIndexOf('.');
char[] packageName = lastDot >= 0 ? className.substring(0, lastDot).toCharArray() : null;
char[] typeName = (lastDot >= 0 ? className.substring(lastDot + 1) : className).toCharArray();
SearchEngine engine = new SearchEngine();
int packageMatchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
try {
engine.searchAllTypeNames(packageName, packageMatchRule, typeName, packageMatchRule, IJavaSearchConstants.TYPE,
SearchEngine.createWorkspaceScope(), nameMatchRequestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
} catch (JavaModelException e) {
EditorUtil.INSTANCE.logError("Was not able to search all type names",e);
}
return result[0];
}
示例2: findTypeInfos
import org.eclipse.jdt.core.search.TypeNameMatch; //导入方法依赖的package包/类
private static List<TypeNameMatch> findTypeInfos(String typeName, IType contextType, IProgressMonitor pm) throws JavaModelException {
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaProject[]{contextType.getJavaProject()}, true);
IPackageFragment currPackage= contextType.getPackageFragment();
ArrayList<TypeNameMatch> collectedInfos= new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor= new TypeNameMatchCollector(collectedInfos);
int matchMode= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
new SearchEngine().searchAllTypeNames(null, matchMode, typeName.toCharArray(), matchMode, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, pm);
List<TypeNameMatch> result= new ArrayList<TypeNameMatch>();
for (Iterator<TypeNameMatch> iter= collectedInfos.iterator(); iter.hasNext();) {
TypeNameMatch curr= iter.next();
IType type= curr.getType();
if (type != null) {
boolean visible=true;
try {
visible= JavaModelUtil.isVisible(type, currPackage);
} catch (JavaModelException e) {
//Assume visibile if not available
}
if (visible) {
result.add(curr);
}
}
}
return result;
}
示例3: findTypeInfos
import org.eclipse.jdt.core.search.TypeNameMatch; //导入方法依赖的package包/类
private static List<TypeNameMatch> findTypeInfos(
String typeName, IType contextType, IProgressMonitor pm) throws JavaModelException {
IJavaSearchScope scope =
SearchEngine.createJavaSearchScope(
new IJavaProject[] {contextType.getJavaProject()}, true);
IPackageFragment currPackage = contextType.getPackageFragment();
ArrayList<TypeNameMatch> collectedInfos = new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor = new TypeNameMatchCollector(collectedInfos);
int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
new SearchEngine()
.searchAllTypeNames(
null,
matchMode,
typeName.toCharArray(),
matchMode,
IJavaSearchConstants.TYPE,
scope,
requestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
pm);
List<TypeNameMatch> result = new ArrayList<TypeNameMatch>();
for (Iterator<TypeNameMatch> iter = collectedInfos.iterator(); iter.hasNext(); ) {
TypeNameMatch curr = iter.next();
IType type = curr.getType();
if (type != null) {
boolean visible = true;
try {
visible = JavaModelUtil.isVisible(type, currPackage);
} catch (JavaModelException e) {
// Assume visibile if not available
}
if (visible) {
result.add(curr);
}
}
}
return result;
}
示例4: computeResult
import org.eclipse.jdt.core.search.TypeNameMatch; //导入方法依赖的package包/类
@Override
protected void computeResult() {
TypeNameMatch[] selected= fContent.getSelection();
if (selected == null || selected.length == 0) {
setResult(null);
return;
}
// If the scope is null then it got computed by the type selection component.
if (fScope == null) {
fScope= fContent.getScope();
}
OpenTypeHistory history= OpenTypeHistory.getInstance();
List result= new ArrayList(selected.length);
for (int i= 0; i < selected.length; i++) {
TypeNameMatch typeInfo= selected[i];
IType type= typeInfo.getType();
if (!type.exists()) {
String title= JavaUIMessages.TypeSelectionDialog_errorTitle;
IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED);
String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName });
MessageDialog.openError(getShell(), title, message);
history.remove(typeInfo);
setResult(null);
} else {
history.accessed(typeInfo);
result.add(type);
}
}
setResult(result);
}
示例5: internalCheckConsistency
import org.eclipse.jdt.core.search.TypeNameMatch; //导入方法依赖的package包/类
private synchronized void internalCheckConsistency(IProgressMonitor monitor) throws OperationCanceledException {
// Setting fNeedsConsistencyCheck is necessary here since
// markAsInconsistent isn't synchronized.
fNeedsConsistencyCheck= true;
List<Object> typesToCheck= new ArrayList<Object>(getKeys());
monitor.beginTask(CorextMessages.TypeInfoHistory_consistency_check, typesToCheck.size());
monitor.setTaskName(CorextMessages.TypeInfoHistory_consistency_check);
for (Iterator<Object> iter= typesToCheck.iterator(); iter.hasNext();) {
TypeNameMatch type= (TypeNameMatch)iter.next();
long currentTimestamp= getContainerTimestamp(type);
Long lastTested= fTimestampMapping.get(type);
if (lastTested != null && currentTimestamp != IResource.NULL_STAMP && currentTimestamp == lastTested.longValue() && !isContainerDirty(type))
continue;
try {
IType jType= type.getType();
if (jType == null || !jType.exists()) {
remove(type);
} else {
// copy over the modifiers since they may have changed
int modifiers= jType.getFlags();
if (modifiers != type.getModifiers()) {
replace(type, SearchEngine.createTypeNameMatch(jType, modifiers));
} else {
fTimestampMapping.put(type, new Long(currentTimestamp));
}
}
} catch (JavaModelException e) {
remove(type);
}
if (monitor.isCanceled())
throw new OperationCanceledException();
monitor.worked(1);
}
monitor.done();
fNeedsConsistencyCheck= false;
}
示例6: getFixImportProposals
import org.eclipse.jdt.core.search.TypeNameMatch; //导入方法依赖的package包/类
@Override
public ClasspathFixProposal[] getFixImportProposals(final IJavaProject project, String name) throws CoreException
{
IProject requestedProject = project.getProject();
if( !requestedProject.hasNature(JPFProjectNature.NATURE_ID) )
{
return null;
}
ArrayList<ClasspathFixProposal> props = new ArrayList<ClasspathFixProposal>();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
int idx = name.lastIndexOf('.');
char[] packageName = idx != -1 ? name.substring(0, idx).toCharArray() : null;
char[] typeName = name.substring(idx + 1).toCharArray();
if( typeName.length == 1 && typeName[0] == '*' )
{
typeName = null;
}
ArrayList<TypeNameMatch> res = new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor = new TypeNameMatchCollector(res);
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
new SearchEngine().searchAllTypeNames(packageName, matchMode, typeName, matchMode, IJavaSearchConstants.TYPE,
scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
if( res.isEmpty() )
{
return null;
}
JPFPluginModelManager service = JPFPluginModelManager.instance();
for( TypeNameMatch curr : res )
{
IType type = curr.getType();
if( type != null )
{
IPackageFragmentRoot root = (IPackageFragmentRoot) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
IPluginModel model = null;
if( root.isArchive() )
{
model = service.findModel((IFile) root.getResource());
}
else if( !root.isExternal() )
{
model = service.findModel(root.getResource().getProject());
}
if( model != null )
{
System.err.println("Found in " + model.getParsedManifest().getId());
props.add(new JPFClasspathFixProposal(project, JPFProject.getManifest(requestedProject), model));
}
}
}
return props.toArray(new ClasspathFixProposal[props.size()]);
}