本文整理汇总了Java中org.eclipse.jdt.internal.core.util.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于org.eclipse.jdt.internal.core.util包,在下文中一共展示了Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTypesToBytes
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
/**
* Returns a mapping of class files to the bytes that make up those class files.
*
* @param resources
* the classfiles
* @param qualifiedNames
* the fully qualified type names corresponding to the classfiles.
* The typeNames correspond to the resources on a one-to-one basis.
* @return a mapping of class files to bytes key: class file value: the bytes
* which make up that classfile
*/
private Map<ReferenceType, byte[]> getTypesToBytes(List<IResource> resources, List<String> qualifiedNames) {
Map<ReferenceType, byte[]> typesToBytes = new HashMap<>(resources.size());
Iterator<IResource> resourceIter = resources.iterator();
Iterator<String> nameIter = qualifiedNames.iterator();
IResource resource;
String name;
while (resourceIter.hasNext()) {
resource = resourceIter.next();
name = nameIter.next();
List<ReferenceType> classes = getJdiClassesByName(name);
byte[] bytes = null;
try {
bytes = Util.getResourceContentsAsByteArray((IFile) resource);
} catch (CoreException e) {
continue;
}
for (ReferenceType type : classes) {
typesToBytes.put(type, bytes);
}
}
return typesToBytes;
}
开发者ID:Microsoft,项目名称:java-debug,代码行数:34,代码来源:JavaHotCodeReplaceProvider.java
示例2: deleteIndexFiles
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void deleteIndexFiles(SimpleSet pathsToKeep) {
File[] indexesFiles = getSavedIndexesDirectory().listFiles();
if (indexesFiles == null) return;
for (int i = 0, l = indexesFiles.length; i < l; i++) {
String fileName = indexesFiles[i].getAbsolutePath();
if (pathsToKeep != null && pathsToKeep.includes(new FileIndexLocation(indexesFiles[i])))
continue;
String suffix = ".index"; // $NON-NLS-1$
if (fileName.regionMatches(
true, fileName.length() - suffix.length(), suffix, 0, suffix.length())) {
if (JobManager.VERBOSE || DEBUG)
Util.verbose("Deleting index file " + indexesFiles[i]); // $NON-NLS-1$
indexesFiles[i].delete();
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:IndexManager.java
示例3: readJavaLikeNamesFile
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private char[][] readJavaLikeNamesFile() {
try {
String pathName = getJavaPluginWorkingLocation().toOSString();
File javaLikeNamesFile = new File(pathName, "javaLikeNames.txt"); // $NON-NLS-1$
if (!javaLikeNamesFile.exists()) return null;
char[] javaLikeNames =
org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(javaLikeNamesFile, null);
if (javaLikeNames.length > 0) {
char[][] names = CharOperation.splitOn('\n', javaLikeNames);
return names;
}
} catch (IOException ignored) {
if (JobManager.VERBOSE) Util.verbose("Failed to read javaLikeNames file"); // $NON-NLS-1$
}
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:IndexManager.java
示例4: rebuildIndex
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void rebuildIndex(IndexLocation indexLocation, IPath containerPath) {
Object target = JavaModelManager.getTarget(containerPath, true);
if (target == null) return;
if (JobManager.VERBOSE)
Util.verbose(
"-> request to rebuild index: "
+ indexLocation
+ " path: "
+ containerPath); // $NON-NLS-1$ //$NON-NLS-2$
updateIndexState(indexLocation, REBUILDING_STATE);
IndexRequest request = null;
if (target instanceof IProject) {
IProject p = (IProject) target;
if (JavaProject.hasJavaNature(p)) request = new IndexAllProject(p, this);
} else if (target instanceof IFolder) {
request = new IndexBinaryFolder((IFolder) target, this);
} else if (target instanceof IFile) {
request = new AddJarFileToIndex((IFile) target, null, this);
} else if (target instanceof File) {
request = new AddJarFileToIndex(containerPath, null, this);
}
if (request != null) request(request);
}
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:IndexManager.java
示例5: saveIndex
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
public void saveIndex(Index index) throws IOException {
// must have permission to write from the write monitor
if (index.hasChanged()) {
if (JobManager.VERBOSE)
Util.verbose("-> saving index " + index.getIndexLocation()); // $NON-NLS-1$
index.save();
}
synchronized (this) {
IPath containerPath = new Path(index.containerPath);
if (this.jobEnd > this.jobStart) {
for (int i = this.jobEnd; i > this.jobStart; i--) { // skip the current job
IJob job = this.awaitingJobs[i];
if (job instanceof IndexRequest)
if (((IndexRequest) job).containerPath.equals(containerPath)) return;
}
}
IndexLocation indexLocation = computeIndexLocation(containerPath);
updateIndexState(indexLocation, SAVED_STATE);
}
}
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:IndexManager.java
示例6: readIndexMap
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void readIndexMap() {
try {
char[] indexMaps =
org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(
this.indexNamesMapFile, null);
char[][] names = CharOperation.splitOn('\n', indexMaps);
if (names.length >= 3) {
// First line is DiskIndex signature (see writeIndexMapFile())
String savedSignature = DiskIndex.SIGNATURE;
if (savedSignature.equals(new String(names[0]))) {
for (int i = 1, l = names.length - 1; i < l; i += 2) {
IndexLocation indexPath =
IndexLocation.createIndexLocation(new URL(new String(names[i])));
if (indexPath == null) continue;
this.indexLocations.put(new Path(new String(names[i + 1])), indexPath);
this.indexStates.put(indexPath, REUSE_STATE);
}
}
}
} catch (IOException ignored) {
if (JobManager.VERBOSE) Util.verbose("Failed to read saved index file names"); // $NON-NLS-1$
}
return;
}
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:IndexManager.java
示例7: readIndexState
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private char[][] readIndexState(String dirOSString) {
try {
char[] savedIndexNames =
org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(
this.savedIndexNamesFile, null);
if (savedIndexNames.length > 0) {
char[][] names = CharOperation.splitOn('\n', savedIndexNames);
if (names.length > 1) {
// First line is DiskIndex signature + saved plugin working location (see
// writeSavedIndexNamesFile())
String savedSignature = DiskIndex.SIGNATURE + "+" + dirOSString; // $NON-NLS-1$
if (savedSignature.equals(new String(names[0]))) return names;
}
}
} catch (IOException ignored) {
if (JobManager.VERBOSE) Util.verbose("Failed to read saved index file names"); // $NON-NLS-1$
}
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:IndexManager.java
示例8: readParticipantsIndexNamesFile
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void readParticipantsIndexNamesFile() {
SimpleLookupTable containers = new SimpleLookupTable(3);
try {
char[] participantIndexNames =
org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(
this.participantIndexNamesFile, null);
if (participantIndexNames.length > 0) {
char[][] names = CharOperation.splitOn('\n', participantIndexNames);
if (names.length >= 3) {
// First line is DiskIndex signature (see writeParticipantsIndexNamesFile())
if (DiskIndex.SIGNATURE.equals(new String(names[0]))) {
for (int i = 1, l = names.length - 1; i < l; i += 2) {
IndexLocation indexLocation =
new FileIndexLocation(new File(new String(names[i])), true);
containers.put(indexLocation, new Path(new String(names[i + 1])));
}
}
}
}
} catch (IOException ignored) {
if (JobManager.VERBOSE)
Util.verbose("Failed to read participant index file names"); // $NON-NLS-1$
}
this.participantsContainers = containers;
return;
}
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:IndexManager.java
示例9: removeIndexesState
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private synchronized void removeIndexesState(IndexLocation[] locations) {
getIndexStates(); // ensure the states are initialized
int length = locations.length;
boolean changed = false;
for (int i = 0; i < length; i++) {
if (locations[i] == null) continue;
if ((this.indexStates.removeKey(locations[i]) != null)) {
changed = true;
if (JobManager.VERBOSE) {
Util.verbose("-> index state updated to: ? for: " + locations[i]); // $NON-NLS-1$
}
}
}
if (!changed) return;
writeSavedIndexNamesFile();
writeIndexMapFile();
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:IndexManager.java
示例10: getPath
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private IPath getPath(IJavaElement element, boolean relativeToRoot) {
switch (element.getElementType()) {
case IJavaElement.JAVA_MODEL:
return Path.EMPTY;
case IJavaElement.JAVA_PROJECT:
return element.getPath();
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
if (relativeToRoot) return Path.EMPTY;
return element.getPath();
case IJavaElement.PACKAGE_FRAGMENT:
String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
case IJavaElement.COMPILATION_UNIT:
case IJavaElement.CLASS_FILE:
return getPath(element.getParent(), relativeToRoot)
.append(new Path(element.getElementName()));
default:
return getPath(element.getParent(), relativeToRoot);
}
}
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:JavaSearchScope.java
示例11: readSource
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private char[] readSource(ZipEntry entry, ZipFile zip, String charSet) {
try {
byte[] bytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(entry, zip);
if (bytes != null) {
// Order of preference: charSet supplied, this.encoding or this.defaultEncoding in that
// order
return org.eclipse.jdt.internal.compiler.util.Util.bytesToChar(
bytes,
charSet == null
? (this.encoding == null ? this.defaultEncoding : this.encoding)
: charSet);
}
} catch (IOException e) {
// ignore
}
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:SourceMapper.java
示例12: notifyTypeHierarchies
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void notifyTypeHierarchies(IElementChangedListener[] listeners, int listenerCount) {
for (int i = 0; i < listenerCount; i++) {
final IElementChangedListener listener = listeners[i];
if (!(listener instanceof TypeHierarchy)) continue;
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are
// causing grief
SafeRunner.run(
new ISafeRunnable() {
public void handleException(Throwable exception) {
Util.log(
exception,
"Exception occurred in listener of Java element change notification"); // $NON-NLS-1$
}
public void run() throws Exception {
TypeHierarchy typeHierarchy = (TypeHierarchy) listener;
if (typeHierarchy.hasFineGrainChanges()) {
// case of changes in primary working copies
typeHierarchy.needsRefresh = true;
typeHierarchy.fireChange();
}
}
});
}
}
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:DeltaProcessor.java
示例13: ClasspathJar
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
ClasspathJar(IFile resource, AccessRuleSet accessRuleSet) {
this.resource = resource;
try {
java.net.URI location = resource.getLocationURI();
if (location == null) {
this.zipFilename = ""; // $NON-NLS-1$
} else {
File localFile = Util.toLocalFile(location, null);
this.zipFilename = localFile.getPath();
}
} catch (CoreException e) {
// ignore
}
this.zipFile = null;
this.knownPackageNames = null;
packageNames = null;
this.accessRuleSet = accessRuleSet;
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:ClasspathJar.java
示例14: contentTypeChanged
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
public void contentTypeChanged(ContentTypeChangeEvent event) {
Util.resetJavaLikeExtensions();
// Walk through projects to reset their secondary types cache
IJavaProject[] projects;
try {
projects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
} catch (JavaModelException e) {
return;
}
for (int i = 0, length = projects.length; i < length; i++) {
IJavaProject project = projects[i];
final PerProjectInfo projectInfo = getPerProjectInfo(project.getProject(), false /* don't create info */);
if (projectInfo != null) {
projectInfo.secondaryTypes = null;
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:JavaModelManager.java
示例15: verbose_reentering_project_container_access
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void verbose_reentering_project_container_access( IPath containerPath, IJavaProject project, IClasspathContainer previousContainer) {
StringBuffer buffer = new StringBuffer();
buffer.append("CPContainer INIT - reentering access to project container during its initialization, will see previous value\n"); //$NON-NLS-1$
buffer.append(" project: " + project.getElementName() + '\n'); //$NON-NLS-1$
buffer.append(" container path: " + containerPath + '\n'); //$NON-NLS-1$
buffer.append(" previous value: "); //$NON-NLS-1$
buffer.append(previousContainer.getDescription());
buffer.append(" {\n"); //$NON-NLS-1$
IClasspathEntry[] entries = previousContainer.getClasspathEntries();
if (entries != null){
for (int j = 0; j < entries.length; j++){
buffer.append(" "); //$NON-NLS-1$
buffer.append(entries[j]);
buffer.append('\n');
}
}
buffer.append(" }"); //$NON-NLS-1$
Util.verbose(buffer.toString());
new Exception("<Fake exception>").printStackTrace(System.out); //$NON-NLS-1$
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:JavaModelManager.java
示例16: notifyParticipants
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void notifyParticipants(final CompilationUnit workingCopy) {
IJavaProject javaProject = getWorkingCopy().getJavaProject();
CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject);
if (participants == null) return;
final ReconcileContext context = new ReconcileContext(this, workingCopy);
for (int i = 0, length = participants.length; i < length; i++) {
final CompilationParticipant participant = participants[i];
SafeRunner.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
if (exception instanceof Error) {
throw (Error) exception; // errors are not supposed to be caught
} else if (exception instanceof OperationCanceledException)
throw (OperationCanceledException) exception;
else if (exception instanceof UnsupportedOperationException) {
// might want to disable participant as it tried to modify the buffer of the working copy being reconciled
Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$
} else
Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$
}
public void run() throws Exception {
participant.reconcile(context);
}
});
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:ReconcileWorkingCopyOperation.java
示例17: updateContent
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
/**
* Updates the content of <code>cu</code>, modifying the type name and/or package
* declaration as necessary.
*
* @return an AST rewrite or null if no rewrite needed
*/
private TextEdit updateContent(ICompilationUnit cu, PackageFragment dest, String newName) throws JavaModelException {
String[] currPackageName = ((PackageFragment) cu.getParent()).names;
String[] destPackageName = dest.names;
if (Util.equalArraysOrNull(currPackageName, destPackageName) && newName == null) {
return null; //nothing to change
} else {
// ensure cu is consistent (noop if already consistent)
cu.makeConsistent(this.progressMonitor);
this.parser.setSource(cu);
CompilationUnit astCU = (CompilationUnit) this.parser.createAST(this.progressMonitor);
AST ast = astCU.getAST();
ASTRewrite rewrite = ASTRewrite.create(ast);
updateTypeName(cu, astCU, cu.getElementName(), newName, rewrite);
updatePackageStatement(astCU, destPackageName, rewrite, cu);
return rewrite.rewriteAST();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:CopyResourceElementsOperation.java
示例18: searchDeclarationsOfReferencedTypes
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
/**
* Searches for all declarations of the types referenced in the given element.
* The element can be a compilation unit or a source type/method/field.
* Reports the type declarations using the given requestor.
*
* @see SearchEngine#searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, IProgressMonitor)
* for detailed comment
*/
public void searchDeclarationsOfReferencedTypes(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException {
if (VERBOSE) {
Util.verbose("BasicSearchEngine.searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$
}
// Do not accept other kind of element type than those specified in the spec
switch (enclosingElement.getElementType()) {
case IJavaElement.FIELD:
case IJavaElement.METHOD:
case IJavaElement.TYPE:
case IJavaElement.COMPILATION_UNIT:
// valid element type
break;
default:
throw new IllegalArgumentException();
}
SearchPattern pattern = new DeclarationOfReferencedTypesPattern(enclosingElement);
searchDeclarations(enclosingElement, requestor, pattern, monitor);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:BasicSearchEngine.java
示例19: readJavaLikeNamesFile
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private char[][] readJavaLikeNamesFile() {
try {
String pathName = getJavaPluginWorkingLocation().toOSString();
File javaLikeNamesFile = new File(pathName, "javaLikeNames.txt"); //$NON-NLS-1$
if (!javaLikeNamesFile.exists())
return null;
char[] javaLikeNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(javaLikeNamesFile, null);
if (javaLikeNames.length > 0) {
char[][] names = CharOperation.splitOn('\n', javaLikeNames);
return names;
}
} catch (IOException ignored) {
if (VERBOSE)
Util.verbose("Failed to read javaLikeNames file"); //$NON-NLS-1$
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:IndexManager.java
示例20: rebuildIndex
import org.eclipse.jdt.internal.core.util.Util; //导入依赖的package包/类
private void rebuildIndex(IndexLocation indexLocation, IPath containerPath, final boolean updateIndex) {
Object target = JavaModel.getTarget(containerPath, true);
if (target == null) return;
if (VERBOSE)
Util.verbose("-> request to rebuild index: "+indexLocation+" path: "+containerPath); //$NON-NLS-1$ //$NON-NLS-2$
updateIndexState(indexLocation, REBUILDING_STATE);
IndexRequest request = null;
if (target instanceof IProject) {
IProject p = (IProject) target;
if (JavaProject.hasJavaNature(p))
request = new IndexAllProject(p, this);
} else if (target instanceof IFolder) {
request = new IndexBinaryFolder((IFolder) target, this);
} else if (target instanceof IFile) {
request = new AddJarFileToIndex((IFile) target, null, this, updateIndex);
} else if (target instanceof File) {
request = new AddJarFileToIndex(containerPath, null, this, updateIndex);
}
if (request != null)
request(request);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:IndexManager.java
注:本文中的org.eclipse.jdt.internal.core.util.Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论