use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class TypeContextChecker method resolveSuperClass.
public static ITypeBinding resolveSuperClass(String superclass, IType typeHandle, StubTypeContext superClassContext) {
StringBuffer cuString = new StringBuffer();
cuString.append(superClassContext.getBeforeString());
cuString.append(superclass);
cuString.append(superClassContext.getAfterString());
try {
ICompilationUnit wc = typeHandle.getCompilationUnit().getWorkingCopy(new WorkingCopyOwner() {
}, new NullProgressMonitor());
try {
wc.getBuffer().setContents(cuString.toString());
CompilationUnit compilationUnit = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(wc, true);
ASTNode type = NodeFinder.perform(compilationUnit, superClassContext.getBeforeString().length(), superclass.length());
if (type instanceof Type) {
return handleBug84585(((Type) type).resolveBinding());
} else if (type instanceof Name) {
ASTNode parent = type.getParent();
if (parent instanceof Type)
return handleBug84585(((Type) parent).resolveBinding());
}
throw new IllegalStateException();
} finally {
wc.discardWorkingCopy();
}
} catch (JavaModelException e) {
return null;
}
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RefactoringSearchEngine2 method searchReferencedMethods.
/**
* Performs the search of referenced methods.
*
* @param element the java element whose referenced methods have to be found
* @param monitor the progress monitor, or <code>null</code>
* @throws JavaModelException if an error occurs during search
*/
public final void searchReferencedMethods(final IJavaElement element, IProgressMonitor monitor) throws JavaModelException {
Assert.isNotNull(element);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
//$NON-NLS-1$
monitor.beginTask("", 1);
monitor.setTaskName(RefactoringCoreMessages.RefactoringSearchEngine_searching_referenced_methods);
try {
SearchEngine engine = null;
if (fOwner != null)
engine = new SearchEngine(fOwner);
else
engine = new SearchEngine(fWorkingCopies);
engine.searchDeclarationsOfSentMessages(element, getCollector(), new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
} catch (CoreException exception) {
throw new JavaModelException(exception);
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class QualifiedNameFinder method process.
public static void process(QualifiedNameSearchResult result, String pattern, String newValue, String filePatterns, IProject root, IProgressMonitor monitor) {
Assert.isNotNull(pattern);
Assert.isNotNull(newValue);
Assert.isNotNull(root);
if (monitor == null)
monitor = new NullProgressMonitor();
if (filePatterns == null || filePatterns.length() == 0) {
// Eat progress.
//$NON-NLS-1$
monitor.beginTask("", 1);
monitor.worked(1);
return;
}
ResultCollector collector = new ResultCollector(result, newValue);
TextSearchEngine engine = TextSearchEngine.create();
Pattern searchPattern = PatternConstructor.createPattern(pattern, true, false);
engine.search(createScope(filePatterns, root), collector, searchPattern, monitor);
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RefactoringFileBuffers method release.
/**
* Releases the text file buffer associated with the compilation unit.
*
* @param unit the compilation unit whose text file buffer has to be released
* @throws CoreException if the buffer could not be successfully released
*/
public static void release(final ICompilationUnit unit) throws CoreException {
Assert.isNotNull(unit);
final IResource resource = unit.getResource();
if (resource != null && resource.getType() == IResource.FILE)
FileBuffers.getTextFileBufferManager().disconnect(resource.getFullPath(), LocationKind.IFILE, new NullProgressMonitor());
}
use of org.eclipse.core.runtime.NullProgressMonitor in project che by eclipse.
the class RefactoringFileBuffers method acquire.
/**
* Connects to and acquires a text file buffer for the specified compilation unit.
* <p>
* All text file buffers acquired by a call to {@link RefactoringFileBuffers#acquire(ICompilationUnit)}
* must be released using {@link RefactoringFileBuffers#release(ICompilationUnit)}.
* </p>
*
* @param unit the compilation unit to acquire a text file buffer for
* @return the text file buffer, or <code>null</code> if no buffer could be acquired
* @throws CoreException if no buffer could be acquired
*/
public static ITextFileBuffer acquire(final ICompilationUnit unit) throws CoreException {
Assert.isNotNull(unit);
final IResource resource = unit.getResource();
if (resource != null && resource.getType() == IResource.FILE) {
final IPath path = resource.getFullPath();
FileBuffers.getTextFileBufferManager().connect(path, LocationKind.IFILE, new NullProgressMonitor());
return FileBuffers.getTextFileBufferManager().getTextFileBuffer(path, LocationKind.IFILE);
}
return null;
}
Aggregations