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


Java DefaultProblemFactory类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory的典型用法代码示例。如果您正苦于以下问题:Java DefaultProblemFactory类的具体用法?Java DefaultProblemFactory怎么用?Java DefaultProblemFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultProblemFactory类属于org.eclipse.jdt.internal.compiler.problem包,在下文中一共展示了DefaultProblemFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Nullable
private static Node parse(String code) {
  CompilerOptions options = new CompilerOptions();
  options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_7;
  options.parseLiteralExpressionsAsConstants = true;
  ProblemReporter problemReporter = new ProblemReporter(
    DefaultErrorHandlingPolicies.exitOnFirstError(), options, new DefaultProblemFactory());
  Parser parser = new Parser(problemReporter, options.parseLiteralExpressionsAsConstants);
  parser.javadocParser.checkDocComment = false;
  EcjTreeConverter converter = new EcjTreeConverter();
  org.eclipse.jdt.internal.compiler.batch.CompilationUnit sourceUnit =
    new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(code.toCharArray(), "unitTest", "UTF-8");
  CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
  CompilationUnitDeclaration unit = parser.parse(sourceUnit, compilationResult);
  if (unit == null) {
    return null;
  }
  converter.visit(code, unit);
  List<? extends Node> nodes = converter.getAll();
  for (lombok.ast.Node node : nodes) {
    if (node instanceof lombok.ast.CompilationUnit) {
      return node;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LombokPsiConverterTest.java

示例2: getSourceElementParser

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
public SourceElementParser getSourceElementParser(
    IJavaProject project, ISourceElementRequestor requestor) {
  // disable task tags to speed up parsing
  Map options = project.getOptions(true);
  options.put(JavaCore.COMPILER_TASK_TAGS, ""); // $NON-NLS-1$
  try {
    SourceElementParser parser =
        new IndexingParser(
            requestor,
            new DefaultProblemFactory(Locale.getDefault()),
            new CompilerOptions(options),
            true, // index local declarations
            true, // optimize string literals
            false); // do not use source javadoc parser to speed up parsing
    parser.reportOnlyOneSyntaxError = true;

    // Always check javadoc while indexing
    parser.javadocParser.checkDocComment = true;
    parser.javadocParser.reportProblems = false;

    return parser;
  } catch (Exception e) {
    e.printStackTrace();
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:IndexManager.java

示例3: process

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Override public ASTNode process(Source in, Void irrelevant) throws ConversionProblem {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(in.getRawInput().toCharArray(), in.getName(), charset.name());
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) {
		throw new ConversionProblem(String.format("Can't read file %s due to parse error: %s", in.getName(), compilationResult.getErrors()[0]));
	}
	
	return cud;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:19,代码来源:Main.java

示例4: createDefaultProblemReporter

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
private static ProblemReporter createDefaultProblemReporter(CompilerOptions options) {
	return new ProblemReporter(new IErrorHandlingPolicy() {
		public boolean proceedOnErrors() {
			return true;
		}
		
		public boolean stopOnFirstError() {
			return false;
		}
		
		@Override
		public boolean ignoreAllErrors() {
			return false;
		}
	}, options, new DefaultProblemFactory(Locale.ENGLISH));
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:17,代码来源:EcjTreeBuilder.java

示例5: parseWithLombok

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Override
protected ASTNode parseWithLombok(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	
	EcjTreeConverter converter = new EcjTreeConverter();
	converter.visit(source.getRawInput(), cud);
	Node lombokized = converter.get();
	
	EcjTreeBuilder builder = new EcjTreeBuilder(source.getRawInput(), source.getName(), ecjCompilerOptions());
	builder.visit(lombokized);
	return builder.get();
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:24,代码来源:EcjTreeConverterType2Test.java

示例6: parseWithTargetCompiler

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Override
protected ASTNode parseWithTargetCompiler(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	
	return cud;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:18,代码来源:EcjTreeConverterType2Test.java

示例7: parseWithTargetCompiler

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Override
protected ASTNode parseWithTargetCompiler(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	return cud;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:17,代码来源:EcjTreeBuilderTest.java

示例8: parseWithTargetCompiler

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
protected Node parseWithTargetCompiler(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	
	EcjTreeConverter converter = new EcjTreeConverter();
	converter.visit(source.getRawInput(), cud);
	return converter.get();
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:19,代码来源:EcjTreeConverterType1Test.java

示例9: getSourceElementParser

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
public SourceElementParser getSourceElementParser(IJavaProject project, ISourceElementRequestor requestor) {
	// disable task tags to speed up parsing
	Map options = project.getOptions(true);
	options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$

	SourceElementParser parser = new IndexingParser(
		requestor,
		new DefaultProblemFactory(Locale.getDefault()),
		new CompilerOptions(options),
		true, // index local declarations
		true, // optimize string literals
		false); // do not use source javadoc parser to speed up parsing
	parser.reportOnlyOneSyntaxError = true;

	// Always check javadoc while indexing
	parser.javadocParser.checkDocComment = true;
	parser.javadocParser.reportProblems = false;

	return parser;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:IndexManager.java

示例10: compile

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
public void compile(Collection<Source> sources) {
    Timer timer = metric.startTimer("act:classload:compile:_all");
    int len = sources.size();
    ICompilationUnit[] compilationUnits = new ICompilationUnit[len];
    int i = 0;
    for (Source source: sources) {
        compilationUnits[i++] = source.compilationUnit();
    }
    IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitOnFirstError();
    IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);

    org.eclipse.jdt.internal.compiler.Compiler jdtCompiler = new Compiler(
            nameEnv, policy, compilerOptions, requestor, problemFactory) {
        @Override
        protected void handleInternalException(Throwable e, CompilationUnitDeclaration ud, CompilationResult result) {
        }
    };

    jdtCompiler.compile(compilationUnits);
    timer.stop();
}
 
开发者ID:actframework,项目名称:actframework,代码行数:22,代码来源:AppCompiler.java

示例11: compile

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Override
public CompilationResult compile(final Collection<String> sourceNames) {
	final Map<String, byte[]> compiled = new HashMap<String, byte[]>();
	final List<CompilationProblem> problems = new ArrayList<CompilationProblem>();

	final List<ICompilationUnit> compilationUnits = collectCompilationUnits(sourceNames, problems);

	// Exit if problems
	if (! problems.isEmpty()) {
		return new CompilationResult(problems);
	}

	// Setup compiler environment
	final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
	final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
	final INameEnvironment nameEnvironment = new NameEnvironment();
	final ICompilerRequestor compilerRequestor = new CompilerRequestor(problems, compiled);

	// Compile
	final Compiler compiler = new Compiler(nameEnvironment, policy, new CompilerOptions(STANDARD_OPTIONS),
			compilerRequestor, problemFactory);
	compiler.compile(compilationUnits.toArray(new ICompilationUnit[0]));

	return new CompilationResult(problems, compiled);
}
 
开发者ID:MattiasBuelens,项目名称:junit,代码行数:26,代码来源:EclipseCompiler.java

示例12: installStubs

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
public void installStubs(final Resource resource) {
  boolean _isInfoFile = this.isInfoFile(resource);
  if (_isInfoFile) {
    return;
  }
  final CompilationUnit compilationUnit = this.getCompilationUnit(resource);
  IErrorHandlingPolicy _proceedWithAllProblems = DefaultErrorHandlingPolicies.proceedWithAllProblems();
  CompilerOptions _compilerOptions = this.getCompilerOptions(resource);
  DefaultProblemFactory _defaultProblemFactory = new DefaultProblemFactory();
  ProblemReporter _problemReporter = new ProblemReporter(_proceedWithAllProblems, _compilerOptions, _defaultProblemFactory);
  final Parser parser = new Parser(_problemReporter, true);
  final CompilationResult compilationResult = new CompilationResult(compilationUnit, 0, 1, (-1));
  final CompilationUnitDeclaration result = parser.dietParse(compilationUnit, compilationResult);
  if ((result.types != null)) {
    for (final TypeDeclaration type : result.types) {
      {
        ImportReference _currentPackage = result.currentPackage;
        char[][] _importName = null;
        if (_currentPackage!=null) {
          _importName=_currentPackage.getImportName();
        }
        List<String> _map = null;
        if (((List<char[]>)Conversions.doWrapArray(_importName))!=null) {
          final Function1<char[], String> _function = (char[] it) -> {
            return String.valueOf(it);
          };
          _map=ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(_importName)), _function);
        }
        String _join = null;
        if (_map!=null) {
          _join=IterableExtensions.join(_map, ".");
        }
        final String packageName = _join;
        final JvmDeclaredType jvmType = this.createType(type, packageName);
        resource.getContents().add(jvmType);
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:40,代码来源:JavaDerivedStateComputer.java

示例13: compileUnits

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
@Override
protected String compileUnits(final JRCompilationUnit[] units, String classpath, File tempDirFile)
{
	final INameEnvironment env = getNameEnvironment(units);

	final IErrorHandlingPolicy policy = 
		DefaultErrorHandlingPolicies.proceedWithAllProblems();

	final Map<String,String> settings = getJdtSettings();

	final IProblemFactory problemFactory = 
		new DefaultProblemFactory(Locale.getDefault());

	final CompilerRequestor requestor = getCompilerRequestor(units);

	final Compiler compiler = new Compiler(env, policy, settings, requestor, problemFactory);

	do
	{
		CompilationUnit[] compilationUnits = requestor.processCompilationUnits();

		compiler.compile(compilationUnits);
	}
	while (requestor.hasMissingMethods());
	
	requestor.processProblems();

	return requestor.getFormattedProblems();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:30,代码来源:JRJdtCompiler.java

示例14: parseWithEcj

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
private void parseWithEcj(Source source) {
	if (VERBOSE) {
		CompilerOptions compilerOptions = ecjCompilerOptions();
		Parser parser = new Parser(new ProblemReporter(
				DefaultErrorHandlingPolicies.proceedWithAllProblems(),
				compilerOptions,
				new DefaultProblemFactory()
			), compilerOptions.parseLiteralExpressionsAsConstants);
		parser.javadocParser.checkDocComment = true;
		CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
		CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
		parser.parse(sourceUnit, compilationResult);
	}
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:15,代码来源:PerformanceTest.java

示例15: resolveDocument

import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; //导入依赖的package包/类
public void resolveDocument() {
	try {
		IPath path = new Path(this.document.getPath());
		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
		JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
		JavaProject javaProject = (JavaProject) model.getJavaProject(project);

		this.options = new CompilerOptions(javaProject.getOptions(true));
		ProblemReporter problemReporter =
				new ProblemReporter(
						DefaultErrorHandlingPolicies.proceedWithAllProblems(),
						this.options,
						new DefaultProblemFactory());

		// Re-parse using normal parser, IndexingParser swallows several nodes, see comment above class.
		this.basicParser = new Parser(problemReporter, false);
		this.basicParser.reportOnlyOneSyntaxError = true;
		this.basicParser.scanner.taskTags = null;
		this.cud = this.basicParser.parse(this.compilationUnit, new CompilationResult(this.compilationUnit, 0, 0, this.options.maxProblemsPerUnit));

		// Use a non model name environment to avoid locks, monitors and such.
		INameEnvironment nameEnvironment = new JavaSearchNameEnvironment(javaProject, JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, true/*add primary WCs*/));
		this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment);
		reduceParseTree(this.cud);
		this.lookupEnvironment.buildTypeBindings(this.cud, null);
		this.lookupEnvironment.completeTypeBindings();
		this.cud.scope.faultInTypes();
		this.cud.resolve();
	} catch (Exception e) {
		if (JobManager.VERBOSE) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:SourceIndexer.java


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