本文整理汇总了Java中org.eclipse.jdt.internal.core.util.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于org.eclipse.jdt.internal.core.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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();
}
}
});
}
}
示例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;
}
示例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;
}
}
}
示例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$
}