本文整理汇总了Java中org.eclipse.emf.ecore.resource.Resource.Diagnostic.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Diagnostic.getMessage方法的具体用法?Java Diagnostic.getMessage怎么用?Java Diagnostic.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.resource.Resource.Diagnostic
的用法示例。
在下文中一共展示了Diagnostic.getMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadingBuiltInTypes
import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入方法依赖的package包/类
@SuppressWarnings("javadoc")
@Test
public void testLoadingBuiltInTypes() {
BuiltInTypeScope scope = BuiltInTypeScope.get(resourceSet);
IEObjectDescription anyType = scope.getSingleElement(QualifiedName.create("any"));
Assert.assertNotNull(anyType);
String s = "";
for (Resource resource : resourceSet.getResources()) {
if (resource.getErrors().size() > 0) {
for (Diagnostic d : resource.getErrors()) {
s += "\n " + d.getMessage() + " at " + resource.getURI() + ":" + d.getLine();
}
}
}
Assert.assertEquals("Resources definine built-in types must have no error."
, "", s);
}
示例2: showErrors
import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入方法依赖的package包/类
public void showErrors(XtextResource resource) {
String error = "";
if (! resource.getErrors().isEmpty()) {
error += "### Parse: \n";
for (Diagnostic d : resource.getErrors()) {
error += d.getMessage() + " in " + d.getLine() + "\n";
}
}
if ( error.length() == 0 ) {
System.out.println("Ok : " + resource.getContents());
} else {
System.out.println(error);
}
}
示例3: checkErrorAndGetErrorList
import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入方法依赖的package包/类
/**
* To detect if there is error in SysML file, and return a error list
*
* @param file
* file is the SysML which is going to test
* @param resourceSet
* resourceSet is the EMF resourceSet
* @return errorList errorList: a list of errors
* @throws IOException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
*/
public ArrayList<ErrorInfo> checkErrorAndGetErrorList(File file, ResourceSet resourceSet)
throws IOException, ParserConfigurationException, SAXException, TransformerException {
String method = "SysMLChecker_getErrorList(): ";
long startTime = System.currentTimeMillis();
MyLog.info(method + "start");
URI uri = URI.createFileURI(file.getPath());
ArrayList<ErrorInfo> errorLog = new ArrayList<ErrorInfo>();
// load the resource into memory
@SuppressWarnings("unused")
Model umlModel = UML2Util.load(resourceSet, uri, UMLPackage.Literals.MODEL);
// get all error list
for (Resource umlResourceImpl : resourceSet.getResources()) {
if (!umlResourceImpl.getErrors().isEmpty()) {
for (Diagnostic error : umlResourceImpl.getErrors()) {
ErrorInfo errorInfo = new ErrorInfo(error.getLine(), error.getColumn(), error.getMessage());
if (!error.getMessage().contains("org.xml.sax.SAXParseException"))
// filter the sax exception errors
errorLog.add(errorInfo);
}
}
}
umlModel = null;
MyLog.info(method + "end with " + (System.currentTimeMillis() - startTime) + " millisecond");
MyLog.info();
return errorLog;
}
示例4: checkResourceErrors
import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入方法依赖的package包/类
private boolean checkResourceErrors(Resource resource) {
if (resource.getErrors().isEmpty())
{
return true;
}
else
{
boolean valid = true;
for (Diagnostic error : resource.getErrors())
{
// exception: if errors only concern beginning and end of file
if (error.getMessage() != null
&& error.getMessage().equals("missing EOF at '\\r'"))
{
// nothing;
}
else if (error.getMessage() != null
&& error.getMessage().equals("extraneous input '\\r' expecting '§'"))
{
// nothing
}
else if (error.getMessage() != null
&& error.getMessage().equals("mismatched input '<EOF>' expecting '§'"))
{
// nothing
}
else
{
valid = false;
}
}
return valid;
}
}