Java Code Examples for org.eclipse.jdt.core.IJavaElementDelta#F_FINE_GRAINED

The following examples show how to use org.eclipse.jdt.core.IJavaElementDelta#F_FINE_GRAINED . 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: DeltaConverter.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @return a possibly empty list of converted deltas.
 */
public List<IResourceDescription.Delta> convert(IJavaElementDelta delta) {
	/*
	 * a file was opened or closed or there is no relevant structural change in the delta
	 * - we do not expect an IResourceDescription.Delta
	 * 
	 * Deltas without any affected children or without content changes
	 * are considered to be irrelevant
	 */
	if (delta.getFlags() == IJavaElementDelta.F_AST_AFFECTED
			|| delta.getFlags() == (IJavaElementDelta.F_AST_AFFECTED | IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) {
		return Collections.emptyList();
	}
	try {
		List<IResourceDescription.Delta> result = Lists.newArrayListWithExpectedSize(2);
		convertCompilationUnits(delta, result);
		return result;
	} catch (Throwable throwable) {
		if (throwable instanceof VirtualMachineError) {
			throw (VirtualMachineError) throwable;
		}
		if (LOGGER.isEnabledFor(Level.ERROR)) {
			LOGGER.error(throwable.getMessage(), throwable);
		}
		return Collections.emptyList();
	}
}
 
Example 2
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isPossibleStructuralChange(IJavaElementDelta cuDelta) {
	if (cuDelta.getKind() != IJavaElementDelta.CHANGED) {
		return true; // add or remove
	}
	int flags= cuDelta.getFlags();
	if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
		return true;
	}
	return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
}
 
Example 3
Source File: ElementChangedListener.java    From JDeodorant with MIT License 5 votes vote down vote up
private void processDelta(IJavaElementDelta delta) {
	IJavaElement javaElement = delta.getElement();
	switch(javaElement.getElementType()) {
	case IJavaElement.JAVA_MODEL:
	case IJavaElement.JAVA_PROJECT:
	case IJavaElement.PACKAGE_FRAGMENT_ROOT:
	case IJavaElement.PACKAGE_FRAGMENT:
		IJavaElementDelta[] affectedChildren = delta.getAffectedChildren();
		for(IJavaElementDelta affectedChild : affectedChildren) {
			processDelta(affectedChild);
		}
		break;
	case IJavaElement.COMPILATION_UNIT:
		ICompilationUnit compilationUnit = (ICompilationUnit)javaElement;
		if(delta.getKind() == IJavaElementDelta.ADDED) {
			CompilationUnitCache.getInstance().compilationUnitAdded(compilationUnit);
		}
		else if(delta.getKind() == IJavaElementDelta.REMOVED) {
			CompilationUnitCache.getInstance().compilationUnitRemoved(compilationUnit);
		}
		else if(delta.getKind() == IJavaElementDelta.CHANGED) {
			if((delta.getFlags() & IJavaElementDelta.F_FINE_GRAINED) != 0) {
				CompilationUnitCache.getInstance().compilationUnitChanged(compilationUnit);
			}
		}
	}
}
 
Example 4
Source File: OpenTypeHistory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isUnknownStructuralChange(int flags) {
	if ((flags & IJavaElementDelta.F_CONTENT) == 0)
		return false;
	return (flags & IJavaElementDelta.F_FINE_GRAINED) == 0;
}
 
Example 5
Source File: PackageExplorerContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static boolean isStructuralCUChange(int flags) {
	// No refresh on working copy creation (F_PRIMARY_WORKING_COPY)
	return (flags & IJavaElementDelta.F_CHILDREN) != 0 || (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
}
 
Example 6
Source File: JavaEditorBreadcrumb.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isStructuralChange(IJavaElementDelta delta) {
	if (delta.getKind() != IJavaElementDelta.CHANGED)
		return true;

	return (delta.getFlags() & IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED) == IJavaElementDelta.F_CONTENT;
}
 
Example 7
Source File: JavaEditorBreadcrumb.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean onlyChildrenChanged(IJavaElementDelta delta) {
	if (delta.getKind() != IJavaElementDelta.CHANGED)
		return false;

	return (delta.getFlags() & ~IJavaElementDelta.F_FINE_GRAINED) == IJavaElementDelta.F_CHILDREN;
}
 
Example 8
Source File: TypeHierarchyLifeCycle.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isPossibleStructuralChange(int flags) {
	return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
}
 
Example 9
Source File: InterfaceIndicatorLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void processDelta(IJavaElementDelta delta, List<IJavaElement> result) {
	IJavaElement elem= delta.getElement();

	boolean isChanged= delta.getKind() == IJavaElementDelta.CHANGED;
	boolean isRemoved= delta.getKind() == IJavaElementDelta.REMOVED;
	int flags= delta.getFlags();

	switch (elem.getElementType()) {
		case IJavaElement.JAVA_PROJECT:
			if (isRemoved || (isChanged &&
					(flags & IJavaElementDelta.F_CLOSED) != 0)) {
				return;
			}
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.PACKAGE_FRAGMENT_ROOT:
			if (isRemoved || (isChanged && (
					(flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 ||
					(flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0))) {
				return;
			}
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.PACKAGE_FRAGMENT:
			if (isRemoved)
				return;
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.TYPE:
		case IJavaElement.CLASS_FILE:
			return;
		case IJavaElement.JAVA_MODEL:
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.COMPILATION_UNIT:
			// Not the primary compilation unit. Ignore it
			if (!JavaModelUtil.isPrimary((ICompilationUnit) elem)) {
				return;
			}

			if (isChanged &&  ((flags & IJavaElementDelta.F_CONTENT) != 0 || (flags & IJavaElementDelta.F_FINE_GRAINED) != 0)) {
				if (delta.getAffectedChildren().length == 0)
					return;

				result.add(elem);
			}
			return;
		default:
			// fields, methods, imports ect
			return;
	}
}