org.eclipse.core.runtime.SubProgressMonitor Java Examples
The following examples show how to use
org.eclipse.core.runtime.SubProgressMonitor.
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: RecipeHelper.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public static void processFile ( final IContainer parent, final Definition definition, final Profile profile, final IProgressMonitor monitor ) throws Exception { monitor.beginTask ( makeJobLabel ( definition, profile ), 100 ); final IFolder output = parent.getFolder ( new Path ( "output" ) ); //$NON-NLS-1$ if ( output.exists () ) { output.delete ( true, new SubProgressMonitor ( monitor, 9 ) ); } output.create ( true, true, new SubProgressMonitor ( monitor, 1 ) ); final Builder builder = new Builder ( definition, profile ); final Recipe recipe = builder.build (); try { final Map<String, Object> initialContent = new HashMap<String, Object> (); initialContent.put ( "output", output ); //$NON-NLS-1$ recipe.execute ( initialContent, new SubProgressMonitor ( monitor, 90 ) ); } finally { monitor.done (); } }
Example #2
Source File: SVNProjectSetCapability.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Creates a new project in the workbench from an existing one * * @param monitor * @throws CoreException */ void createExistingProject(IProgressMonitor monitor) throws CoreException { String projectName = project.getName(); IProjectDescription description; try { monitor.beginTask("Creating " + projectName, 2 * 1000); description = ResourcesPlugin.getWorkspace() .loadProjectDescription( new Path(directory + File.separatorChar + ".project")); //$NON-NLS-1$ description.setName(projectName); project.create(description, new SubProgressMonitor(monitor, 1000)); project.open(new SubProgressMonitor(monitor, 1000)); } finally { monitor.done(); } }
Example #3
Source File: InlineMethodRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
Example #4
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (fgFirstTime) { // Join the initialize after load job. IJobManager manager= Job.getJobManager(); manager.join(JavaUI.ID_PLUGIN, monitor); } OpenTypeHistory history= OpenTypeHistory.getInstance(); if (fgFirstTime || history.isEmpty()) { if (history.needConsistencyCheck()) { monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); refreshSearchIndices(new SubProgressMonitor(monitor, 90)); history.checkConsistency(new SubProgressMonitor(monitor, 10)); } else { refreshSearchIndices(monitor); } monitor.done(); fgFirstTime= false; } else { history.checkConsistency(monitor); } }
Example #5
Source File: PyReferenceSearcher.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Searches for references to the identifier in the request. * * <p>{@link #prepareSearch(RefactoringRequest)} must be called before * {@link #search(RefactoringRequest)} or else results are undefined. * * @param request the search request * @throws SearchException if an exception occurs in the process of finding references. * @throws OperationCanceledException if the request is canceled. */ public void search(RefactoringRequest request) throws SearchException, OperationCanceledException { for (IRefactorRenameProcess p : requestToProcesses.get(request)) { request.checkCancelled(); p.clear(); // Clear references found from a previous invocation RefactoringStatus status = new RefactoringStatus(); request.pushMonitor(new SubProgressMonitor(request.getMonitor(), 1)); try { p.findReferencesToRename(request, status); } finally { request.popMonitor().done(); } if (status.hasFatalError()) { throw new SearchException(status.getEntryWithHighestSeverity().getMessage()); } } }
Example #6
Source File: TmxLargeFileDataAccess.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 删除重复文本段 删除重复的TU,原文和译文相同。删除时如果TU中只有2个TUV,则直接删除TU;如果TU中有超过2个TUV则只删除当前TUV 保留最新的TUV * @return ; */ public boolean deleteDupaicate(IProgressMonitor monitor, boolean ignoreTag, boolean ignoreCase) { monitor.beginTask("", 100); SubProgressMonitor subFilerJob = new SubProgressMonitor(monitor, 40); subFilerJob.setTaskName(Messages.getString("core.fileAccess.filterDupliacteSegment")); TmxFilterQueryUtil filterQuery = new TmxFilterQueryUtil(container, super.currSrcLang, super.currTgtLang); filterQuery.setIngoreTag(ignoreTag); filterQuery.setIgnoreCase(ignoreCase); List<String> filterResultList = filterQuery.getDuplicate4DeleteIds(subFilerJob); subFilerJob.done(); if (filterResultList.size() == 0) { return false; } SubProgressMonitor subDeleteJob = new SubProgressMonitor(monitor, 60); subDeleteJob.setTaskName(Messages.getString("core.fileAccess.deleteDuplicateSegment")); deleteTus(filterResultList.toArray(new String[] {}), subDeleteJob); subDeleteJob.done(); return true; }
Example #7
Source File: InferTypeArgumentsConstraintsSolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void chooseTypes(ConstraintVariable2[] allConstraintVariables, SubProgressMonitor pm) { pm.beginTask("", allConstraintVariables.length); //$NON-NLS-1$ for (int i= 0; i < allConstraintVariables.length; i++) { ConstraintVariable2 cv= allConstraintVariables[i]; TypeEquivalenceSet set= cv.getTypeEquivalenceSet(); if (set == null) continue; //TODO: should not happen iff all unused constraint variables got pruned //TODO: should calculate only once per EquivalenceRepresentative; can throw away estimate TypeSet afterwards TType type= chooseSingleType((TypeSet) cv.getTypeEstimate()); //TODO: is null for Universe TypeSet setChosenType(cv, type); if (cv instanceof CollectionElementVariable2) { CollectionElementVariable2 elementCv= (CollectionElementVariable2) cv; fUpdate.addDeclaration(elementCv); } pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } pm.done(); }
Example #8
Source File: ExtractTempRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { try { pm.beginTask("", 6); //$NON-NLS-1$ RefactoringStatus result= Checks.validateModifiesFiles(ResourceUtil.getFiles(new ICompilationUnit[] { fCu}), getValidationContext()); if (result.hasFatalError()) return result; if (fCompilationUnitNode == null) { fCompilationUnitNode= RefactoringASTParser.parseWithASTProvider(fCu, true, new SubProgressMonitor(pm, 3)); } else { pm.worked(3); } result.merge(checkSelection(new SubProgressMonitor(pm, 3))); if (!result.hasFatalError() && isLiteralNodeSelected()) fReplaceAllOccurrences= false; return result; } finally { pm.done(); } }
Example #9
Source File: EclipseGitProgressTransformer.java From orion.server with Eclipse Public License 1.0 | 6 votes |
@Override public void beginTask(final String name, final int total) { endTask(); msg = name; lastWorked = 0; totalWork = total; task = new SubProgressMonitor(root, 1000); if (totalWork == UNKNOWN) task.beginTask(EMPTY_STRING, IProgressMonitor.UNKNOWN); else task.beginTask(EMPTY_STRING, totalWork); task.subTask(msg); if (job != null) { job.setTaskTotal(total); job.setTaskMessage(msg); } }
Example #10
Source File: RenamePackageProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private List<SearchResultGroup> getReferencesToTypesInPackage(IProgressMonitor pm, ReferencesInBinaryContext binaryRefs, RefactoringStatus status) throws CoreException { pm.beginTask("", 2); //$NON-NLS-1$ IJavaSearchScope referencedFromNamesakesScope= RefactoringScopeFactory.create(fPackage, true, false); IPackageFragment[] namesakePackages= getNamesakePackages(referencedFromNamesakesScope, new SubProgressMonitor(pm, 1)); if (namesakePackages.length == 0) { pm.done(); return new ArrayList<SearchResultGroup>(0); } IJavaSearchScope scope= SearchEngine.createJavaSearchScope(namesakePackages); IType[] typesToSearch= getTypesInPackage(fPackage); if (typesToSearch.length == 0) { pm.done(); return new ArrayList<SearchResultGroup>(0); } SearchPattern pattern= RefactoringSearchEngine.createOrPattern(typesToSearch, IJavaSearchConstants.REFERENCES); CollectingSearchRequestor requestor= new CuCollectingSearchRequestor(binaryRefs); SearchResultGroup[] results= RefactoringSearchEngine.search(pattern, scope, requestor, new SubProgressMonitor(pm, 1), status); pm.done(); return new ArrayList<SearchResultGroup>(Arrays.asList(results)); }
Example #11
Source File: ExtractTempRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { try { pm.beginTask("", 6); //$NON-NLS-1$ RefactoringStatus result = Checks.validateModifiesFiles(ResourceUtil.getFiles(new ICompilationUnit[] { fCu }), getValidationContext(), pm); if (result.hasFatalError()) { return result; } if (fCompilationUnitNode == null) { fCompilationUnitNode = RefactoringASTParser.parseWithASTProvider(fCu, true, new SubProgressMonitor(pm, 3)); } else { pm.worked(3); } result.merge(checkSelection(new SubProgressMonitor(pm, 3))); if (!result.hasFatalError() && isLiteralNodeSelected()) { fReplaceAllOccurrences = false; } return result; } finally { pm.done(); } }
Example #12
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addMethodStubForAbstractMethod(final IMethod sourceMethod, final CompilationUnit declaringCuNode, final AbstractTypeDeclaration typeToCreateStubIn, final ICompilationUnit newCu, final CompilationUnitRewrite rewriter, final Map<IMember, IncomingMemberVisibilityAdjustment> adjustments, final IProgressMonitor monitor, final RefactoringStatus status) throws CoreException { final MethodDeclaration methodToCreateStubFor= ASTNodeSearchUtil.getMethodDeclarationNode(sourceMethod, declaringCuNode); final AST ast= rewriter.getRoot().getAST(); final MethodDeclaration newMethod= ast.newMethodDeclaration(); newMethod.setBody(createMethodStub(methodToCreateStubFor, ast)); newMethod.setConstructor(false); copyExtraDimensions(methodToCreateStubFor, newMethod); newMethod.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getModifiersWithUpdatedVisibility(sourceMethod, JdtFlags.clearFlag(Modifier.NATIVE | Modifier.ABSTRACT, methodToCreateStubFor.getModifiers()), adjustments, new SubProgressMonitor(monitor, 1), false, status))); newMethod.setName(((SimpleName) ASTNode.copySubtree(ast, methodToCreateStubFor.getName()))); final TypeVariableMaplet[] mapping= TypeVariableUtil.composeMappings(TypeVariableUtil.subTypeToSuperType(getDeclaringType(), getDestinationType()), TypeVariableUtil.superTypeToInheritedType(getDestinationType(), ((IType) typeToCreateStubIn.resolveBinding().getJavaElement()))); copyReturnType(rewriter.getASTRewrite(), getDeclaringType().getCompilationUnit(), methodToCreateStubFor, newMethod, mapping); copyParameters(rewriter.getASTRewrite(), getDeclaringType().getCompilationUnit(), methodToCreateStubFor, newMethod, mapping); copyThrownExceptions(methodToCreateStubFor, newMethod); newMethod.setJavadoc(createJavadocForStub(typeToCreateStubIn.getName().getIdentifier(), methodToCreateStubFor, newMethod, newCu, rewriter.getASTRewrite())); ImportRewriteContext context= new ContextSensitiveImportRewriteContext(typeToCreateStubIn, rewriter.getImportRewrite()); ImportRewriteUtil.addImports(rewriter, context, newMethod, new HashMap<Name, String>(), new HashMap<Name, String>(), false); rewriter.getASTRewrite().getListRewrite(typeToCreateStubIn, typeToCreateStubIn.getBodyDeclarationsProperty()).insertAt(newMethod, ASTNodes.getInsertionIndex(newMethod, typeToCreateStubIn.bodyDeclarations()), rewriter.createCategorizedGroupDescription(RefactoringCoreMessages.PullUpRefactoring_add_method_stub, SET_PULL_UP)); }
Example #13
Source File: ReplaceInvocationsRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
Example #14
Source File: FindStringsToExternalizeAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private List<NonNLSElement> analyze(IPackageFragmentRoot sourceFolder, IProgressMonitor pm) throws CoreException { try{ IJavaElement[] children= sourceFolder.getChildren(); pm.beginTask("", children.length); //$NON-NLS-1$ pm.setTaskName(JavaElementLabels.getElementLabel(sourceFolder, JavaElementLabels.ALL_DEFAULT)); List<NonNLSElement> result= new ArrayList<NonNLSElement>(); for (int i= 0; i < children.length; i++) { IJavaElement iJavaElement= children[i]; if (iJavaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT){ IPackageFragment pack= (IPackageFragment)iJavaElement; if (! pack.isReadOnly()) result.addAll(analyze(pack, new SubProgressMonitor(pm, 1))); else pm.worked(1); } else pm.worked(1); } return result; } finally{ pm.done(); } }
Example #15
Source File: SuperTypeRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Computes the compilation units referencing the subtype to replace. * * @param type * the subtype * @param monitor * the progress monitor to use * @param status * the refactoring status * @return the referenced compilation units (element type: * <code><IJavaProject, Collection<SearchResultGroup>></code>) * @throws JavaModelException * if an error occurs */ protected final Map<IJavaProject, Set<SearchResultGroup>> getReferencingCompilationUnits(final IType type, final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException { try { monitor.beginTask("", 100); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.SuperTypeRefactoringProcessor_creating); final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(); engine.setOwner(fOwner); engine.setFiltering(true, true); engine.setStatus(status); engine.setScope(RefactoringScopeFactory.create(type)); engine.setPattern(SearchPattern.createPattern(type, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE)); engine.searchPattern(new SubProgressMonitor(monitor, 100)); @SuppressWarnings("unchecked") Map<IJavaProject, Set<SearchResultGroup>> result= (Map<IJavaProject, Set<SearchResultGroup>>) engine.getAffectedProjects(); return result; } finally { monitor.done(); } }
Example #16
Source File: MoveInnerToTopRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addImportsToTargetUnit(final ICompilationUnit targetUnit, final IProgressMonitor monitor) throws CoreException, JavaModelException { monitor.beginTask("", 2); //$NON-NLS-1$ try { ImportRewrite rewrite= StubUtility.createImportRewrite(targetUnit, true); if (fTypeImports != null) { ITypeBinding type= null; for (final Iterator<ITypeBinding> iterator= fTypeImports.iterator(); iterator.hasNext();) { type= iterator.next(); rewrite.addImport(type); } } if (fStaticImports != null) { IBinding binding= null; for (final Iterator<IBinding> iterator= fStaticImports.iterator(); iterator.hasNext();) { binding= iterator.next(); rewrite.addStaticImport(binding); } } fTypeImports= null; fStaticImports= null; TextEdit edits= rewrite.rewriteImports(new SubProgressMonitor(monitor, 1)); JavaModelUtil.applyEdit(targetUnit, edits, false, new SubProgressMonitor(monitor, 1)); } finally { monitor.done(); } }
Example #17
Source File: XlsxRowReader.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void readRows(IProgressMonitor monitor) throws ParserConfigurationException, SAXException, IOException, OpenXML4JException { monitor.beginTask("", 10); monitor.worked(1); OPCPackage p = OPCPackage.open(xlsxFile, PackageAccess.READ); ReadOnlySharedStringsTable shareString = new ReadOnlySharedStringsTable(p); XSSFReader xssfReader = new XSSFReader(p); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); try { while (iter.hasNext()) { InputStream stream = iter.next(); readCells(stream, shareString, new SubProgressMonitor(monitor, 9)); stream.close(); // 目前只处理第一个sheet break; } } finally { p.close(); monitor.done(); } }
Example #18
Source File: Builder.java From cppcheclipse with Apache License 2.0 | 6 votes |
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); // ignore all parent elements (projects, folders) if (resource instanceof IFile) { switch (delta.getKind()) { case IResourceDelta.ADDED: // handle added resource processResource(resource, new SubProgressMonitor(monitor, 1)); break; case IResourceDelta.REMOVED: // resources are not available any more and therefore the // markers were automatically removed break; case IResourceDelta.CHANGED: // handle changed resource processResource(resource, new SubProgressMonitor(monitor, 1)); break; } } // return true to continue visiting children. return true; }
Example #19
Source File: RenameTypeParameterProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 5); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_checking); status.merge(Checks.checkIfCuBroken(fTypeParameter.getDeclaringMember())); monitor.worked(1); if (!status.hasFatalError()) { status.merge(checkNewElementName(getNewElementName())); monitor.worked(1); monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_searching); status.merge(createRenameChanges(new SubProgressMonitor(monitor, 2))); monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_checking); if (status.hasFatalError()) { return status; } monitor.worked(1); } } finally { monitor.done(); } return status; }
Example #20
Source File: FindStringsToExternalizeAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private List<NonNLSElement> analyze(IJavaProject project, IProgressMonitor pm) throws CoreException { try{ IPackageFragment[] packs= project.getPackageFragments(); pm.beginTask("", packs.length); //$NON-NLS-1$ List<NonNLSElement> result= new ArrayList<NonNLSElement>(); for (int i= 0; i < packs.length; i++) { if (! packs[i].isReadOnly()) result.addAll(analyze(packs[i], new SubProgressMonitor(pm, 1))); else pm.worked(1); } return result; } finally{ pm.done(); } }
Example #21
Source File: ExtractTempRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException { try { pm.beginTask(RefactoringCoreMessages.ExtractTempRefactoring_checking_preconditions, 4); fCURewrite= new CompilationUnitRewrite(fCu, fCompilationUnitNode); fCURewrite.getASTRewrite().setTargetSourceRangeComputer(new NoCommentSourceRangeComputer()); doCreateChange(new SubProgressMonitor(pm, 2)); fChange= fCURewrite.createChange(RefactoringCoreMessages.ExtractTempRefactoring_change_name, true, new SubProgressMonitor(pm, 1)); RefactoringStatus result= new RefactoringStatus(); if (Arrays.asList(getExcludedVariableNames()).contains(fTempName)) result.addWarning(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_another_variable, BasicElementLabels.getJavaElementName(fTempName))); result.merge(checkMatchingFragments()); fChange.setKeepPreviewEdits(true); if (fCheckResultForCompileProblems) { checkNewSource(new SubProgressMonitor(pm, 1), result); } return result; } finally { pm.done(); } }
Example #22
Source File: RefactoringExecutionHelper.java From typescript.java with MIT License | 5 votes |
@Override public void run(IProgressMonitor pm) throws CoreException { try { pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$ pm.subTask(""); //$NON-NLS-1$ final RefactoringStatus status= fRefactoring.checkAllConditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); if (status.getSeverity() >= fStopSeverity) { final boolean[] canceled= { false }; if (fForked) { fParent.getDisplay().syncExec(new Runnable() { @Override public void run() { canceled[0]= showStatusDialog(status); } }); } else { canceled[0]= showStatusDialog(status); } if (canceled[0]) { throw new OperationCanceledException(); } } fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); fPerformChangeOperation= new PerformChangeOperation(fChange);//RefactoringUI.createUIAwareChangeOperation(fChange); fPerformChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName()); if (fRefactoring instanceof IScheduledRefactoring) fPerformChangeOperation.setSchedulingRule(((IScheduledRefactoring)fRefactoring).getSchedulingRule()); if (!fForked || fForkChangeExecution) fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } finally { pm.done(); } }
Example #23
Source File: RenamePackageChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void doRename(IProgressMonitor pm) throws CoreException { IPackageFragment pack= getPackage(); if (pack == null) return; if (!fRenameSubpackages) { renamePackage(pack, pm, createNewPath(), getNewName()); } else { IPackageFragment[] allPackages= JavaElementUtil.getPackageAndSubpackages(pack); Arrays.sort(allPackages, new Comparator<IPackageFragment>() { public int compare(IPackageFragment o1, IPackageFragment o2) { String p1= o1.getElementName(); String p2= o2.getElementName(); return p1.compareTo(p2); } }); int count= allPackages.length; pm.beginTask("", count); //$NON-NLS-1$ // When renaming to subpackage (a -> a.b), do it inside-out: boolean insideOut= getNewName().startsWith(getOldName()); try { for (int i= 0; i < count; i++) { IPackageFragment currentPackage= allPackages[insideOut ? count - i - 1 : i]; renamePackage(currentPackage, new SubProgressMonitor(pm, 1), createNewPath(currentPackage), getNewName(currentPackage)); } } finally { pm.done(); } } }
Example #24
Source File: RenamePackageProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private List<SearchResultGroup> getReferencesToTypesInNamesakes(IProgressMonitor pm, RefactoringStatus status) throws CoreException { pm.beginTask("", 2); //$NON-NLS-1$ // e.g. renaming B-p.p; project C requires B, X and has ref to B-p.p and X-p.p; // goal: find refs to X-p.p in CUs from fOccurrences // (1) find namesake packages (scope: all packages referenced by CUs in fOccurrences and fPackage) IJavaElement[] elements= new IJavaElement[fOccurrences.length + 1]; for (int i= 0; i < fOccurrences.length; i++) { elements[i]= fOccurrences[i].getCompilationUnit(); } elements[fOccurrences.length]= fPackage; IJavaSearchScope namesakePackagesScope= RefactoringScopeFactory.createReferencedScope(elements); IPackageFragment[] namesakePackages= getNamesakePackages(namesakePackagesScope, new SubProgressMonitor(pm, 1)); if (namesakePackages.length == 0) { pm.done(); return new ArrayList<>(0); } // (2) find refs in fOccurrences and fPackage to namesake packages // (from fOccurrences (without namesakes): may have shared star import) // (from fPackage: may have unimported references to types of namesake packages) IType[] typesToSearch= getTypesInPackages(namesakePackages); if (typesToSearch.length == 0) { pm.done(); return new ArrayList<>(0); } SearchPattern pattern= RefactoringSearchEngine.createOrPattern(typesToSearch, IJavaSearchConstants.REFERENCES); IJavaSearchScope scope= getPackageAndOccurrencesWithoutNamesakesScope(); SearchResultGroup[] results= RefactoringSearchEngine.search(pattern, scope, new SubProgressMonitor(pm, 1), status); pm.done(); return new ArrayList<>(Arrays.asList(results)); }
Example #25
Source File: DocumentPart.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public void reverseConvert() throws Exception { // 处理的单元为 w:p String xpath = "/w:document/w:body/descendant::w:p"; int allPSum = getNodeCount(xpath); initWorkInterval(allPSum); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 12, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); subMonitor.beginTask("", allPSum % workInterval == 0 ? (allPSum / workInterval) : (allPSum / workInterval) + 1); subMonitor.setTaskName(Messages.getString("xlf2Docx.task5")); ap.selectXPath(xpath); int traverPIdx = 0; while(ap.evalXPath() != -1){ traverPIdx ++; analysisReversePnode(); monitorWork(subMonitor, traverPIdx, false); } xm.output(partPath); monitorWork(subMonitor, traverPIdx, true); subMonitor.done(); //再处理可翻译属性 xpath = "/w:document/w:body/descendant::w:p/w:r/w:pict/v:shape/@alt"; reverseTranslateAttributes(xpath); monitor.worked(1); if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("docxConvert.task3")); } }
Example #26
Source File: ExtractConstantRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException { pm.beginTask(RefactoringCoreMessages.ExtractConstantRefactoring_checking_preconditions, 2); /* Note: some checks are performed on change of input widget * values. (e.g. see ExtractConstantRefactoring.checkConstantNameOnChange()) */ //TODO: possibly add more checking for name conflicts that might // lead to a change in behavior try { RefactoringStatus result = new RefactoringStatus(); createConstantDeclaration(); replaceExpressionsWithConstant(); fChange = fCuRewrite.createChange(RefactoringCoreMessages.ExtractConstantRefactoring_change_name, true, new SubProgressMonitor(pm, 1)); if (fCheckResultForCompileProblems) { checkSource(new SubProgressMonitor(pm, 1), result); } return result; } finally { fConstantTypeCache = null; fCuRewrite.clearASTAndImportRewrites(); pm.done(); } }
Example #27
Source File: CompilationUnitReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask(getName(), 1); try { ICompilationUnit unit= getCu(); ResourceMapping mapping= JavaElementResourceMapping.create(unit); Change result= doPerformReorg(new SubProgressMonitor(pm, 1)); markAsExecuted(unit, mapping); return result; } finally { pm.done(); } }
Example #28
Source File: InferTypeArgumentsConstraintsSolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void runSolver(SubProgressMonitor pm) { pm.beginTask("", fWorkList.size() * 3); //$NON-NLS-1$ while (! fWorkList.isEmpty()) { // Get a variable whose type estimate has changed ConstraintVariable2 cv= fWorkList.removeFirst(); List<ITypeConstraint2> usedIn= fTCModel.getUsedIn(cv); processConstraints(usedIn); pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } pm.done(); }
Example #29
Source File: ExtractTempRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void checkNewSource(SubProgressMonitor monitor, RefactoringStatus result) throws CoreException { String newCuSource = fChange.getPreviewContent(new NullProgressMonitor()); CompilationUnit newCUNode = new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(newCuSource, fCu, true, true, monitor); IProblem[] newProblems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fCompilationUnitNode); for (int i = 0; i < newProblems.length; i++) { IProblem problem = newProblems[i]; if (problem.isError()) { result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem)))); } } }
Example #30
Source File: BinaryRefactoringHistoryWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Deconfigures the classpath of the project after refactoring. * * @param monitor * the progress monitor to use * @throws CoreException * if an error occurs while deconfiguring the classpath */ private void deconfigureClasspath(final IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(JarImportMessages.JarImportWizard_cleanup_import, 300); if (fJavaProject != null) { final IClasspathEntry[] entries= fJavaProject.readRawClasspath(); final boolean changed= deconfigureClasspath(entries, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); final RefactoringHistory history= getRefactoringHistory(); final boolean valid= history != null && !history.isEmpty(); if (valid) RefactoringCore.getUndoManager().flush(); if (valid || changed) fJavaProject.setRawClasspath(entries, changed, new SubProgressMonitor(monitor, 60, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); } if (fSourceFolder != null) { final IFileStore store= EFS.getStore(fSourceFolder.getRawLocationURI()); if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists()) store.delete(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); fSourceFolder.delete(true, false, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); fSourceFolder.clearHistory(new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); fSourceFolder= null; } if (fJavaProject != null) { try { fJavaProject.getResource().refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); } catch (CoreException exception) { JavaPlugin.log(exception); } } } finally { fJavaProject= null; monitor.done(); } }