本文整理汇总了Java中org.eclipse.jdt.core.WorkingCopyOwner类的典型用法代码示例。如果您正苦于以下问题:Java WorkingCopyOwner类的具体用法?Java WorkingCopyOwner怎么用?Java WorkingCopyOwner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkingCopyOwner类属于org.eclipse.jdt.core包,在下文中一共展示了WorkingCopyOwner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCachedHierarchy
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private ITypeHierarchy getCachedHierarchy(IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
IType rep = fUnionFind.find(type);
if (rep != null) {
Collection<IType> collection = fRootReps.get(rep);
for (Iterator<IType> iter = collection.iterator(); iter.hasNext();) {
IType root = iter.next();
ITypeHierarchy hierarchy = fRootHierarchies.get(root);
if (hierarchy == null) {
hierarchy = root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1));
fRootHierarchies.put(root, hierarchy);
}
if (hierarchy.contains(type)) {
return hierarchy;
}
}
}
return null;
}
示例2: findAllDeclarations
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException {
fDeclarations = new ArrayList<>();
class MethodRequestor extends SearchRequestor {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IMethod method = (IMethod) match.getElement();
boolean isBinary = method.isBinary();
if (!isBinary) {
fDeclarations.add(method);
}
}
}
int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE;
int matchRule = SearchPattern.R_ERASURE_MATCH | SearchPattern.R_CASE_SENSITIVE;
SearchPattern pattern = SearchPattern.createPattern(fMethod, limitTo, matchRule);
MethodRequestor requestor = new MethodRequestor();
SearchEngine searchEngine = owner != null ? new SearchEngine(owner) : new SearchEngine();
searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, createSearchScope(), requestor, monitor);
}
示例3: initProjectManager
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
@Before
public void initProjectManager() throws CoreException {
clientRequests.clear();
logListener = new SimpleLogListener();
Platform.addLogListener(logListener);
preferences = new Preferences();
if (preferenceManager != null) {
when(preferenceManager.getPreferences()).thenReturn(preferences);
}
projectsManager = new ProjectsManager(preferenceManager);
WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
@Override
public IBuffer createBuffer(ICompilationUnit workingCopy) {
ICompilationUnit original= workingCopy.getPrimary();
IResource resource= original.getResource();
if (resource instanceof IFile) {
return new DocumentAdapter(workingCopy, (IFile)resource);
}
return DocumentAdapter.Null;
}
});
}
示例4: getAllRippleMethods
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private IMethod[] getAllRippleMethods(IProgressMonitor pm, WorkingCopyOwner owner)
throws CoreException {
IMethod[] rippleMethods = findAllRippleMethods(pm, owner);
if (fDeclarationToMatch == null) return rippleMethods;
List<IMethod> rippleMethodsList = new ArrayList<IMethod>(Arrays.asList(rippleMethods));
for (Iterator<IMethod> iter = rippleMethodsList.iterator(); iter.hasNext(); ) {
Object match = fDeclarationToMatch.get(iter.next());
if (match != null) {
iter.remove();
fBinaryRefs.add((SearchMatch) match);
}
}
fDeclarationToMatch = null;
return rippleMethodsList.toArray(new IMethod[rippleMethodsList.size()]);
}
示例5: getCachedHierarchy
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private ITypeHierarchy getCachedHierarchy(
IType type, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
IType rep = fUnionFind.find(type);
if (rep != null) {
Collection<IType> collection = fRootReps.get(rep);
for (Iterator<IType> iter = collection.iterator(); iter.hasNext(); ) {
IType root = iter.next();
ITypeHierarchy hierarchy = fRootHierarchies.get(root);
if (hierarchy == null) {
hierarchy = root.newTypeHierarchy(owner, new SubProgressMonitor(monitor, 1));
fRootHierarchies.put(root, hierarchy);
}
if (hierarchy.contains(type)) return hierarchy;
}
}
return null;
}
示例6: parse
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
public CompilationUnit parse(
ITypeRoot typeRoot,
WorkingCopyOwner owner,
boolean resolveBindings,
boolean statementsRecovery,
boolean bindingsRecovery,
IProgressMonitor pm) {
fParser.setResolveBindings(resolveBindings);
fParser.setStatementsRecovery(statementsRecovery);
fParser.setBindingsRecovery(bindingsRecovery);
fParser.setSource(typeRoot);
if (owner != null) fParser.setWorkingCopyOwner(owner);
fParser.setCompilerOptions(getCompilerOptions(typeRoot));
CompilationUnit result = (CompilationUnit) fParser.createAST(pm);
return result;
}
示例7: search
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
public static SearchResultGroup[] search(
SearchPattern pattern,
WorkingCopyOwner owner,
IJavaSearchScope scope,
CollectingSearchRequestor requestor,
IProgressMonitor monitor,
RefactoringStatus status)
throws JavaModelException {
return internalSearch(
owner != null ? new SearchEngine(owner) : new SearchEngine(),
pattern,
scope,
requestor,
monitor,
status);
}
示例8: getPerWorkingCopyInfo
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
public PerWorkingCopyInfo getPerWorkingCopyInfo(
CompilationUnit workingCopy,
boolean create,
boolean recordUsage,
IProblemRequestor problemRequestor) {
synchronized (
this.perWorkingCopyInfos) { // use the perWorkingCopyInfo collection as its own lock
WorkingCopyOwner owner = workingCopy.owner;
Map workingCopyToInfos = (Map) this.perWorkingCopyInfos.get(owner);
if (workingCopyToInfos == null && create) {
workingCopyToInfos = new HashMap();
this.perWorkingCopyInfos.put(owner, workingCopyToInfos);
}
PerWorkingCopyInfo info =
workingCopyToInfos == null
? null
: (PerWorkingCopyInfo) workingCopyToInfos.get(workingCopy);
if (info == null && create) {
info = new PerWorkingCopyInfo(workingCopy, problemRequestor);
workingCopyToInfos.put(workingCopy, info);
}
if (info != null && recordUsage) info.useCount++;
return info;
}
}
示例9: getCompilationUnit
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private static ICompilationUnit getCompilationUnit(
char[] fileName, WorkingCopyOwner workingCopyOwner) {
char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
if (pkgEnd == -1) return null;
IPackageFragment pkg =
getPackageFragment(slashSeparatedFileName, pkgEnd, -1 /*no jar separator for .java files*/);
if (pkg == null) return null;
int start;
ICompilationUnit cu =
pkg.getCompilationUnit(
new String(
slashSeparatedFileName, start = pkgEnd + 1, slashSeparatedFileName.length - start));
if (workingCopyOwner != null) {
ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
if (workingCopy != null) return workingCopy;
}
return cu;
}
示例10: findPackageFragment
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
public IJavaElement findPackageFragment(String packageName) throws JavaModelException {
NameLookup lookup =
newNameLookup((WorkingCopyOwner) null /*no need to look at working copies for pkgs*/);
IPackageFragment[] pkgFragments = lookup.findPackageFragments(packageName, false);
if (pkgFragments == null) {
return null;
} else {
// try to return one that is a child of this project
for (int i = 0, length = pkgFragments.length; i < length; i++) {
IPackageFragment pkgFragment = pkgFragments[i];
if (equals(pkgFragment.getParent().getParent())) {
return pkgFragment;
}
}
// default to the first one
return pkgFragments[0];
}
}
示例11: getHandleFromMemento
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
@Override
public IJavaElement getHandleFromMemento(
String token, MementoTokenizer memento, WorkingCopyOwner owner) {
switch (token.charAt(0)) {
case JavaElement.JEM_PACKAGEFRAGMENTROOT:
String rootPath = IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
token = null;
while (memento.hasMoreTokens()) {
token = memento.nextToken();
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331821
if (token == MementoTokenizer.PACKAGEFRAGMENT || token == MementoTokenizer.COUNT) {
break;
}
rootPath += token;
}
JavaElement root = (JavaElement) getPackageFragmentRoot(new Path(rootPath));
if (token != null && token.charAt(0) == JavaElement.JEM_PACKAGEFRAGMENT) {
return root.getHandleFromMemento(token, memento, owner);
} else {
return root.getHandleFromMemento(memento, owner);
}
}
return null;
}
示例12: _processUnit
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private void _processUnit(ICompilationUnit cu)
throws JavaModelException, MalformedTreeException, BadLocationException {
// Parse the javacode to be able to modify it
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setSource(cu);
// Create a copy of the CompilationUnit to work on
CompilationUnit copyOfUnit = (CompilationUnit)parser.createAST(null);
MemberComparator comparator = new MemberComparator();
// This helper method will sort our java code with the given comparator
TextEdit edits = CompilationUnitSorter.sort(copyOfUnit, comparator, 0, null, null);
// The sort method gives us null if there weren't any changes
if (edits != null) {
ICompilationUnit workingCopy = cu.getWorkingCopy(new WorkingCopyOwner() {}, null);
workingCopy.applyTextEdit(edits, null);
// Commit changes
workingCopy.commitWorkingCopy(true, null);
}
}
示例13: getImplicitConstructorReferencesInClassCreations
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private List<SearchMatch> getImplicitConstructorReferencesInClassCreations(WorkingCopyOwner owner, IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
//XXX workaround for jdt core bug 23112
SearchPattern pattern= SearchPattern.createPattern(fType, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
IJavaSearchScope scope= RefactoringScopeFactory.create(fType);
SearchResultGroup[] refs= RefactoringSearchEngine.search(pattern, owner, scope, pm, status);
List<SearchMatch> result= new ArrayList<SearchMatch>();
for (int i= 0; i < refs.length; i++) {
SearchResultGroup group= refs[i];
ICompilationUnit cu= group.getCompilationUnit();
if (cu == null)
continue;
CompilationUnit cuNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(cu, false);
SearchMatch[] results= group.getSearchResults();
for (int j= 0; j < results.length; j++) {
SearchMatch searchResult= results[j];
ASTNode node= ASTNodeSearchUtil.getAstNode(searchResult, cuNode);
if (isImplicitConstructorReferenceNodeInClassCreations(node))
result.add(searchResult);
}
}
return result;
}
示例14: reportBinding
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
private void reportBinding(Object key, ASTRequestor astRequestor, WorkingCopyOwner owner, CompilationUnitDeclaration unit) {
BindingKeyResolver keyResolver = (BindingKeyResolver) key;
Binding compilerBinding = keyResolver.getCompilerBinding();
if (compilerBinding != null) {
DefaultBindingResolver resolver = new DefaultBindingResolver(unit.scope, owner, this.bindingTables, false, this.fromJavaProject);
AnnotationBinding annotationBinding = keyResolver.getAnnotationBinding();
IBinding binding;
if (annotationBinding != null) {
binding = resolver.getAnnotationInstance(annotationBinding);
} else {
binding = resolver.getBinding(compilerBinding);
}
if (binding != null)
astRequestor.acceptBinding(keyResolver.getKey(), binding);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:CompilationUnitResolver.java
示例15: setExtendedData
import org.eclipse.jdt.core.WorkingCopyOwner; //导入依赖的package包/类
protected void setExtendedData(
ITypeRoot typeRoot,
CompilationUnitDeclaration compilationUnitDeclaration,
LookupEnvironment lookupEnvironment,
Scope scope,
ASTNode astNode,
ASTNode astNodeParent,
WorkingCopyOwner owner,
CompletionParser parser) {
this.isExtended = true;
this.extendedContext =
new InternalExtendedCompletionContext(
this,
typeRoot,
compilationUnitDeclaration,
lookupEnvironment,
scope,
astNode,
astNodeParent,
owner,
parser);
}