use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class SurroundWithTryCatchRefactoring method createChange.
/* non Java-doc
* @see IRefactoring#createChange(IProgressMonitor)
*/
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
//$NON-NLS-1$
final String NN = "";
if (pm == null)
pm = new NullProgressMonitor();
pm.beginTask(NN, 2);
try {
final CompilationUnitChange result = new CompilationUnitChange(getName(), fCUnit);
if (fLeaveDirty)
result.setSaveMode(TextFileChange.LEAVE_DIRTY);
MultiTextEdit root = new MultiTextEdit();
result.setEdit(root);
fRewriter = ASTRewrite.create(fAnalyzer.getEnclosingBodyDeclaration().getAST());
fRewriter.setTargetSourceRangeComputer(new SelectionAwareSourceRangeComputer(fAnalyzer.getSelectedNodes(), fCUnit.getBuffer(), fSelection.getOffset(), fSelection.getLength()));
fImportRewrite = StubUtility.createImportRewrite(fRootNode, true);
fLinkedProposalModel = new LinkedProposalModel();
fScope = CodeScopeBuilder.perform(fAnalyzer.getEnclosingBodyDeclaration(), fSelection).findScope(fSelection.getOffset(), fSelection.getLength());
fScope.setCursor(fSelection.getOffset());
fSelectedNodes = fAnalyzer.getSelectedNodes();
createTryCatchStatement(fCUnit.getBuffer(), fCUnit.findRecommendedLineSeparator());
if (fImportRewrite.hasRecordedChanges()) {
TextEdit edit = fImportRewrite.rewriteImports(null);
root.addChild(edit);
result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] { edit }));
}
TextEdit change = fRewriter.rewriteAST();
root.addChild(change);
result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] { change }));
return result;
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class OverrideCompletionProposal method getRecoveredAST.
private CompilationUnit getRecoveredAST(IDocument document, int offset, Document recoveredDocument) {
CompilationUnit ast = SharedASTProvider.getAST(fCompilationUnit, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
if (ast != null) {
recoveredDocument.set(document.get());
return ast;
}
char[] content = document.get().toCharArray();
// clear prefix to avoid compile errors
int index = offset - 1;
while (index >= 0 && Character.isJavaIdentifierPart(content[index])) {
content[index] = ' ';
index--;
}
recoveredDocument.set(new String(content));
final CheASTParser parser = CheASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setSource(content);
parser.setUnitName(fCompilationUnit.getElementName());
parser.setProject(fCompilationUnit.getJavaProject());
return (CompilationUnit) parser.createAST(new NullProgressMonitor());
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class ClasspathUpdaterService method updateClasspath.
/**
* Updates the information about classpath.
*
* @param projectPath
* path to the current project
* @param entries
* list of classpath entries which need to set
* @throws JavaModelException
* if JavaModel has a failure
* @throws ServerException
* if some server error
* @throws ForbiddenException
* if operation is forbidden
* @throws ConflictException
* if update operation causes conflicts
* @throws NotFoundException
* if Project with specified path doesn't exist in workspace
* @throws IOException
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void updateClasspath(@QueryParam("projectpath") String projectPath, List<ClasspathEntryDto> entries) throws JavaModelException, ServerException, ForbiddenException, ConflictException, NotFoundException, IOException {
IJavaProject javaProject = model.getJavaProject(projectPath);
javaProject.setRawClasspath(createModifiedEntry(entries), javaProject.getOutputLocation(), new NullProgressMonitor());
updateProjectConfig(projectPath);
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class IntroduceIndirectionRefactoring method setIntermediaryTypeName.
/**
* @param fullyQualifiedTypeName the fully qualified name of the intermediary method
* @return status for type name. Use {@link #setIntermediaryMethodName(String)} to check for overridden methods.
*/
public RefactoringStatus setIntermediaryTypeName(String fullyQualifiedTypeName) {
IType target = null;
try {
if (fullyQualifiedTypeName.length() == 0)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.IntroduceIndirectionRefactoring_type_not_selected_error);
// find type (now including secondaries)
target = getProject().findType(fullyQualifiedTypeName, new NullProgressMonitor());
if (target == null || !target.exists())
return RefactoringStatus.createErrorStatus(Messages.format(RefactoringCoreMessages.IntroduceIndirectionRefactoring_type_does_not_exist_error, BasicElementLabels.getJavaElementName(fullyQualifiedTypeName)));
if (target.isAnnotation())
return RefactoringStatus.createErrorStatus(RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_in_annotation);
if (target.isInterface() && !(JavaModelUtil.is18OrHigher(target.getJavaProject()) && JavaModelUtil.is18OrHigher(getProject())))
return RefactoringStatus.createErrorStatus(RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_on_interface);
} catch (JavaModelException e) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.IntroduceIndirectionRefactoring_unable_determine_declaring_type);
}
if (target.isReadOnly())
return RefactoringStatus.createErrorStatus(RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_in_readonly);
if (target.isBinary())
return RefactoringStatus.createErrorStatus(RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_in_binary);
fIntermediaryType = target;
return new RefactoringStatus();
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class UndoDocumentChange method isValid.
/**
* {@inheritDoc}
*/
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
if (pm == null)
pm = new NullProgressMonitor();
//$NON-NLS-1$
pm.beginTask("", 1);
RefactoringStatus result = TextChanges.isValid(fDocument, fLength);
pm.worked(1);
return result;
}
Aggregations