• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultProblem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convertRange

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
@SuppressWarnings("restriction")
private static Range convertRange(IProblem problem) {
	Position start = new Position();
	Position end = new Position();

	start.setLine(problem.getSourceLineNumber()-1);// VSCode is 0-based
	end.setLine(problem.getSourceLineNumber()-1);
	if(problem instanceof DefaultProblem){
		DefaultProblem dProblem = (DefaultProblem)problem;
		start.setCharacter(dProblem.getSourceColumnNumber() - 1);
		int offset = 0;
		if (dProblem.getSourceStart() != -1 && dProblem.getSourceEnd() != -1) {
			offset = dProblem.getSourceEnd() - dProblem.getSourceStart() + 1;
		}
		end.setCharacter(dProblem.getSourceColumnNumber() - 1 + offset);
	}
	return new Range(start, end);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:DiagnosticsHandler.java


示例2: appendProblem

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
public static void appendProblem(
    StringBuffer problems, IProblem problem, char[] source, int problemCount) {
  problems.append(problemCount + (problem.isError() ? ". ERROR" : ". WARNING"));
  problems.append(" in " + new String(problem.getOriginatingFileName()));
  if (source != null) {
    problems.append(((DefaultProblem) problem).errorReportSource(source));
  }
  problems.append("\n");
  problems.append(problem.getMessage());
  problems.append("\n");
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:Utils.java


示例3: appendProblem

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
public static void appendProblem(StringBuffer problems, IProblem problem, char[] source, int problemCount) {
	problems.append(problemCount + (problem.isError() ? ". ERROR" : problem.isWarning() ? ". WARNING" : ". INFO"));
	problems.append(" in " + new String(problem.getOriginatingFileName()));
	if (source != null) {
		problems.append(((DefaultProblem)problem).errorReportSource(source));
	}
	problems.append("\n");
	problems.append(problem.getMessage());
	problems.append("\n");
}
 
开发者ID:vogellacompany,项目名称:codemodify,代码行数:11,代码来源:Util.java


示例4: writeProblemLog

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
public void writeProblemLog(Appendable out) throws IOException {
    out.append("----------\n");
    if (problems != null) {
        int errorCount = 0;
        for (CompilationResult r : problems) {
            for (CategorizedProblem p : r.getAllProblems()) {
                out.append(Integer.toString(++errorCount));
                out.append(". ");
                if (p.isError()) {
                    out.append("ERROR in ");
                } else if (p.isWarning()) {
                    out.append("WARNING in ");
                } else {
                    out.append("Problem in ");
                }
                out.append(new String(p.getOriginatingFileName()));

                String errorReportSource = 
                    ((DefaultProblem) p).errorReportSource(
                            r.compilationUnit.getContents());

                out.append(errorReportSource);
                out.append("\n");
                out.append(p.getMessage());
                out.append("\n----------\n");
            }
        }
    }
}
 
开发者ID:CoCoViLa,项目名称:CoCoViLa,代码行数:30,代码来源:CCL.java


示例5: appendProblem

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
public static void appendProblem(StringBuffer problems, IProblem problem, char[] source, int problemCount) {
    problems.append(problemCount + (problem.isError() ? ". ERROR" : ". WARNING"));
    problems.append(" in " + new String(problem.getOriginatingFileName()));
    if (source != null) {
        problems.append(((DefaultProblem)problem).errorReportSource(source));
    }
    problems.append("\n");
    problems.append(problem.getMessage());
    problems.append("\n");
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:11,代码来源:Util.java


示例6: loggingExtraProblems

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
@Override
protected void loggingExtraProblems() {
	super.loggingExtraProblems();
	for (@SuppressWarnings("rawtypes")
		Iterator iterator = this.extraProblems.iterator(); iterator.hasNext(); ) {
		final CategorizedProblem problem = (CategorizedProblem) iterator.next();
		if (this.diagnosticListener != null) {
			this.diagnosticListener.report(new Diagnostic<JavaFileObject>() {
				@Override
				public String getCode() {
					return null;
				}
				@Override
				public long getColumnNumber() {
					if (problem instanceof DefaultProblem) {
						return ((DefaultProblem) problem).column;
					}
					return Diagnostic.NOPOS;
				}
				@Override
				public long getEndPosition() {
					if (problem instanceof DefaultProblem) {
						return ((DefaultProblem) problem).getSourceEnd();
					}
					return Diagnostic.NOPOS;
				}
				@Override
				public Kind getKind() {
					if (problem.isError()) {
						return Diagnostic.Kind.ERROR;
					}
					if (problem.isWarning()) {
						return Diagnostic.Kind.WARNING;
					}
					return Diagnostic.Kind.OTHER;
				}
				@Override
				public long getLineNumber() {
					if (problem instanceof DefaultProblem) {
						return ((DefaultProblem) problem).getSourceLineNumber();
					}
					return Diagnostic.NOPOS;
				}
				@Override
				public String getMessage(Locale locale) {
					return problem.getMessage();
				}
				@Override
				public long getPosition() {
					if (problem instanceof DefaultProblem) {
						return ((DefaultProblem) problem).getSourceStart();
					}
					return Diagnostic.NOPOS;
				}
				@Override
				public JavaFileObject getSource() {
					if (problem instanceof DefaultProblem) {
						File f = new File(new String(((DefaultProblem) problem).getOriginatingFileName()));
						if (f.exists()) {
							return new EclipseFileObject(null, f.toURI(), JavaFileObject.Kind.SOURCE, null);
						}
						return null;
					}
					return null;
				}
				@Override
				public long getStartPosition() {
					return getPosition();
				}
			});
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:74,代码来源:EclipseCompilerImpl.java


示例7: getProblemLog

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
/**
 * Returns the compilation errors / warnings for the given CompilationResult.
 *
 * @param compilationResult the compilation result
 * @param showCategory
 * @param showWarningToken
 * @return String the problem log
 */
public static String getProblemLog(CompilationResult compilationResult, boolean showCategory, boolean showWarningToken) {
	StringBuffer buffer = new StringBuffer(100);
	if (compilationResult.hasProblems() || compilationResult.hasTasks()) {
		CategorizedProblem[] problems = compilationResult.getAllProblems();
		int count = problems.length;
		int problemCount = 0;
		char[] unitSource = compilationResult.compilationUnit.getContents();
		for (int i = 0; i < count; i++) {
			DefaultProblem problem = (DefaultProblem) problems[i];
			if (problem != null) {
				if (problemCount == 0)
					buffer.append("----------\n");
				problemCount++;
				buffer.append(problemCount + (problem.isError() ? ". ERROR" : problem.isWarning() ? ". WARNING" : ". INFO"));
				buffer.append(" in " + new String(problem.getOriginatingFileName()).replace('/', '\\'));
				try {
					buffer.append(problem.errorReportSource(unitSource));
					buffer.append("\n");
					if (showCategory) {
						String category = problem.getInternalCategoryMessage();
						if (category != null) {
							buffer.append("[@cat:").append(category).append("] ");
						}
					}
					if (showWarningToken) {
						int irritant = ProblemReporter.getIrritant(problem.getID());
						if (irritant != 0) {
							String warningToken = CompilerOptions.warningTokenFromIrritant(irritant);
							if (warningToken != null) {
								buffer.append("[@sup:").append(warningToken).append("] ");
							}
						}
					}
					buffer.append(problem.getMessage());
					buffer.append("\n");
				} catch (Exception e) {
				}
				buffer.append("----------\n");
			}
		}
	}
	return buffer.toString();
}
 
开发者ID:vogellacompany,项目名称:codemodify,代码行数:52,代码来源:Util.java


示例8: acceptResult

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
@Override
public void acceptResult(CompilationResult result) {
  if (result == null) {
    return; // ah?
  }

  final String sourceName = new String(result.getFileName());
  final File sourceFile = new File(sourceName);

  Resource<File> input = context.getProcessedSource(sourceFile);

  // track type references
  if (result.rootReferences != null && result.qualifiedReferences != null && result.simpleNameReferences != null) {
    context.setAttribute(input.getResource(), ATTR_REFERENCES, new ReferenceCollection(result.rootReferences, result.qualifiedReferences, result.simpleNameReferences));
  }

  if (result.hasProblems()) {
    for (CategorizedProblem problem : result.getProblems()) {
      if (problem.isError() || isShowWarnings()) {
        MessageSeverity severity = problem.isError() ? MessageSeverity.ERROR : MessageSeverity.WARNING;
        input.addMessage(problem.getSourceLineNumber(), ((DefaultProblem) problem).column, problem.getMessage(), severity, null /* cause */);
      }
    }
  }

  try {
    if (!result.hasErrors() && !isProcOnly()) {
      for (ClassFile classFile : result.getClassFiles()) {
        char[] filename = classFile.fileName();
        int length = filename.length;
        char[] relativeName = new char[length + 6];
        System.arraycopy(filename, 0, relativeName, 0, length);
        System.arraycopy(SuffixConstants.SUFFIX_class, 0, relativeName, length, 6);
        CharOperation.replace(relativeName, '/', File.separatorChar);
        String relativeStringName = new String(relativeName);
        writeClassFile(input, relativeStringName, classFile);
      }
    }
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  // XXX double check affected sources are recompiled when this source has errors
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:45,代码来源:CompilerJdt.java


示例9: getExtraMarkerAttributeValues

import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; //导入依赖的package包/类
/**
 * Returns the respective values for the extra marker attributes associated to this problem when persisted into
 * a marker by the JavaBuilder. Each value must correspond to a matching attribute name, as defined by
 * {@link #getExtraMarkerAttributeNames()}.
 * The values must be eligible for marker creation, as defined by <code> IMarker#setAttributes(String[], Object[])}.
 * @return the values of the corresponding extra marker attributes
 */
public Object[] getExtraMarkerAttributeValues() {
	return DefaultProblem.EMPTY_VALUES;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:CategorizedProblem.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FsServerDefaultsProto类代码示例发布时间:2022-05-22
下一篇:
Java DocTreePathScanner类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap