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


Java Diagnostic类代码示例

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


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

示例1: analyse

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Override
public void analyse(Script script, String codeName, String code) {
	List<Diagnostic> errors = super.getScriptErrors(script);
	if (errors.isEmpty()) {
		String msg = "expected errors in " + codeName + " but there was not a single one";
		if (this.logger.isDebugEnabled()) {
			StringBuilder sb = new StringBuilder(msg).append("\n");
			sb.append("========== " + codeName + " ==========\n");
			if (this.logCode) {
				sb.append(code).append("\n");
			}
			sb.append("========================================").append("\n");
			this.logger.debug(sb);
		}
		assertEquals(msg, code, codeName);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:NegativeAnalyser.java

示例2: getScriptErrors

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Override
protected List<Diagnostic> getScriptErrors(Script script) {
	EcoreUtil.resolveAll(script.eResource());
	List<Diagnostic> diagnostics = super.getScriptErrors(script);
	Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
	List<Diagnostic> result = Lists.<Diagnostic> newArrayList(Iterables.filter(diagnostics,
			ExceptionDiagnostic.class));
	while (expressions.hasNext()) {
		Expression expression = expressions.next();
		RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
		Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
		if (type.getRuleFailedException() != null) {
			Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
			if (!(cause instanceof RuleFailedException)) {
				if (cause instanceof Exception) {
					result.add(new ExceptionDiagnostic((Exception) cause));
				} else {
					throw new RuntimeException(cause);
				}
			}
		}
	}
	validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:ExceptionAnalyser.java

示例3: 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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:BuiltInTypeScopeTest.java

示例4: applyToModel

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Override
public void applyToModel(IResolvedTypes resolvedTypes) {
	Resource resource = getExpression().eResource();
	if (resource instanceof LazyLinkingResource) {
		LazyLinkingResource lazyLinkingResource = (LazyLinkingResource) resource;
		
		TypeAwareLinkingDiagnosticContext context = new TypeAwareLinkingDiagnosticContext(this, resolvedTypes);
		DiagnosticMessage message = lazyLinkingResource.getDiagnosticMessageProvider()
				.getUnresolvedProxyMessage(context);
		if (message != null) {
			List<Resource.Diagnostic> diagnostics = getDiagnosticList(lazyLinkingResource, message);
			Diagnostic diagnostic = createDiagnostic(message);
			diagnostics.add(diagnostic);
		}
		EObject referenced = (InternalEObject) getExpression().eGet(getReference(), false);
		lazyLinkingResource.markUnresolvable(referenced);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:AbstractUnresolvableReferenceWithNode.java

示例5: getResourceAndExpect

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
public final XtextResource getResourceAndExpect(InputStream in, URI uri, int expectedErrors) throws Exception {
	XtextResource resource = doGetResource(in, uri);
	checkNodeModel(resource);
	if (expectedErrors != UNKNOWN_EXPECTATION) {
		if (expectedErrors == EXPECT_ERRORS)
			assertFalse(Joiner.on('\n').join(resource.getErrors()), resource.getErrors().isEmpty());
		else
			assertEquals(Joiner.on('\n').join(resource.getErrors()), expectedErrors, resource.getErrors().size());
	}
	for(Diagnostic d: resource.getErrors()) {
		if (d instanceof ExceptionDiagnostic)
			fail(d.getMessage());
	}
	if (expectedErrors == 0 && resource.getContents().size() > 0 && shouldTestSerializer(resource)) {
		SerializerTestHelper tester = get(SerializerTestHelper.class);
		EObject obj = resource.getContents().get(0);
		tester.assertSerializeWithNodeModel(obj);
		tester.assertSerializeWithoutNodeModel(obj);
	}
	return resource;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:AbstractXtextTests.java

示例6: convertResourceDiagnostic

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Override
public void convertResourceDiagnostic(Diagnostic diagnostic, Severity severity,	IAcceptor<Issue> acceptor) {
	IssueImpl issue = new Issue.IssueImpl();
	issue.setSyntaxError(diagnostic instanceof XtextSyntaxDiagnostic);
	issue.setSeverity(severity);
	issue.setLineNumber(diagnostic.getLine());
	issue.setColumn(diagnostic.getColumn());
	issue.setMessage(diagnostic.getMessage());

	if (diagnostic instanceof org.eclipse.xtext.diagnostics.Diagnostic) {
		org.eclipse.xtext.diagnostics.Diagnostic xtextDiagnostic = (org.eclipse.xtext.diagnostics.Diagnostic) diagnostic;
		issue.setOffset(xtextDiagnostic.getOffset());
		issue.setLength(xtextDiagnostic.getLength());
	}
	if (diagnostic instanceof AbstractDiagnostic) {
		AbstractDiagnostic castedDiagnostic = (AbstractDiagnostic)diagnostic;
		issue.setUriToProblem(castedDiagnostic.getUriToProblem());
		issue.setCode(castedDiagnostic.getCode());
		issue.setData(castedDiagnostic.getData());
	}
	issue.setType(CheckType.FAST);
	acceptor.accept(issue);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:DiagnosticConverterImpl.java

示例7: getIssueData

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
/**
 * @since 2.4
 */
protected String[] getIssueData(org.eclipse.emf.common.util.Diagnostic diagnostic) {
	if (diagnostic instanceof AbstractValidationDiagnostic) {
		AbstractValidationDiagnostic diagnosticImpl = (AbstractValidationDiagnostic) diagnostic;
		return diagnosticImpl.getIssueData();
	} else {
		// replace any EObjects by their URIs
		EObject causer = getCauser(diagnostic);
		List<String> issueData = newArrayList();
		for (Object object : diagnostic.getData()) {
			if (object != causer && object instanceof EObject) {
				EObject eObject = (EObject)object;
				issueData.add(EcoreUtil.getURI(eObject).toString());
			} else if (object instanceof String) {
				issueData.add( (String) object);
			}
	    }
		return issueData.toArray(new String[issueData.size()]);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:DiagnosticConverterImpl.java

示例8: testAbstractLanguageToMetamodel

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Test public void testAbstractLanguageToMetamodel() throws Exception {
	XtextResource r = getResource("classpath:/" + AbstractTestLanguage.class.getName().replace('.', '/') + ".xtext");
	Grammar element = (Grammar) r.getParseResult().getRootASTElement();
	if (!r.getErrors().isEmpty()) {
		EList<Diagnostic> errors = r.getErrors();
		for (Diagnostic syntaxError : errors) {
			logger.debug(syntaxError.getMessage() + " - " + syntaxError.getLine());
		}
		fail(errors.toString());
	}
	List<TerminalRule> lexerRules = GrammarUtil.allTerminalRules(element);
	assertEquals(8, lexerRules.size());

	List<EPackage> list = Xtext2EcoreTransformer.doGetGeneratedPackages(element);
	assertNotNull(list);
	assertEquals(0, list.size());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:ToEcoreTrafoTest.java

示例9: parseScriptIntoXTextEObject

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
private XExpression parseScriptIntoXTextEObject(String scriptAsString) throws ScriptParsingException {
	Resource resource = resourceSet.createResource(computeUnusedUri(resourceSet)); // IS-A XtextResource
	try {
		resource.load(new StringInputStream(scriptAsString), resourceSet.getLoadOptions());
	} catch (IOException e) {
		throw new ScriptParsingException("Unexpected IOException; from close() of a String-based ByteArrayInputStream, no real I/O; how is that possible???", scriptAsString, e);
	}
	
	List<Diagnostic> errors = resource.getErrors();
	if (errors.size() != 0) {
		throw new ScriptParsingException("Failed to parse expression (due to managed SyntaxError/s)", scriptAsString).addDiagnosticErrors(errors);
	}
	
	EList<EObject> contents = resource.getContents();

	if (!contents.isEmpty()) {
		Iterable<Issue> validationErrors = getValidationErrors(contents.get(0));
		if(!validationErrors.iterator().hasNext()) {
			return (XExpression) contents.get(0);
		} else {
			throw new ScriptParsingException("Failed to parse expression (due to managed ValidationError/s)", scriptAsString).addValidationIssues(validationErrors);
		}
	} else {
		return null;
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:ScriptEngineImpl.java

示例10: doSignal

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Override
public void doSignal(List<Diagnostic> errors, int cursorColumn, int cursorLine) {
    for (Diagnostic e : errors) {
        if (e instanceof AbstractDiagnostic) {
            AbstractDiagnostic error = (AbstractDiagnostic) e;

            int errorLine = error.getLine();
            int errorBegin = error.getColumn();
            int errorLength = error.getLength();

            if (errorLine != cursorLine) {
                return;
            }
            doSignal(cursorColumn, cursorLine, errorBegin, errorLength);
        }
    }
    oldColumn = cursorColumn;
    oldLine = cursorLine;
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:20,代码来源:AreaErrorIndicator.java

示例11: handleCursorPositionChanged

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
@Override
protected void handleCursorPositionChanged() {
    super.handleCursorPositionChanged();
    IXtextDocument document = getDocument();
    CooperateXtextDocument cooperateXtextDocument = document.getAdapter(CooperateXtextDocument.class);
    if (cooperateXtextDocument.getResource() == null) {
        return;
    }
    EList<Diagnostic> errors = cooperateXtextDocument.getResource().getErrors();

    if (ErrorIndicatorPreferenceHandler.INSTANCE.getErrorAreaIndicatorSetting()) {
        areaErrorIndicator.doSignal(errors, getCursorPosition());
    }
    if (ErrorIndicatorPreferenceHandler.INSTANCE.getErrorLineIndicatorSetting()) {
        lineErrorIndicator.doSignal(errors, getCursorPosition());
    }
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:CooperateCDOXtextEditor.java

示例12: ATLModel

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
public ATLModel(Resource original, String fileLocation, boolean keepCopier) { 
	DynamicToStaticCopier copier = new DynamicToStaticCopier(fileLocation);
	ResourceSet rs = original.getResourceSet();
	if ( rs == null ) {
		rs = new ResourceSetImpl();
	}
	resource = rs.createResource(URI.createURI("trafo.ext"));		
	copier.copyResource(original, resource);

	if ( keepCopier ) {
		this.copierTrace = new ATLModelTrace(copier);
	}
	
	mainFileLocation = fileLocation;
	fileLocations.add(fileLocation);
	
	errors = new ErrorModel(resource);
	typing = new TypingModel(resource);
	
	hasSyntaxErrors = original.getErrors().size() > 0;
	if ( hasSyntaxErrors ) {
		for (Diagnostic diagnostic : original.getErrors()) {
			errors.signalParseError(diagnostic.getLocation(), diagnostic.getMessage(), diagnostic.getLine() + ":" + diagnostic.getColumn());
		}
	}
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:27,代码来源:ATLModel.java

示例13: extendWithPreconditions

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
public static void extendWithPreconditions(ATLModel atlModel, List<String> preconditions, IAtlFileLoader loader) throws PreconditionParseError {
	if ( preconditions.size() > 0 ) {
		String text = "library preconditions;";
		int idx = 0;
		for (String pre : preconditions) {
			text = text + "\n-- @precondition \n" + "helper def: precondition_" + idx + " : Boolean = " + pre + ";"; 
			idx++;
		}
		
		Resource r = loader.load(text);
		String[] messages = new String[r.getErrors().size()];
		int i = 0;
		for (Diagnostic diagnostic : r.getErrors()) {
			messages[i] = diagnostic.toString();
			i++;
		}
		
		if ( r.getErrors().size() > 0 )
			throw new PreconditionParseError(messages);
		
		atlModel.extendWithPreconditions(r);
	}
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:24,代码来源:AnalyserUtils.java

示例14: removeAcceptedErrors

import org.eclipse.emf.ecore.resource.Resource.Diagnostic; //导入依赖的package包/类
private void removeAcceptedErrors(EList<Diagnostic> errors) {
	Iterator<Diagnostic> iterator = errors.iterator();
	while (iterator.hasNext()) {
		Resource.Diagnostic diagnostic = iterator.next();

		// removes errors for projectState and changePackage references in versions.
		if (diagnostic instanceof FeatureNotFoundException) {
			FeatureNotFoundException featureNotFoundException = (FeatureNotFoundException) diagnostic;
			if (featureNotFoundException.getObject() instanceof Version) {
				if (featureNotFoundException.getName().equals("projectState")
					|| featureNotFoundException.getName().equals("changes")) {
					iterator.remove();
				}
			}
		}
	}
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:18,代码来源:EmfStoreValidator.java

示例15: 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);
    }
    
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:ParseApiDesc.java


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