本文整理汇总了Java中org.eclipse.jdt.core.IClassFile.getElementName方法的典型用法代码示例。如果您正苦于以下问题:Java IClassFile.getElementName方法的具体用法?Java IClassFile.getElementName怎么用?Java IClassFile.getElementName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IClassFile
的用法示例。
在下文中一共展示了IClassFile.getElementName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* @param newCfSource the source
* @param originalCf the class file to get the name and project from
* @param resolveBindings whether bindings are to be resolved
* @param recovery whether statements and binding recovery should be enabled
* @param pm an {@link IProgressMonitor}, or <code>null</code>
* @return the parsed CompilationUnit
*/
public CompilationUnit parse(
String newCfSource,
IClassFile originalCf,
boolean resolveBindings,
boolean recovery,
IProgressMonitor pm) {
fParser.setResolveBindings(resolveBindings);
fParser.setStatementsRecovery(recovery);
fParser.setBindingsRecovery(recovery);
fParser.setSource(newCfSource.toCharArray());
String cfName = originalCf.getElementName();
fParser.setUnitName(cfName.substring(0, cfName.length() - 6) + JavaModelUtil.DEFAULT_CU_SUFFIX);
fParser.setProject(originalCf.getJavaProject());
fParser.setCompilerOptions(getCompilerOptions(originalCf));
CompilationUnit newCUNode = (CompilationUnit) fParser.createAST(pm);
return newCUNode;
}
示例2: parse
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* @param newCfSource the source
* @param originalCf the class file to get the name and project from
* @param resolveBindings whether bindings are to be resolved
* @param recovery whether statements and binding recovery should be enabled
* @param pm an {@link IProgressMonitor}, or <code>null</code>
* @return the parsed CompilationUnit
*/
public CompilationUnit parse(String newCfSource, IClassFile originalCf, boolean resolveBindings, boolean recovery, IProgressMonitor pm) {
fParser.setResolveBindings(resolveBindings);
fParser.setStatementsRecovery(recovery);
fParser.setBindingsRecovery(recovery);
fParser.setSource(newCfSource.toCharArray());
String cfName= originalCf.getElementName();
fParser.setUnitName(cfName.substring(0, cfName.length() - 6) + JavaModelUtil.DEFAULT_CU_SUFFIX);
fParser.setProject(originalCf.getJavaProject());
fParser.setCompilerOptions(getCompilerOptions(originalCf));
CompilationUnit newCUNode= (CompilationUnit) fParser.createAST(pm);
return newCUNode;
}
示例3: makeResourceItem
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
private static ResourceItem makeResourceItem(IClassFile file) {
String resourcePath = file.getPath() + "|" + file.getParent().getElementName().replaceAll("\\.", "/") + "/" + file.getElementName();
return new ResourceItem(extractName(file.getElementName()), resourcePath, "[class]");
}
示例4: setupSourceMapper
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
protected void setupSourceMapper(IClassFile classFile)
{
try
{
// Search package fragment root and classPath
IJavaElement packageFragment = classFile.getParent();
IJavaElement packageFragmentRoot = packageFragment.getParent();
if (packageFragmentRoot instanceof PackageFragmentRoot)
{
// Setup a new source mapper.
PackageFragmentRoot root = (PackageFragmentRoot)packageFragmentRoot;
// Location of the archive file containing classes.
IPath basePath = root.getPath();
File baseFile = basePath.makeAbsolute().toFile();
if (!baseFile.exists()) {
IResource resource = root.getCorrespondingResource();
basePath = resource.getLocation();
baseFile = basePath.makeAbsolute().toFile();
}
// Class path
String classPath = classFile.getElementName();
String packageName = packageFragment.getElementName();
if ((packageName != null) && (packageName.length() > 0))
classPath = packageName.replace('.', '/') + '/' + classPath;
// Location of the archive file containing source.
IPath sourcePath = root.getSourceAttachmentPath();
if (sourcePath == null) sourcePath = basePath;
// Location of the package fragment root within the zip
// (empty specifies the default root).
IPath sourceAttachmentRootPath = root.getSourceAttachmentRootPath();
String sourceRootPath;
if (sourceAttachmentRootPath == null) {
sourceRootPath = null;
} else {
sourceRootPath = sourceAttachmentRootPath.toString();
if ((sourceRootPath != null) && (sourceRootPath.length() == 0))
sourceRootPath = null;
}
// Options
Map options = root.getJavaProject().getOptions(true);
root.setSourceMapper(new JDSourceMapper(
baseFile, sourcePath, sourceRootPath, options));
}
}
catch (CoreException e)
{
JavaDecompilerPlugin.getDefault().getLog().log(new Status(
Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID,
0, e.getMessage(), e));
}
}
示例5: parse
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* @param newCfSource
* the source
* @param originalCf
* the class file to get the name and project from
* @param resolveBindings
* whether bindings are to be resolved
* @param recovery
* whether statements and binding recovery should be enabled
* @param pm
* an {@link IProgressMonitor}, or <code>null</code>
* @return the parsed CompilationUnit
*/
public CompilationUnit parse(String newCfSource, IClassFile originalCf, boolean resolveBindings, boolean recovery, IProgressMonitor pm) {
fParser.setResolveBindings(resolveBindings);
fParser.setStatementsRecovery(recovery);
fParser.setBindingsRecovery(recovery);
fParser.setSource(newCfSource.toCharArray());
String cfName = originalCf.getElementName();
fParser.setUnitName(cfName.substring(0, cfName.length() - 6) + JavaModelUtil.DEFAULT_CU_SUFFIX);
fParser.setProject(originalCf.getJavaProject());
fParser.setCompilerOptions(getCompilerOptions(originalCf));
CompilationUnit newCUNode = (CompilationUnit) fParser.createAST(pm);
return newCUNode;
}