本文整理汇总了Java中org.eclipse.jdt.core.search.TypeNameMatch类的典型用法代码示例。如果您正苦于以下问题:Java TypeNameMatch类的具体用法?Java TypeNameMatch怎么用?Java TypeNameMatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeNameMatch类属于org.eclipse.jdt.core.search包,在下文中一共展示了TypeNameMatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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];
}
开发者ID:de-jcup,项目名称:egradle,代码行数:30,代码来源:JDTDataAccess.java
示例2: isVisible
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private boolean isVisible(TypeNameMatch curr) {
int flags= curr.getModifiers();
if (Flags.isPrivate(flags)) {
return false;
}
boolean isPublic;
try {
isPublic= JdtFlags.isPublic(curr.getType());
} catch (JavaModelException e) {
isPublic= Flags.isPublic(flags);
}
if (isPublic || Flags.isProtected(flags)) {
return true;
}
return curr.getPackageName().equals(fCurrPackage.getElementName());
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:OrganizeImportsOperation.java
示例3: isFiltered
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
public static boolean isFiltered(TypeNameMatch match) {
boolean filteredByPattern = getDefault().filter(match.getFullyQualifiedName());
if (filteredByPattern) return true;
int accessibility = match.getAccessibility();
switch (accessibility) {
case IAccessRule.K_NON_ACCESSIBLE:
return JavaCore.ENABLED.equals(
JavaCore.getOption(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK));
case IAccessRule.K_DISCOURAGED:
return JavaCore.ENABLED.equals(
JavaCore.getOption(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK));
default:
return false;
}
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:TypeFilter.java
示例4: findTypeByFqn
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private List<IType> findTypeByFqn(char[][] packages, char[][] names, IJavaSearchScope scope)
throws JavaModelException {
List<IType> result = new ArrayList<>();
SearchEngine searchEngine = new SearchEngine();
searchEngine.searchAllTypeNames(
packages,
names,
scope,
new TypeNameMatchRequestor() {
@Override
public void acceptTypeNameMatch(TypeNameMatch typeNameMatch) {
result.add(typeNameMatch.getType());
}
},
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
new NullProgressMonitor());
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:JavaDebuggerUtils.java
示例5: 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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:TypeContextChecker.java
示例6: addSelectedInterfaces
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private void addSelectedInterfaces() {
StructuredSelection selection= getSelectedItems();
if (selection == null)
return;
for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
Object obj= iter.next();
if (obj instanceof TypeNameMatch) {
accessedHistoryItem(obj);
TypeNameMatch type= (TypeNameMatch) obj;
String qualifiedName= getNameWithTypeParameters(type.getType());
String message;
if (fTypeWizardPage.addSuperInterface(qualifiedName)) {
message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfaceadded_info, BasicElementLabels.getJavaElementName(qualifiedName));
} else {
message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfacealreadyadded_info, BasicElementLabels.getJavaElementName(qualifiedName));
}
updateStatus(new StatusInfo(IStatus.INFO, message));
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:SuperInterfaceSelectionDialog.java
示例7: getContainerName
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private String getContainerName(TypeNameMatch type) {
IPackageFragmentRoot root= type.getPackageFragmentRoot();
if (root.isExternal()) {
String name= root.getPath().toOSString();
for (int i= 0; i < fInstallLocations.length; i++) {
if (name.startsWith(fInstallLocations[i])) {
return fVMNames[i];
}
}
String lib= (String)fLib2Name.get(name);
if (lib != null)
return lib;
}
StringBuffer buf= new StringBuffer();
JavaElementLabels.getPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED | JavaElementLabels.ROOT_VARIABLE, buf);
return buf.toString();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:TypeInfoViewer.java
示例8: findAllTypes
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor) throws JavaModelException {
boolean is50OrHigher= JavaModelUtil.is50OrHigher(fCompilationUnit.getJavaProject());
int typeKinds= SimilarElementsRequestor.ALL_TYPES;
if (nameNode != null) {
typeKinds= ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher);
}
ArrayList<TypeNameMatch> typeInfos= new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor= new TypeNameMatchCollector(typeInfos);
int matchMode= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
new SearchEngine().searchAllTypeNames(null, matchMode, simpleTypeName.toCharArray(), matchMode, getSearchForConstant(typeKinds), searchScope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
ArrayList<TypeNameMatch> typeRefsFound= new ArrayList<TypeNameMatch>(typeInfos.size());
for (int i= 0, len= typeInfos.size(); i < len; i++) {
TypeNameMatch curr= typeInfos.get(i);
if (curr.getPackageName().length() > 0) { // do not suggest imports from the default package
if (isOfKind(curr, typeKinds, is50OrHigher) && isVisible(curr)) {
typeRefsFound.add(curr);
}
}
}
return typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:25,代码来源:AddImportsOperation.java
示例9: addDashLineAndUpdateLastHistoryEntry
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private void addDashLineAndUpdateLastHistoryEntry(int ticket, final TypeNameMatch next) {
syncExec(ticket, new Runnable() {
public void run() {
if (fNextElement > 0) {
TableItem item= fTable.getItem(fNextElement - 1);
String label= item.getText();
String newLabel= fLabelProvider.getText(null, (TypeNameMatch)item.getData(), next);
if (newLabel.length() != label.length())
item.setText(newLabel);
if (fLastSelection != null && fLastSelection.length > 0) {
TableItem last= fLastSelection[fLastSelection.length - 1];
if (last == item) {
fLastLabels[fLastLabels.length - 1]= newLabel;
}
}
}
fDashLineIndex= fNextElement;
addDashLine();
}
});
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:TypeInfoViewer.java
示例10: validateItem
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
@Override
protected IStatus validateItem(Object item) {
if (item == null)
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, "", null); //$NON-NLS-1$
if (fValidator != null) {
IType type= ((TypeNameMatch) item).getType();
if (!type.exists()) {
String qualifiedName= TypeNameMatchLabelProvider.getText((TypeNameMatch) item, TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED);
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_error_type_doesnot_exist, qualifiedName), null);
}
Object[] elements= { type };
return fValidator.validate(elements);
} else
return Status.OK_STATUS;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:FilteredTypesSelectionDialog.java
示例11: matchesModifiers
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private boolean matchesModifiers(TypeNameMatch type) {
if (fElementKind == IJavaSearchConstants.TYPE)
return true;
int modifiers= type.getModifiers() & TYPE_MODIFIERS;
switch (fElementKind) {
case IJavaSearchConstants.CLASS:
return modifiers == 0;
case IJavaSearchConstants.ANNOTATION_TYPE:
return Flags.isAnnotation(modifiers);
case IJavaSearchConstants.INTERFACE:
return modifiers == Flags.AccInterface;
case IJavaSearchConstants.ENUM:
return Flags.isEnum(modifiers);
case IJavaSearchConstants.CLASS_AND_INTERFACE:
return modifiers == 0 || modifiers == Flags.AccInterface;
case IJavaSearchConstants.CLASS_AND_ENUM:
return modifiers == 0 || Flags.isEnum(modifiers);
case IJavaSearchConstants.INTERFACE_AND_ANNOTATION:
return Flags.isInterface(modifiers);
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:TypeInfoFilter.java
示例12: findAllTypes
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor, ICompilationUnit cu) throws JavaModelException {
boolean is50OrHigher= JavaModelUtil.is50OrHigher(cu.getJavaProject());
int typeKinds= SimilarElementsRequestor.ALL_TYPES;
if (nameNode != null) {
typeKinds= ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher);
}
ArrayList<TypeNameMatch> typeInfos= new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor= new TypeNameMatchCollector(typeInfos);
new SearchEngine().searchAllTypeNames(null, 0, simpleTypeName.toCharArray(), SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, getSearchForConstant(typeKinds), searchScope, requestor, IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, monitor);
ArrayList<TypeNameMatch> typeRefsFound= new ArrayList<TypeNameMatch>(typeInfos.size());
for (int i= 0, len= typeInfos.size(); i < len; i++) {
TypeNameMatch curr= typeInfos.get(i);
if (curr.getPackageName().length() > 0) { // do not suggest imports from the default package
if (isOfKind(curr, typeKinds, is50OrHigher) && isVisible(curr, cu)) {
typeRefsFound.add(curr);
}
}
}
return typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:24,代码来源:JavaContext.java
示例13: internalRunVirtual
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private void internalRunVirtual(ProgressMonitor monitor) throws CoreException, InterruptedException {
if (monitor.isCanceled())
throw new OperationCanceledException();
fViewer.clear(fTicket);
TypeNameMatch[] matchingTypes= fHistory.getFilteredTypeInfos(fFilter);
fViewer.setHistoryResult(fTicket, matchingTypes);
if ((fMode & INDEX) == 0)
return;
Set filteredMatches= new HashSet(matchingTypes.length * 2);
for (int i= 0; i < matchingTypes.length; i++) {
filteredMatches.add(matchingTypes[i]);
}
TypeNameMatch[] result= getSearchResult(filteredMatches, monitor);
if (monitor.isCanceled())
throw new OperationCanceledException();
fViewer.setSearchResult(fTicket, result);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:23,代码来源:TypeInfoViewer.java
示例14: getSearchResult
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
@Override
protected TypeNameMatch[] getSearchResult(Set filteredHistory, ProgressMonitor monitor) throws CoreException {
List result= new ArrayList(2048);
for (int i= 0; i < fLastResult.length; i++) {
TypeNameMatch type= fLastResult[i];
if (filteredHistory.contains(type))
continue;
if (fFilter.matchesCachedResult(type))
result.add(type);
}
// we have to sort if the filter is a camel case filter.
TypeNameMatch[] types= (TypeNameMatch[])result.toArray(new TypeNameMatch[result.size()]);
if (fFilter.isCamelCasePattern()) {
Arrays.sort(types, new TypeInfoComparator(fLabelProvider, fFilter));
}
return types;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:TypeInfoViewer.java
示例15: setResult
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
@Override
protected void setResult(List newResult) {
List<IType> resultToReturn= new ArrayList<IType>();
for (int i= 0; i < newResult.size(); i++) {
if (newResult.get(i) instanceof TypeNameMatch) {
IType type= ((TypeNameMatch) newResult.get(i)).getType();
if (type.exists()) {
// items are added to history in the
// org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#computeResult()
// method
resultToReturn.add(type);
} else {
TypeNameMatch typeInfo= (TypeNameMatch) newResult.get(i);
IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED);
String message= Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_dialogMessage, new String[] { TypeNameMatchLabelProvider.getText(typeInfo, TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED), containerName });
MessageDialog.openError(getShell(), fTitle, message);
getSelectionHistory().remove(typeInfo);
}
}
}
super.setResult(resultToReturn);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:FilteredTypesSelectionDialog.java
示例16: getText
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
@Override
public String getText(Object element) {
if (!(element instanceof TypeNameMatch)) {
return super.getText(element);
}
TypeNameMatch typeMatch= (TypeNameMatch) element;
if (fContainerInfo && isDuplicateElement(element)) {
return BasicElementLabels.getJavaElementName(fTypeInfoUtil.getFullyQualifiedText(typeMatch));
}
if (!fContainerInfo && isDuplicateElement(element)) {
return BasicElementLabels.getJavaElementName(fTypeInfoUtil.getQualifiedText(typeMatch));
}
return BasicElementLabels.getJavaElementName(typeMatch.getSimpleTypeName());
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:FilteredTypesSelectionDialog.java
示例17: getContainerName
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private String getContainerName(TypeNameMatch type) {
IPackageFragmentRoot root= type.getPackageFragmentRoot();
if (root.isExternal()) {
String name= root.getPath().toOSString();
for (int i= 0; i < fInstallLocations.length; i++) {
if (name.startsWith(fInstallLocations[i])) {
return fVMNames[i];
}
}
String lib= fLib2Name.get(name);
if (lib != null)
return lib;
}
StringBuffer buf= new StringBuffer();
JavaElementLabels.getPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED | JavaElementLabels.ROOT_VARIABLE, buf);
return buf.toString();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:FilteredTypesSelectionDialog.java
示例18: setData
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
private void setData(TableItem item) {
int index= fTable.indexOf(item);
TypeNameMatch type= getTypeInfo(index);
if (type == DASH_LINE) {
item.setData(fDashLine);
fillDashLine(item);
} else {
item.setData(type);
item.setImage(fImageManager.get(fLabelProvider.getImageDescriptor(type)));
item.setText(fLabelProvider.getText(
getTypeInfo(index - 1),
type,
getTypeInfo(index + 1)));
item.setForeground(null);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:TypeInfoViewer.java
示例19: compare
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
public int compare(TypeNameMatch leftInfo, TypeNameMatch rightInfo) {
int result= compareName(leftInfo.getSimpleTypeName(), rightInfo.getSimpleTypeName());
if (result != 0)
return result;
result= compareDeprecation(leftInfo.getModifiers(), rightInfo.getModifiers());
if (result != 0)
return result;
result= compareTypeContainerName(leftInfo.getTypeContainerName(), rightInfo.getTypeContainerName());
if (result != 0)
return result;
int leftCategory= getElementTypeCategory(leftInfo);
int rightCategory= getElementTypeCategory(rightInfo);
if (leftCategory < rightCategory)
return -1;
if (leftCategory > rightCategory)
return +1;
return compareContainerName(leftInfo, rightInfo);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:FilteredTypesSelectionDialog.java
示例20: addInfo
import org.eclipse.jdt.core.search.TypeNameMatch; //导入依赖的package包/类
public void addInfo(TypeNameMatch info) {
for (int i= this.foundInfos.size() - 1; i >= 0; i--) {
TypeNameMatch curr= this.foundInfos.get(i);
if (curr.getTypeContainerName().equals(info.getTypeContainerName())) {
return; // not added. already contains type with same name
}
}
foundInfos.add(info);
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:10,代码来源:OrganizeImportsOperation.java
注:本文中的org.eclipse.jdt.core.search.TypeNameMatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论