当前位置: 首页>>代码示例>>Java>>正文


Java CompilationResult.getClassFiles方法代码示例

本文整理汇总了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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GreclipseMain.java

示例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());
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:41,代码来源:JRJdtCompiler.java

示例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 });
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:57,代码来源:JavaDerivedStateComputer.java

示例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());
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:60,代码来源:JRJdtCompiler.java


注:本文中的org.eclipse.jdt.internal.compiler.CompilationResult.getClassFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。