Java Code Examples for org.eclipse.jdt.core.search.TypeNameMatch#getModifiers()

The following examples show how to use org.eclipse.jdt.core.search.TypeNameMatch#getModifiers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeInfoFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: JavaContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOfKind(TypeNameMatch curr, int typeKinds, boolean is50OrHigher) {
	int flags= curr.getModifiers();
	if (Flags.isAnnotation(flags)) {
		return is50OrHigher && ((typeKinds & SimilarElementsRequestor.ANNOTATIONS) != 0);
	}
	if (Flags.isEnum(flags)) {
		return is50OrHigher && ((typeKinds & SimilarElementsRequestor.ENUMS) != 0);
	}
	if (Flags.isInterface(flags)) {
		return (typeKinds & SimilarElementsRequestor.INTERFACES) != 0;
	}
	return (typeKinds & SimilarElementsRequestor.CLASSES) != 0;
}
 
Example 3
Source File: JavaContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isVisible(TypeNameMatch curr, ICompilationUnit cu) {
	int flags= curr.getModifiers();
	if (Flags.isPrivate(flags)) {
		return false;
	}
	if (Flags.isPublic(flags) || Flags.isProtected(flags)) {
		return true;
	}
	return curr.getPackageName().equals(cu.getParent().getElementName());
}
 
Example 4
Source File: OpenTypeHistory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: OrganizeImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOfKind(TypeNameMatch curr, int typeKinds, boolean is50OrHigher) {
	int flags= curr.getModifiers();
	if (Flags.isAnnotation(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ANNOTATIONS) != 0;
	}
	if (Flags.isEnum(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ENUMS) != 0;
	}
	if (Flags.isInterface(flags)) {
		return (typeKinds & SimilarElementsRequestor.INTERFACES) != 0;
	}
	return (typeKinds & SimilarElementsRequestor.CLASSES) != 0;
}
 
Example 6
Source File: OrganizeImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isVisible(TypeNameMatch curr) {
	int flags= curr.getModifiers();
	if (Flags.isPrivate(flags)) {
		return false;
	}
	if (Flags.isPublic(flags) || Flags.isProtected(flags)) {
		return true;
	}
	return curr.getPackageName().equals(fCurrPackage.getElementName());
}
 
Example 7
Source File: AddImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOfKind(TypeNameMatch curr, int typeKinds, boolean is50OrHigher) {
	int flags= curr.getModifiers();
	if (Flags.isAnnotation(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ANNOTATIONS) != 0;
	}
	if (Flags.isEnum(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ENUMS) != 0;
	}
	if (Flags.isInterface(flags)) {
		return (typeKinds & SimilarElementsRequestor.INTERFACES) != 0;
	}
	return (typeKinds & SimilarElementsRequestor.CLASSES) != 0;
}
 
Example 8
Source File: AddImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isVisible(TypeNameMatch curr) {
	int flags= curr.getModifiers();
	if (Flags.isPrivate(flags)) {
		return false;
	}
	if (Flags.isPublic(flags) || Flags.isProtected(flags)) {
		return true;
	}
	return curr.getPackageName().equals(fCompilationUnit.getParent().getElementName());
}
 
Example 9
Source File: TypeNameMatchLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static ImageDescriptor getImageDescriptor(TypeNameMatch typeRef, int flags) {
	if (isSet(SHOW_TYPE_CONTAINER_ONLY, flags)) {
		if (typeRef.getPackageName().equals(typeRef.getTypeContainerName()))
			return JavaPluginImages.DESC_OBJS_PACKAGE;

		// XXX cannot check outer type for interface efficiently (5887)
		return JavaPluginImages.DESC_OBJS_CLASS;

	} else if (isSet(SHOW_PACKAGE_ONLY, flags)) {
		return JavaPluginImages.DESC_OBJS_PACKAGE;
	} else {
		boolean isInner= typeRef.getTypeContainerName().indexOf('.') != -1;
		int modifiers= typeRef.getModifiers();

		ImageDescriptor desc= JavaElementImageProvider.getTypeImageDescriptor(isInner, false, modifiers, false);
		int adornmentFlags= 0;
		if (Flags.isFinal(modifiers)) {
			adornmentFlags |= JavaElementImageDescriptor.FINAL;
		}
		if (Flags.isAbstract(modifiers) && !Flags.isInterface(modifiers)) {
			adornmentFlags |= JavaElementImageDescriptor.ABSTRACT;
		}
		if (Flags.isStatic(modifiers)) {
			adornmentFlags |= JavaElementImageDescriptor.STATIC;
		}
		if (Flags.isDeprecated(modifiers)) {
			adornmentFlags |= JavaElementImageDescriptor.DEPRECATED;
		}

		return new JavaElementImageDescriptor(desc, adornmentFlags, JavaElementImageProvider.BIG_SIZE);
	}
}