1 11 package org.eclipse.jdt.internal.corext.refactoring.binary; 12 13 import java.net.URI ; 14 import java.util.List ; 15 16 import org.eclipse.core.filesystem.IFileStore; 17 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 import org.eclipse.core.runtime.SubProgressMonitor; 21 22 import org.eclipse.jdt.core.IClassFile; 23 import org.eclipse.jdt.core.IType; 24 25 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; 26 27 33 public class StubCreationOperation extends AbstractCodeCreationOperation { 34 35 36 protected final boolean fStubInvisible; 37 38 46 public StubCreationOperation(final URI uri, final List packages) { 47 this(uri, packages, false); 48 } 49 50 61 public StubCreationOperation(final URI uri, final List packages, final boolean stub) { 62 super(uri, packages); 63 fStubInvisible= stub; 64 } 65 66 69 protected String getOperationLabel() { 70 return RefactoringCoreMessages.StubCreationOperation_creating_type_stubs; 71 } 72 73 85 protected void run(final IClassFile file, final IFileStore parent, final IProgressMonitor monitor) throws CoreException { 86 try { 87 monitor.beginTask(RefactoringCoreMessages.StubCreationOperation_creating_type_stubs, 2); 88 SubProgressMonitor subProgressMonitor= new SubProgressMonitor(monitor, 1); 89 final IType type= file.getType(); 90 if (type.isAnonymous() || type.isLocal() || type.isMember()) 91 return; 92 String source= new StubCreator(fStubInvisible).createStub(type, subProgressMonitor); 93 createCompilationUnit(parent, type.getElementName() + ".java", source, monitor); } finally { 95 monitor.done(); 96 } 97 } 98 } 99 | Popular Tags |