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

The following examples show how to use org.eclipse.jdt.core.IJavaElementDelta#F_SOURCEDETACHED . 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: ClasspathChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addClasspathDeltas(JavaElementDelta delta, IPackageFragmentRoot[] roots, int flag) {
	for (int i = 0; i < roots.length; i++) {
		IPackageFragmentRoot root = roots[i];
		delta.changed(root, flag);
		if ((flag & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0
				|| (flag & IJavaElementDelta.F_SOURCEATTACHED) != 0
				|| (flag & IJavaElementDelta.F_SOURCEDETACHED) != 0){
			try {
				root.close();
			} catch (JavaModelException e) {
				// ignore
			}
		}
	}
}
 
Example 2
Source File: ClasspathChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int getSourceAttachmentDeltaFlag(IPath oldPath, IPath newPath) {
	if (oldPath == null) {
		if (newPath != null) {
			return IJavaElementDelta.F_SOURCEATTACHED;
		} else {
			return 0;
		}
	} else if (newPath == null) {
		return IJavaElementDelta.F_SOURCEDETACHED;
	} else if (!oldPath.equals(newPath)) {
		return IJavaElementDelta.F_SOURCEATTACHED | IJavaElementDelta.F_SOURCEDETACHED;
	} else {
		return 0;
	}
}
 
Example 3
Source File: JavaProjectClasspathChangeAnalyzer.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private boolean isAttachmentChangeFlagOnly(IJavaElementDelta child) {
	// change is sourceattached or sourcedetached or sourceattached and sourcedetached at the same time
	return child.getFlags() == IJavaElementDelta.F_SOURCEATTACHED
			 || child.getFlags() == IJavaElementDelta.F_SOURCEDETACHED
			|| child.getFlags() == IJavaElementDelta.F_SOURCEDETACHED + IJavaElementDelta.F_SOURCEATTACHED;
}
 
Example 4
Source File: ClassFileDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Recursively check whether the class file has been deleted.
 * 
 * @param input the package fragment root
 * @param delta the Java element delta
 * @return <code>true</code> if delta processing can be stopped
 */
protected boolean check(IPackageFragmentRoot input, IJavaElementDelta delta) {
	IJavaElement element= delta.getElement();

	if ((delta.getKind() & IJavaElementDelta.REMOVED) != 0 || (delta.getFlags() & IJavaElementDelta.F_CLOSED) != 0) {
		// http://dev.eclipse.org/bugs/show_bug.cgi?id=19023
		if (element.equals(input.getJavaProject()) || element.equals(input)) {
			handleDeleted(fInput);
			return true;
		}
	}

	if (((delta.getFlags() & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) && input.equals(element)) {
		handleDeleted(fInput);
		return true;
	}

	if (((delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) && input.equals(element)) {
		handleDeleted(fInput);
		return true;
	}

	IJavaElementDelta[] subdeltas= delta.getAffectedChildren();
	for (int i= 0; i < subdeltas.length; i++) {
		if (check(input, subdeltas[i]))
			return true;
	}

	if ((delta.getFlags() & IJavaElementDelta.F_SOURCEDETACHED) != 0 ||
		(delta.getFlags() & IJavaElementDelta.F_SOURCEATTACHED) != 0)
	{
		IClassFile file= fInput != null ? fInput.getClassFile() : null;
		IJavaProject project= input != null ? input.getJavaProject() : null;

		boolean isOnClasspath= false;
		if (file != null && project != null)
			isOnClasspath= project.isOnClasspath(file);

		if (isOnClasspath) {
			fireInputChanged(fInput);
			return false;
		} else {
			handleDeleted(fInput);
			return true;
		}
	}

	return false;
}