<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; public class DiscardWorkingCopyOperation extends JavaModelOperation { public DiscardWorkingCopyOperation ( IJavaElement workingCopy ) { super ( new IJavaElement [ ] { workingCopy } ) ; } protected void executeOperation ( ) throws JavaModelException { CompilationUnit workingCopy = getWorkingCopy ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; int useCount = manager . discardPerWorkingCopyInfo ( workingCopy ) ; if ( useCount == 0 ) { IJavaProject javaProject = workingCopy . getJavaProject ( ) ; if ( ExternalJavaProject . EXTERNAL_PROJECT_NAME . equals ( javaProject . getElementName ( ) ) ) { manager . removePerProjectInfo ( ( JavaProject ) javaProject , true ) ; manager . containerRemove ( javaProject ) ; } if ( ! workingCopy . isPrimary ( ) ) { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . removed ( workingCopy ) ; addDelta ( delta ) ; removeReconcileDelta ( workingCopy ) ; } else { if ( workingCopy . getResource ( ) . isAccessible ( ) ) { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . changed ( workingCopy , IJavaElementDelta . F_PRIMARY_WORKING_COPY ) ; addDelta ( delta ) ; } else { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . removed ( workingCopy , IJavaElementDelta . F_PRIMARY_WORKING_COPY ) ; addDelta ( delta ) ; } } } } protected CompilationUnit getWorkingCopy ( ) { return ( CompilationUnit ) getElementToProcess ( ) ; } public boolean isReadOnly ( ) { return true ; } } </s>