本文整理汇总了Java中org.eclipse.xtext.diagnostics.Diagnostic类的典型用法代码示例。如果您正苦于以下问题:Java Diagnostic类的具体用法?Java Diagnostic怎么用?Java Diagnostic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Diagnostic类属于org.eclipse.xtext.diagnostics包,在下文中一共展示了Diagnostic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUnresolved_02
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Test
public void testUnresolved_02() {
Type type = getContext();
INode nameNode = NodeModelUtils.findNodesForFeature(type, ImportedURIPackage.Literals.TYPE__NAME).get(0);
resolve(type, "BlaBlaBla", nameNode.getOffset(), nameNode.getLength());
Resource resource = type.eResource();
assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(nameNode, nameNode.getOffset());
Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0);
assertEquals(nameNode.getOffset(), diagnostic.getOffset());
assertEquals(nameNode.getLength(), diagnostic.getLength());
assertEquals(lineAndColumn.getLine(), diagnostic.getLine());
assertEquals(lineAndColumn.getColumn(), diagnostic.getColumn());
assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage());
}
示例2: getResolutions
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Override
public List<IssueResolution> getResolutions(Issue issue) {
StopWatch stopWatch = new StopWatch(logger);
try {
if (Diagnostic.LINKING_DIAGNOSTIC.equals(issue.getCode())) {
List<IssueResolution> result = new ArrayList<IssueResolution>();
result.addAll(getResolutionsForLinkingIssue(issue));
result.addAll(super.getResolutions(issue));
return result;
} else
return super.getResolutions(issue);
} finally {
stopWatch.resetAndLog("#getResolutions");
}
}
示例3: convertFacets
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
private void convertFacets(final HeadlessExperiment stm, final ISyntacticElement elt,
final Set<Diagnostic> errors) {
final SymbolProto p = DescriptionFactory.getProto(EXPERIMENT, null);
for (final Facet f : EGaml.getFacetsOf(stm)) {
final String fname = EGaml.getKeyOf(f);
// We compute (and convert) the expression attached to the facet
final boolean label = p == null ? false : p.isLabel(fname);
final IExpressionDescription fexpr = convExpr(f, label, errors);
addFacet(elt, fname, fexpr, errors);
}
final IExpressionDescription ed = findExpr(stm, errors);
addFacet(elt, NAME, ed, errors);
addFacet(elt, TITLE, ed, errors);
if (!elt.hasFacet(TYPE))
addFacet(elt, TYPE, convertToLabel(null, HEADLESS_UI), errors);
}
示例4: convExpr
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
private final IExpressionDescription convExpr(final Facet facet, final boolean label,
final Set<Diagnostic> errors) {
if (facet != null) {
final Expression expr = facet.getExpr();
if (expr == null && facet.getBlock() != null) {
final Block b = facet.getBlock();
final ISyntacticElement elt =
SyntacticFactory.create(ACTION, new Facets(NAME, SYNTHETIC + SYNTHETIC_ACTION++), true);
convertBlock(elt, b, errors);
return convExpr(elt, errors);
}
if (expr != null) { return label ? convertToLabel(expr, EGaml.getKeyOf(expr)) : convExpr(expr, errors); }
final String name = facet.getName();
// TODO Verify the use of "facet"
if (name != null) { return convertToLabel(null, name); }
}
return null;
}
示例5: getUnresolvedProxyMessage
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context) {
EReference _reference = context.getReference();
final EClass referenceType = _reference.getEReferenceType();
String linkText = "";
try {
String _linkText = context.getLinkText();
linkText = _linkText;
} catch (final Throwable _t) {
if (_t instanceof IllegalNodeException) {
final IllegalNodeException e = (IllegalNodeException)_t;
INode _node = e.getNode();
String _text = _node.getText();
linkText = _text;
} else {
throw Exceptions.sneakyThrow(_t);
}
}
String _name = referenceType.getName();
String _plus = ("Couldn\'t resolve reference to " + _name);
String _plus_1 = (_plus + " \'");
String _plus_2 = (_plus_1 + linkText);
final String msg = (_plus_2 + "\'.");
String _name_1 = referenceType.getName();
DiagnosticMessage _diagnosticMessage = new DiagnosticMessage(msg, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC, _name_1, linkText);
return _diagnosticMessage;
}
示例6: selectionOnPrimitiveType
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Test
public void selectionOnPrimitiveType() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class A {");
_builder.newLine();
_builder.append("\t");
_builder.append("A m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return \"a\".m();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
SJProgram _parse = this._parseHelper.parse(_builder);
EClass _sJMemberSelection = SmallJavaPackage.eINSTANCE.getSJMemberSelection();
this._validationTestHelper.assertError(_parse, _sJMemberSelection,
Diagnostic.LINKING_DIAGNOSTIC,
"Couldn\'t resolve reference to SJMember \'m\'");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例7: createMissingEntity
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Fix(Diagnostic.LINKING_DIAGNOSTIC)
public void createMissingEntity(final Issue issue, final IssueResolutionAcceptor acceptor) {
final ISemanticModification _function = new ISemanticModification() {
@Override
public void apply(final EObject element, final IModificationContext context) throws Exception {
Entity _containerOfType = EcoreUtil2.<Entity>getContainerOfType(element, Entity.class);
IXtextDocument _xtextDocument = context.getXtextDocument();
Integer _offset = issue.getOffset();
Integer _length = issue.getLength();
String _get = _xtextDocument.get((_offset).intValue(), (_length).intValue());
EntitiesModelUtil.addEntityAfter(_containerOfType, _get);
}
};
acceptor.accept(issue,
"Create missing entity",
"Create missing entity",
"Entity.gif", _function);
}
示例8: createMissingEntity
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Fix(Diagnostic.LINKING_DIAGNOSTIC)
public void createMissingEntity(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue,
"Create missing entity", // label
"Create missing entity", // description
"Entity.gif", // icon
new ISemanticModification() {
public void apply(EObject element, IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
String missingEntityName = xtextDocument.get(issue.getOffset(), issue.getLength());
Entity newEntity = EntitiesFactory.eINSTANCE.createEntity();
newEntity.setName(missingEntityName);
Entity currentEntity = EcoreUtil2.getContainerOfType(element, Entity.class);
Model model = (Model) currentEntity.eContainer();
model.getEntities().add(model.getEntities().indexOf(currentEntity)+1, newEntity);
}
}
);
}
开发者ID:LorenzoBettini,项目名称:packtpub-xtext-book-examples,代码行数:20,代码来源:EntitiesJavaQuickfixProvider.java
示例9: testForwardReference
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Test
public void testForwardReference() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("val j = i + 1 // forward reference");
_builder.newLine();
_builder.append("val i = 10");
_builder.newLine();
ExpressionsModel _parse = this._parseHelper.parse(_builder);
EClass _xFeatureCall = XbasePackage.eINSTANCE.getXFeatureCall();
this._validationTestHelper.assertError(_parse, _xFeatureCall,
Diagnostic.LINKING_DIAGNOSTIC,
"Couldn\'t resolve reference to JvmIdentifiableElement \'i\'");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例10: testNoOperationFound
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Test public void testNoOperationFound() throws Exception {
XAnnotation annotation = annotation("@testdata.Annotation2(toString = true)", false);
validator.assertNoError(annotation, IssueCodes.INCOMPATIBLE_TYPES);
// TODO use better error message like in Java (e.g. Annotation A does not define an attribute b)
validator.assertError(annotation, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR, Diagnostic.LINKING_DIAGNOSTIC);
validator.assertError(annotation, XAnnotationsPackage.Literals.XANNOTATION, IssueCodes.ANNOTATIONS_MISSING_ATTRIBUTE_DEFINITION, "attribute 'value'");
}
示例11: consume
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
public void consume(Diagnostic diagnostic) {
final Pair<Integer, Integer> newRange = Tuples.create(diagnostic.getOffset(), diagnostic.getLength());
if (coveredNodes.add(newRange)) {
boolean changed = this.diagnostics.add(diagnostic);
diagnosticsConsumed |= changed;
}
}
示例12: getUnresolvedProxyMessage
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Override
public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) {
EClass referenceType = context.getReference().getEReferenceType();
String linkText = "";
try {
linkText = context.getLinkText();
} catch (IllegalNodeException e){
linkText = e.getNode().getText();
}
String msg = "Couldn't resolve reference to " + referenceType.getName() + " '" + linkText + "'.";
return new DiagnosticMessage(msg, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}
示例13: getViolatedBoundsConstraintMessage
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Override
public DiagnosticMessage getViolatedBoundsConstraintMessage(ILinkingDiagnosticContext context, int size) {
String message = "Too many matches for reference to '" + context.getLinkText() + "'. "
+ "Feature " + context.getReference().getName() + " can only hold " + context.getReference().getUpperBound()
+ " reference" + (context.getReference().getUpperBound() != 1 ? "s" : "") + " but found " + size + " candidate" +
(size!=1 ? "s" : "");
return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}
示例14: testCrossProjectLink
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Test
public void testCrossProjectLink() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo {");
_builder.newLine();
_builder.append(" ");
_builder.append("Bar bar");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final URI foo = this.createFile(this.project0, "Foo.testlang", _builder);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("type Bar {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final URI bar = this.createFile(this.project1, "Bar.testlang", _builder_1);
this.workspaceManager.doBuild(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(foo, bar)), CollectionLiterals.<URI>emptyList(), CancelIndicator.NullImpl);
Assert.assertEquals(2, this.diagnostics.size());
Assert.assertEquals(1, this.diagnostics.get(foo).size());
Assert.assertEquals(Diagnostic.LINKING_DIAGNOSTIC, IterableExtensions.<Issue>head(this.diagnostics.get(foo)).getCode());
Assert.assertTrue(this.diagnostics.get(bar).isEmpty());
this.diagnostics.clear();
List<String> _dependencies = this.workspaceManager.getProjectManager(this.project0.getName()).getProjectDescription().getDependencies();
String _name = this.project1.getName();
_dependencies.add(_name);
this.workspaceManager.doBuild(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(foo, bar)), CollectionLiterals.<URI>emptyList(), CancelIndicator.NullImpl);
Assert.assertEquals(2, this.diagnostics.size());
Assert.assertTrue(this.diagnostics.get(foo).isEmpty());
Assert.assertTrue(this.diagnostics.get(bar).isEmpty());
}
示例15: testUnresolved_01
import org.eclipse.xtext.diagnostics.Diagnostic; //导入依赖的package包/类
@Test
public void testUnresolved_01() {
Type type = resolve("BlaBlaBla");
Resource resource = type.eResource();
assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0);
assertEquals(0, diagnostic.getOffset());
assertEquals(1, diagnostic.getLength());
assertEquals(1, diagnostic.getLine());
assertEquals(1, diagnostic.getColumn());
assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage());
}