本文整理汇总了Java中org.eclipse.jdt.internal.compiler.CompilationResult.getClassFiles方法的典型用法代码示例。如果您正苦于以下问题:Java CompilationResult.getClassFiles方法的具体用法?Java CompilationResult.getClassFiles怎么用?Java CompilationResult.getClassFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.CompilationResult
的用法示例。
在下文中一共展示了CompilationResult.getClassFiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outputClassFiles
import org.eclipse.jdt.internal.compiler.CompilationResult; //导入方法依赖的package包/类
@Override
public void outputClassFiles(CompilationResult result) {
super.outputClassFiles(result);
if (result == null || result.hasErrors() && !proceedOnError) {
return;
}
List<String> classFiles = new ArrayList<String>();
for (ClassFile file : result.getClassFiles()) {
classFiles.add(new String(file.fileName()) + ".class");
}
myOutputs.put(new String(result.getFileName()), classFiles);
}
示例2: acceptResult
import org.eclipse.jdt.internal.compiler.CompilationResult; //导入方法依赖的package包/类
public void acceptResult(CompilationResult result) {
String className = ((CompilationUnit) result.getCompilationUnit()).className;
int classIdx;
for (classIdx = 0; classIdx < units.length; ++classIdx) {
if (className.equals(units[classIdx].getName())) {
break;
}
}
if (result.hasErrors()) {
// IProblem[] problems = result.getErrors();
IProblem[] problems = getJavaCompilationErrors(result);
unitResults[classIdx].problems = problems;
String sourceCode = units[classIdx].getSourceCode();
for (int i = 0; i < problems.length; i++) {
IProblem problem = problems[i];
if (IProblem.UndefinedMethod == problem.getID()) {
if (problem.getSourceStart() >= 0 && problem.getSourceEnd() >= 0) {
String methodName = sourceCode.substring(problem.getSourceStart(), problem.getSourceEnd() + 1);
Method method = FunctionsUtil.getInstance(jasperReportsContext).getMethod4Function(methodName);
if (method != null) {
unitResults[classIdx].addMissingMethod(method);
// continue;
}
}
}
}
} else {
ClassFile[] resultClassFiles = result.getClassFiles();
for (int i = 0; i < resultClassFiles.length; i++) {
units[classIdx].setCompileData(resultClassFiles[i].getBytes());
}
}
}
示例3: installFull
import org.eclipse.jdt.internal.compiler.CompilationResult; //导入方法依赖的package包/类
public void installFull(final Resource resource) {
boolean _isInfoFile = this.isInfoFile(resource);
if (_isInfoFile) {
return;
}
final CompilationUnit compilationUnit = this.getCompilationUnit(resource);
final ClassLoader classLoader = this.getClassLoader(resource);
final IResourceDescriptions data = this.resourceDescriptionsProvider.getResourceDescriptions(resource.getResourceSet());
if ((data == null)) {
throw new IllegalStateException("no index installed");
}
final IndexAwareNameEnvironment nameEnv = new IndexAwareNameEnvironment(resource, classLoader, data, this.stubGenerator);
IErrorHandlingPolicy _proceedWithAllProblems = DefaultErrorHandlingPolicies.proceedWithAllProblems();
CompilerOptions _compilerOptions = this.getCompilerOptions(resource);
final ICompilerRequestor _function = (CompilationResult it) -> {
boolean _equals = Arrays.equals(it.fileName, compilationUnit.fileName);
if (_equals) {
final HashMap<String, byte[]> map = CollectionLiterals.<String, byte[]>newHashMap();
List<String> topLevelTypes = CollectionLiterals.<String>newArrayList();
ClassFile[] _classFiles = it.getClassFiles();
for (final ClassFile cf : _classFiles) {
{
final Function1<char[], String> _function_1 = (char[] it_1) -> {
return String.valueOf(it_1);
};
final String className = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(cf.getCompoundName())), _function_1), ".");
map.put(className, cf.getBytes());
if ((!cf.isNestedType)) {
topLevelTypes.add(className);
}
}
}
final InMemoryClassLoader inMemClassLoader = new InMemoryClassLoader(map, classLoader);
for (final String topLevel : topLevelTypes) {
try {
BinaryClass _binaryClass = new BinaryClass(topLevel, inMemClassLoader);
ClassFileBytesAccess _classFileBytesAccess = new ClassFileBytesAccess();
final JvmDeclaredTypeBuilder builder = new JvmDeclaredTypeBuilder(_binaryClass, _classFileBytesAccess, inMemClassLoader);
final JvmDeclaredType type = builder.buildType();
EList<EObject> _contents = resource.getContents();
_contents.add(type);
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable t = (Throwable)_t;
throw new IllegalStateException((("could not load type \'" + topLevel) + "\'"), t);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
}
};
DefaultProblemFactory _defaultProblemFactory = new DefaultProblemFactory();
final org.eclipse.jdt.internal.compiler.Compiler compiler = new org.eclipse.jdt.internal.compiler.Compiler(nameEnv, _proceedWithAllProblems, _compilerOptions, _function, _defaultProblemFactory);
compiler.compile(new ICompilationUnit[] { compilationUnit });
}
示例4: acceptResult
import org.eclipse.jdt.internal.compiler.CompilationResult; //导入方法依赖的package包/类
@Override
public void acceptResult(CompilationResult result)
{
String className = ((CompilationUnit) result.getCompilationUnit()).className;
int classIdx;
for (classIdx = 0; classIdx < units.length; ++classIdx)
{
if (className.equals(units[classIdx].getName()))
{
break;
}
}
if (result.hasErrors())
{
//IProblem[] problems = result.getErrors();
IProblem[] problems = getJavaCompilationErrors(result);
unitResults[classIdx].problems = problems;
String sourceCode = units[classIdx].getSourceCode();
for (int i = 0; i < problems.length; i++)
{
IProblem problem = problems[i];
if (IProblem.UndefinedMethod == problem.getID())
{
if (
problem.getSourceStart() >= 0
&& problem.getSourceEnd() >= 0
)
{
String methodName =
sourceCode.substring(
problem.getSourceStart(),
problem.getSourceEnd() + 1
);
Method method = FunctionsUtil.getInstance(jasperReportsContext).getMethod4Function(methodName);
if (method != null)
{
unitResults[classIdx].addMissingMethod(method);
//continue;
}
}
}
}
}
else
{
ClassFile[] resultClassFiles = result.getClassFiles();
for (int i = 0; i < resultClassFiles.length; i++)
{
units[classIdx].setCompileData(resultClassFiles[i].getBytes());
}
}
}