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


Java CategorizedProblem.getSourceLineNumber方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.compiler.CategorizedProblem.getSourceLineNumber方法的典型用法代码示例。如果您正苦于以下问题:Java CategorizedProblem.getSourceLineNumber方法的具体用法?Java CategorizedProblem.getSourceLineNumber怎么用?Java CategorizedProblem.getSourceLineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.compiler.CategorizedProblem的用法示例。


在下文中一共展示了CategorizedProblem.getSourceLineNumber方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: report

import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
protected void report(Environment environment, CategorizedProblem problem) {
    if (problem == null) {
        throw new IllegalArgumentException("problem cannot be null");
    }

    File file = new File(new String(problem.getOriginatingFileName()));
    String filename = file.getAbsolutePath();

    String message = problem.getMessage() + " at " + filename + ":"
            + problem.getSourceLineNumber();

    if (problem.isError()) {
        if (!environment.getNoClasspath()) {
            // by default, compilation errors are notified as exception
            throw new ModelBuildingException(message);
        }
    }

}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:20,代码来源:DiversityCompiler.java

示例2: computePriority

import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
private int computePriority(CategorizedProblem problem){
	final int P_STATIC = 10000;
	final int P_OUTSIDE_METHOD = 40000;
	final int P_FIRST_ERROR = 20000;
	final int P_ERROR = 100000;

	int priority = 10000 - problem.getSourceLineNumber(); // early problems first
	if (priority < 0) priority = 0;
	if (problem.isError()){
		priority += P_ERROR;
	}
	ReferenceContext context = this.problemsMap == null ? null : (ReferenceContext) this.problemsMap.get(problem);
	if (context != null){
		if (context instanceof AbstractMethodDeclaration){
			AbstractMethodDeclaration method = (AbstractMethodDeclaration) context;
			if (method.isStatic()) {
				priority += P_STATIC;
			}
		} else {
			priority += P_OUTSIDE_METHOD;
		}
		if (this.firstErrors.contains(problem)){ // if context is null, firstErrors is null too
		  priority += P_FIRST_ERROR;
	    }
	} else {
		priority += P_OUTSIDE_METHOD;
	}
	return priority;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:CompilationResult.java

示例3: addProblemClinit

import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
 * INTERNAL USE-ONLY
 * Generate the byte for a problem clinit method info that correspond to a boggus method.
 *
 * @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
 */
public void addProblemClinit(CategorizedProblem[] problems) {
	generateMethodInfoHeaderForClinit();
	// leave two spaces for the number of attributes
	this.contentsOffset -= 2;
	int attributeOffset = this.contentsOffset;
	this.contentsOffset += 2;
	int attributeNumber = 0;

	int codeAttributeOffset = this.contentsOffset;
	generateCodeAttributeHeader();
	this.codeStream.resetForProblemClinit(this);
	String problemString = "" ; //$NON-NLS-1$
	int problemLine = 0;
	if (problems != null) {
		int max = problems.length;
		StringBuffer buffer = new StringBuffer(25);
		int count = 0;
		for (int i = 0; i < max; i++) {
			CategorizedProblem problem = problems[i];
			if ((problem != null) && (problem.isError())) {
				buffer.append("\t"  +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
				count++;
				if (problemLine == 0) {
					problemLine = problem.getSourceLineNumber();
				}
				problems[i] = null;
			}
		} // insert the top line afterwards, once knowing how many problems we have to consider
		if (count > 1) {
			buffer.insert(0, Messages.compilation_unresolvedProblems);
		} else {
			buffer.insert(0, Messages.compilation_unresolvedProblem);
		}
		problemString = buffer.toString();
	}

	// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
	this.codeStream.generateCodeAttributeForProblemMethod(problemString);
	attributeNumber++; // code attribute
	completeCodeAttributeForClinit(
		codeAttributeOffset,
		problemLine);
	if (this.contentsOffset + 2 >= this.contents.length) {
		resizeContents(2);
	}
	this.contents[attributeOffset++] = (byte) (attributeNumber >> 8);
	this.contents[attributeOffset] = (byte) attributeNumber;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:55,代码来源:ClassFile.java

示例4: addProblemConstructor

import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
 * INTERNAL USE-ONLY
 * Generate the byte for a problem method info that correspond to a boggus constructor.
 *
 * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
 * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
 * @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
 */
public void addProblemConstructor(
	AbstractMethodDeclaration method,
	MethodBinding methodBinding,
	CategorizedProblem[] problems) {
	
	if (methodBinding.declaringClass.isInterface()) {
		method.abort(ProblemSeverities.AbortType, null);
	}

	// always clear the strictfp/native/abstract bit for a problem method
	generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(ClassFileConstants.AccStrictfp | ClassFileConstants.AccNative | ClassFileConstants.AccAbstract));
	int methodAttributeOffset = this.contentsOffset;
	int attributesNumber = generateMethodInfoAttributes(methodBinding);

	// Code attribute
	attributesNumber++;
	int codeAttributeOffset = this.contentsOffset;
	generateCodeAttributeHeader();
	this.codeStream.reset(method, this);
	String problemString = "" ; //$NON-NLS-1$
	int problemLine = 0;
	if (problems != null) {
		int max = problems.length;
		StringBuffer buffer = new StringBuffer(25);
		int count = 0;
		for (int i = 0; i < max; i++) {
			CategorizedProblem problem = problems[i];
			if ((problem != null) && (problem.isError())) {
				buffer.append("\t"  +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
				count++;
				if (problemLine == 0) {
					problemLine = problem.getSourceLineNumber();
				}
			}
		} // insert the top line afterwards, once knowing how many problems we have to consider
		if (count > 1) {
			buffer.insert(0, Messages.compilation_unresolvedProblems);
		} else {
			buffer.insert(0, Messages.compilation_unresolvedProblem);
		}
		problemString = buffer.toString();
	}

	// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
	this.codeStream.generateCodeAttributeForProblemMethod(problemString);
	completeCodeAttributeForProblemMethod(
		method,
		methodBinding,
		codeAttributeOffset,
		((SourceTypeBinding) methodBinding.declaringClass)
			.scope
			.referenceCompilationUnit()
			.compilationResult
			.getLineSeparatorPositions(),
		problemLine);
	completeMethodInfo(methodBinding, methodAttributeOffset, attributesNumber);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:66,代码来源:ClassFile.java

示例5: addProblemMethod

import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
 * INTERNAL USE-ONLY
 * Generate the byte for a problem method info that correspond to a boggus method.
 *
 * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
 * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
 * @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
 */
public void addProblemMethod(
	AbstractMethodDeclaration method,
	MethodBinding methodBinding,
	CategorizedProblem[] problems) {
	if (methodBinding.isAbstract() && methodBinding.declaringClass.isInterface()) {
		method.abort(ProblemSeverities.AbortType, null);
	}
	// always clear the strictfp/native/abstract bit for a problem method
	generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(ClassFileConstants.AccStrictfp | ClassFileConstants.AccNative | ClassFileConstants.AccAbstract));
	int methodAttributeOffset = this.contentsOffset;
	int attributesNumber = generateMethodInfoAttributes(methodBinding);

	// Code attribute
	attributesNumber++;

	int codeAttributeOffset = this.contentsOffset;
	generateCodeAttributeHeader();
	this.codeStream.reset(method, this);
	String problemString = "" ; //$NON-NLS-1$
	int problemLine = 0;
	if (problems != null) {
		int max = problems.length;
		StringBuffer buffer = new StringBuffer(25);
		int count = 0;
		for (int i = 0; i < max; i++) {
			CategorizedProblem problem = problems[i];
			if ((problem != null)
				&& (problem.isError())
				&& (problem.getSourceStart() >= method.declarationSourceStart)
				&& (problem.getSourceEnd() <= method.declarationSourceEnd)) {
				buffer.append("\t"  +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
				count++;
				if (problemLine == 0) {
					problemLine = problem.getSourceLineNumber();
				}
				problems[i] = null;
			}
		} // insert the top line afterwards, once knowing how many problems we have to consider
		if (count > 1) {
			buffer.insert(0, Messages.compilation_unresolvedProblems);
		} else {
			buffer.insert(0, Messages.compilation_unresolvedProblem);
		}
		problemString = buffer.toString();
	}

	// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
	this.codeStream.generateCodeAttributeForProblemMethod(problemString);
	completeCodeAttributeForProblemMethod(
		method,
		methodBinding,
		codeAttributeOffset,
		((SourceTypeBinding) methodBinding.declaringClass)
			.scope
			.referenceCompilationUnit()
			.compilationResult
			.getLineSeparatorPositions(),
		problemLine);
	completeMethodInfo(methodBinding, methodAttributeOffset, attributesNumber);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:69,代码来源:ClassFile.java

示例6: addProblemConstructor

import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
 * INTERNAL USE-ONLY
 * Generate the byte for a problem method info that correspond to a boggus constructor.
 *
 * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
 * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
 * @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
 */
public void addProblemConstructor(
	AbstractMethodDeclaration method,
	MethodBinding methodBinding,
	CategorizedProblem[] problems) {

	// always clear the strictfp/native/abstract bit for a problem method
	generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(ClassFileConstants.AccStrictfp | ClassFileConstants.AccNative | ClassFileConstants.AccAbstract));
	int methodAttributeOffset = this.contentsOffset;
	int attributesNumber = generateMethodInfoAttributes(methodBinding);

	// Code attribute
	attributesNumber++;
	int codeAttributeOffset = this.contentsOffset;
	generateCodeAttributeHeader();
	this.codeStream.reset(method, this);
	String problemString = "" ; //$NON-NLS-1$
	int problemLine = 0;
	if (problems != null) {
		int max = problems.length;
		StringBuffer buffer = new StringBuffer(25);
		int count = 0;
		for (int i = 0; i < max; i++) {
			CategorizedProblem problem = problems[i];
			if ((problem != null) && (problem.isError())) {
				buffer.append("\t"  +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
				count++;
				if (problemLine == 0) {
					problemLine = problem.getSourceLineNumber();
				}
			}
		} // insert the top line afterwards, once knowing how many problems we have to consider
		if (count > 1) {
			buffer.insert(0, Messages.compilation_unresolvedProblems);
		} else {
			buffer.insert(0, Messages.compilation_unresolvedProblem);
		}
		problemString = buffer.toString();
	}

	// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
	this.codeStream.generateCodeAttributeForProblemMethod(problemString);
	completeCodeAttributeForProblemMethod(
		method,
		methodBinding,
		codeAttributeOffset,
		((SourceTypeBinding) methodBinding.declaringClass)
			.scope
			.referenceCompilationUnit()
			.compilationResult
			.getLineSeparatorPositions(),
		problemLine);
	completeMethodInfo(methodBinding, methodAttributeOffset, attributesNumber);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:62,代码来源:ClassFile.java


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