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


Java INameEnvironment类代码示例

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


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

示例1: getEnclosedElements

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
@Override
public List<? extends Element> getEnclosedElements() {
	PackageBinding binding = (PackageBinding)_binding;
	LookupEnvironment environment = binding.environment;
	char[][][] typeNames = null;
	INameEnvironment nameEnvironment = binding.environment.nameEnvironment;
	if (nameEnvironment instanceof FileSystem) {
		typeNames = ((FileSystem) nameEnvironment).findTypeNames(binding.compoundName);
	}
	HashSet<Element> set = new HashSet<Element>(); 
	if (typeNames != null) {
		for (char[][] typeName : typeNames) {
			ReferenceBinding type = environment.getType(typeName);
			if (type != null && type.isValidBinding()) {
				set.add(_env.getFactory().newElement(type));
			}
		}
	}
	ArrayList<Element> list = new ArrayList<Element>(set.size());
	list.addAll(set);
	return Collections.unmodifiableList(list);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:PackageElementImpl.java

示例2: evaluateCodeSnippet

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * @see IEvaluationContext#evaluateCodeSnippet(String, ICodeSnippetRequestor, IProgressMonitor)
 */
public void evaluateCodeSnippet(String codeSnippet, ICodeSnippetRequestor requestor, IProgressMonitor progressMonitor) throws JavaModelException {

	checkBuilderState();
	INameEnvironment environment = null;
	try {
		this.context.evaluate(
			codeSnippet.toCharArray(),
			environment = getBuildNameEnvironment(),
			this.project.getOptions(true),
			getInfrastructureEvaluationRequestor(requestor),
			getProblemFactory());
	} catch (InstallException e) {
		handleInstallException(e);
	} finally {
		if (environment != null) environment.cleanup();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:EvaluationContextWrapper.java

示例3: evaluateVariable

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * @see IEvaluationContext#evaluateVariable(IGlobalVariable, ICodeSnippetRequestor, IProgressMonitor)
 */
public void evaluateVariable(IGlobalVariable variable, ICodeSnippetRequestor requestor, IProgressMonitor progressMonitor) throws JavaModelException {

	checkBuilderState();
	INameEnvironment environment = null;
	try {
		this.context.evaluateVariable(
			((GlobalVariableWrapper)variable).variable,
			environment = getBuildNameEnvironment(),
			this.project.getOptions(true),
			getInfrastructureEvaluationRequestor(requestor),
			getProblemFactory());
	} catch (InstallException e) {
		handleInstallException(e);
	} finally {
		if (environment != null) environment.cleanup();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:EvaluationContextWrapper.java

示例4: CodeSnippetCompiler

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * Creates a new code snippet compiler initialized with a code snippet parser.
 */
public CodeSnippetCompiler(
   		INameEnvironment environment,
   		IErrorHandlingPolicy policy,
   		CompilerOptions compilerOptions,
   		ICompilerRequestor requestor,
   		IProblemFactory problemFactory,
   		EvaluationContext evaluationContext,
   		int codeSnippetStart,
   		int codeSnippetEnd) {
	super(environment, policy, compilerOptions, requestor, problemFactory);
	this.codeSnippetStart = codeSnippetStart;
	this.codeSnippetEnd = codeSnippetEnd;
	this.evaluationContext = evaluationContext;
	this.parser =
		new CodeSnippetParser(
			this.problemReporter,
			evaluationContext,
			this.options.parseLiteralExpressionsAsConstants,
			codeSnippetStart,
			codeSnippetEnd);
	this.parseThreshold = 1;
	// fully parse only the code snippet compilation unit
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:CodeSnippetCompiler.java

示例5: getJavaElement

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
public IJavaElement getJavaElement() {
	INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; // a package binding always has a LooupEnvironment set
	if (!(nameEnvironment instanceof SearchableEnvironment)) return null;
	// this is not true in standalone DOM/AST
	NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup;
	if (nameLookup == null) return null;
	IJavaElement[] pkgs = nameLookup.findPackageFragments(getName(), false/*exact match*/);
	if (pkgs == null) return null;
	if (pkgs.length == 0) {
		// add additional tracing as this should not happen
		org.eclipse.jdt.internal.core.util.Util.log(
			new Status(
					IStatus.WARNING,
					JavaCore.PLUGIN_ID,
					"Searching for package " + getName() + " returns an empty array")); //$NON-NLS-1$ //$NON-NLS-2$
		return null;
	}
	return pkgs[0];
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:PackageBinding.java

示例6: compile

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的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

示例7: compileUnits

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的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

示例8: parseSources

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
@NonNull
private static Pair<Collection<CompilationUnitDeclaration>,INameEnvironment> parseSources(
        @NonNull List<File> sourcePaths,
        @NonNull List<String> classpath,
        @NonNull String encoding,
        long languageLevel)
        throws IOException {
    List<ICompilationUnit> sourceUnits = Lists.newArrayListWithExpectedSize(100);

    for (File source : gatherJavaSources(sourcePaths)) {
        char[] contents = Util.getFileCharContent(source, encoding);
        ICompilationUnit unit = new CompilationUnit(contents, source.getPath(), encoding);
        sourceUnits.add(unit);
    }

    Map<ICompilationUnit, CompilationUnitDeclaration> outputMap = Maps.newHashMapWithExpectedSize(
            sourceUnits.size());

    CompilerOptions options = EcjParser.createCompilerOptions();
    options.docCommentSupport = true; // So I can find @hide

    // Note: We can *not* set options.ignoreMethodBodies=true because it disables
    // type attribution!

    options.sourceLevel = languageLevel;
    options.complianceLevel = options.sourceLevel;
    // We don't generate code, but just in case the parser consults this flag
    // and makes sure that it's not greater than the source level:
    options.targetJDK = options.sourceLevel;
    options.originalComplianceLevel = options.sourceLevel;
    options.originalSourceLevel = options.sourceLevel;
    options.inlineJsrBytecode = true; // >= 1.5

    INameEnvironment environment = EcjParser.parse(options, sourceUnits, classpath,
            outputMap, null);
    Collection<CompilationUnitDeclaration> parsedUnits = outputMap.values();
    return Pair.of(parsedUnits, environment);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:ExtractAnnotationsDriver.java

示例9: NonGeneratingCompiler

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
public NonGeneratingCompiler(INameEnvironment environment, IErrorHandlingPolicy policy,
        CompilerOptions options, ICompilerRequestor requestor,
        IProblemFactory problemFactory,
        Map<ICompilationUnit, CompilationUnitDeclaration> units) {
    super(environment, policy, options, requestor, problemFactory, null, null);
    mUnits = units;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:EcjParser.java

示例10: resolveDocument

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的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

示例11: HierarchyResolver

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) {
	// create a problem handler with the 'exit after all problems' handling policy
	this.options = new CompilerOptions(settings);
	IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
	ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory);

	LookupEnvironment environment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment);
	environment.mayTolerateMissingType = true;
	setEnvironment(environment, builder);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:HierarchyResolver.java

示例12: validateImports

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * @see IEvaluationContext#validateImports(ICodeSnippetRequestor)
 */
public void validateImports(ICodeSnippetRequestor requestor) {

	checkBuilderState();
	INameEnvironment environment = null;
	try {
		this.context.evaluateImports(
			environment = getBuildNameEnvironment(),
			getInfrastructureEvaluationRequestor(requestor),
			getProblemFactory());
	} finally {
		if (environment != null) environment.cleanup();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:EvaluationContextWrapper.java

示例13: Evaluator

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * Creates a new evaluator.
 */
Evaluator(EvaluationContext context, INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) {
	this.context = context;
	this.environment = environment;
	this.options = options;
	this.requestor = requestor;
	this.problemFactory = problemFactory;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:Evaluator.java

示例14: evaluate

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * @see org.eclipse.jdt.core.eval.IEvaluationContext
 * @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed.
 */
public void evaluate(char[] codeSnippet, INameEnvironment environment, Map options, final IRequestor requestor, IProblemFactory problemFactory) throws InstallException {
	this.evaluate(
		codeSnippet,
		null,
		null,
		null,
		null,
		true,
		false,
		environment,
		options,
		requestor,
		problemFactory);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:EvaluationContext.java

示例15: evaluateVariables

import org.eclipse.jdt.internal.compiler.env.INameEnvironment; //导入依赖的package包/类
/**
 * @see org.eclipse.jdt.core.eval.IEvaluationContext
 * @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed.
 */
public void evaluateVariables(INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) throws InstallException {
	deployCodeSnippetClassIfNeeded(requestor);
	VariablesEvaluator evaluator = new VariablesEvaluator(this, environment, options, requestor, problemFactory);
	ClassFile[] classes = evaluator.getClasses();
	if (classes != null) {
		if (classes.length > 0) {
			// Sort classes so that enclosing types are cached before nested types
			// otherwise an AbortCompilation is thrown in 1.5 mode since the enclosing type
			// is needed to resolve a nested type
			Util.sort(classes, new Util.Comparer() {
				public int compare(Object a, Object b) {
					if (a == b) return 0;
					ClassFile enclosing = ((ClassFile) a).enclosingClassFile;
					while (enclosing != null) {
						if (enclosing == b)
							return 1;
						enclosing = enclosing.enclosingClassFile;
					}
					return -1;
				}
			});

			// Send classes
			if (!requestor.acceptClassFiles(classes, null)) {
				throw new InstallException();
			}

			// Remember that the variables have been installed
			int count = this.variableCount;
			GlobalVariable[] variablesCopy = new GlobalVariable[count];
			System.arraycopy(this.variables, 0, variablesCopy, 0, count);
			this.installedVars = new VariablesInfo(evaluator.getPackageName(), evaluator.getClassName(), classes, variablesCopy, count);
			VAR_CLASS_COUNTER++;
		}
		this.varsChanged = false;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:EvaluationContext.java


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