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

Java DiagnosticMessage类代码示例

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

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



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

示例1: createAndAddDiagnostic

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
	// check if unresolved reference is special case handled by {@link N4JSScopingDiagnostician}
	DiagnosticMessage scopingDiagnostic = scopingDiagnostician.getMessageFor(triple.getFirst(), triple.getSecond(),
			triple.getThird());
	// if so, use more specific diagnostic message
	if (null != scopingDiagnostic) {
		List<Diagnostic> list = getDiagnosticList(scopingDiagnostic);
		Diagnostic diagnostic = createDiagnostic(triple, scopingDiagnostic);
		if (!list.contains(diagnostic)) {
			list.add(diagnostic);
		}
	} else {
		// if not, use default generic scoping message
		super.createAndAddDiagnostic(triple);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:N4JSResource.java


示例2: applyToModel

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的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


示例3: handleCyclicResolution

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
protected EObject handleCyclicResolution(Triple<EObject, EReference, INode> triple) throws AssertionError {
	if (!isValidationDisabled()) {
		EObject context = triple.getFirst();
		if (context.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
			// here we may end up with cyclic resolution requests in rare situations, e.g. for input types
			// like :
			/*
			 * package p;
			 * class C extends p.C.Bogus {}
			 */
			return null;
		}
		DiagnosticMessage message = new DiagnosticMessage("Cyclic linking detected : " + getReferences(triple, resolving), Severity.ERROR, "cyclic-resolution");
		List<Diagnostic> list = getDiagnosticList(message);
		Diagnostic diagnostic = createDiagnostic(triple, message);
		if (!list.contains(diagnostic))
			list.add(diagnostic);
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:BatchLinkableResource.java


示例4: defaultModesOK

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Test
public void defaultModesOK() {
  ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
  LexerCommand command = createMock(LexerCommand.class);
  LexerCommands commands = createMock(LexerCommands.class);

  expect(diagnosticContext.getLinkText()).andReturn("HIDDEN");
  expect(diagnosticContext.getContext()).andReturn(command);

  expect(command.eContainer()).andReturn(commands);

  Object[] mocks = {diagnosticContext, command, commands };

  replay(mocks);

  DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider()
      .getUnresolvedProxyMessage(diagnosticContext);
  assertNull(message);

  verify(mocks);
}
 
开发者ID:antlr4ide,项目名称:antlr4ide,代码行数:22,代码来源:Antlr4MissingReferenceMessageProviderTest.java


示例5: undefinedMode

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Test
public void undefinedMode() {
  ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
  LexerCommand command = createMock(LexerCommand.class);
  LexerCommands commands = createMock(LexerCommands.class);

  expect(diagnosticContext.getLinkText()).andReturn("INSIDE");
  expect(diagnosticContext.getContext()).andReturn(command);

  expect(command.eContainer()).andReturn(commands);

  Object[] mocks = {diagnosticContext, command, commands };

  replay(mocks);

  DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider()
      .getUnresolvedProxyMessage(diagnosticContext);
  assertNull(message);

  verify(mocks);
}
 
开发者ID:antlr4ide,项目名称:antlr4ide,代码行数:22,代码来源:Antlr4MissingReferenceMessageProviderTest.java


示例6: getUnresolvedProxyMessage

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的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;
}
 
开发者ID:RobertWalter83,项目名称:DialogScriptDSL,代码行数:27,代码来源:CustomLinkingDiagnosticMessageProvider.java


示例7: diagnose

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
/**
 * Creates a {@link DiagnosticMessage} for instanceof expressions where the right-hand-side is a primitive type
 * identifier.
 *
 * It is assumed that the given qualified name was extracted from the {@link IdentifierRef} on the rhs of the given
 * relational expression.
 *
 * Returns null if not applicable.
 *
 * @param name
 *            The unresolved name of an IdentifierRef on the RHS of the expression.
 *
 * @param expression
 *            A pair of the instanceof-expression and the unresolved IdentifierRef.
 */
@Override
DiagnosticMessage diagnose(QualifiedName name, RelationalExpression expression) {
	// only applicable for the instanceof operator
	if (expression.getOp() != RelationalOperator.INSTANCEOF) {
		return null;
	}

	// query built-in type scope for the unresolved name
	BuiltInTypeScope builtInTypeScope = BuiltInTypeScope.get(expression.eResource().getResourceSet());
	IEObjectDescription singleElement = builtInTypeScope.getSingleElement(name);

	// if there is no primitive type with this name, this diagnosis is not applicable
	if (null == singleElement) {
		return null;
	}

	// if we can find a primitive type for the qualified name
	if (singleElement.getEClass().getClassifierID() == TypesPackage.Literals.PRIMITIVE_TYPE.getClassifierID()) {
		// create special error message
		return createMessage(IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES,
				IssueCodes.getMessageForTYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES());
	} else {
		// the found element is not a primitive type, diagnosis not applicable
		return null;
	}

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:43,代码来源:N4JSScopingInstanceOfPrimitivTypeDiagnosis.java


示例8: diagnose

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
DiagnosticMessage diagnose(QualifiedName name, ParameterizedPropertyAccessExpression propertyAccess) {
	// determine containing member declaration and classifier definition
	N4MemberDeclaration containingMemberDeclaration = EcoreUtil2.getContainerOfType(propertyAccess,
			N4MemberDeclaration.class);
	N4ClassifierDefinition classifierDefinition = EcoreUtil2.getContainerOfType(containingMemberDeclaration,
			N4ClassifierDefinition.class);

	// if ancestors present and non-static context (no super in static context)
	if (containingMemberDeclaration != null &&
			!containingMemberDeclaration.isStatic() &&
			classifierDefinition != null) {

		// Get candidate methods
		MemberList<TMember>.MemberIterable<TMethod> methods = containerTypesHelper.fromContext(propertyAccess)
				.membersOfImplementedInterfacesForConsumption((TClassifier) classifierDefinition.getDefinedType())
				.methods();

		boolean hasMethod = methods.stream()
				.filter(m -> !m.isHasNoBody() && !m.isStatic()) // Filter for non-static non-abstract methods
				.anyMatch(m -> m.getName().equals(name.toString()));

		if (hasMethod) {
			return createMessage(IssueCodes.CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER,
					IssueCodes.getMessageForCLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER());
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:30,代码来源:N4JSScopingConsumableMethodsDiagnosis.java


示例9: createDiagnostic

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
protected Resource.Diagnostic createDiagnostic(DiagnosticMessage message) {
	Diagnostic diagnostic = new XtextLinkingDiagnostic(
			node, 
			message.getMessage(),
			message.getIssueCode(), message.getIssueData());
	return diagnostic;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:AbstractUnresolvableReferenceWithNode.java


示例10: getDiagnosticList

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
protected List<Diagnostic> getDiagnosticList(LazyLinkingResource resource, /* @Nullable */ DiagnosticMessage message) throws AssertionError {
	if (message != null) {
		switch (message.getSeverity()) {
			case ERROR:
				return resource.getErrors();
			case WARNING:
				return resource.getWarnings();
			default:
				throw new AssertionError("Unexpected severity: " + message.getSeverity());
		}
	}
	return Collections.emptyList();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:AbstractUnresolvableReferenceWithNode.java


示例11: acceptError

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
public void acceptError(TransformationErrorCode errorCode, String message, EObject element) {
	setTarget(element, null);
	lastError = errorCode;
	addDiagnostic(new DiagnosticMessage(message, Severity.ERROR, null));	
	lastError = null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:TransformationDiagnosticsProducer.java


示例12: getUnresolvedProxyMessage

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticContext context) {
	DiagnosticMessage diagnosticMessage = new XtextSwitch<DiagnosticMessage>() {
		@Override
		public DiagnosticMessage caseRuleCall(RuleCall ruleCall) {
			return new DiagnosticMessage(context.getLinkText()+" cannot be resolved to a rule", Severity.ERROR,
					UNRESOLVED_RULE, context.getLinkText());
		}

	}.doSwitch(context.getContext());
	return diagnosticMessage != null ? diagnosticMessage : super.getUnresolvedProxyMessage(context);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:XtextLinkingDiagnosticMessageProvider.java


示例13: createAndAddDiagnostic

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
	if (isValidationDisabled())
		return;
	DiagnosticMessage message = createDiagnosticMessage(triple);
	if (message != null) {
		List<Diagnostic> list = getDiagnosticList(message);
		Diagnostic diagnostic = createDiagnostic(triple, message);
		if (!list.contains(diagnostic))
			list.add(diagnostic);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:LazyLinkingResource.java


示例14: removeDiagnostic

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
protected void removeDiagnostic(Triple<EObject, EReference, INode> triple) {
	// return early if there's nothing to remove
	if (getErrors().isEmpty() && getWarnings().isEmpty())
		return;
	DiagnosticMessage message = createDiagnosticMessage(triple);
	List<Diagnostic> list = getDiagnosticList(message);
	if (!list.isEmpty()) {
		Diagnostic diagnostic = createDiagnostic(triple, message);
		list.remove(diagnostic);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:LazyLinkingResource.java


示例15: getDiagnosticList

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
protected List<Diagnostic> getDiagnosticList(DiagnosticMessage message) throws AssertionError {
	if (message != null) {
		switch (message.getSeverity()) {
			case ERROR:
				return getErrors();
			case WARNING:
				return getWarnings();
			default:
				throw new AssertionError("Unexpected severity: " + message.getSeverity());
		}
	}
	return Collections.emptyList();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:LazyLinkingResource.java


示例16: getUnresolvedProxyMessage

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:LinkingDiagnosticMessageProvider.java


示例17: getViolatedBoundsConstraintMessage

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:9,代码来源:LinkingDiagnosticMessageProvider.java


示例18: createDiagnostic

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
protected void createDiagnostic(Triple<EObject, EReference, INode> triple) {
	SpecificationElement specificationElement = EcoreUtil2.getContainerOfType(triple.getFirst(),
			SpecificationElement.class);
	DiagnosticMessage message = createDiagnosticMessage(triple);
	Diagnostic diagnostic = new XtextLinkingDiagnostic(triple.getThird(), message.getMessage(),
			message.getIssueCode(), message.getIssueData());
	linkingDiagnostics.put(specificationElement, diagnostic);

}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:10,代码来源:AbstractSCTResource.java


示例19: getUnresolvedProxyMessage

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticContext context) {

	EObject object = context.getContext();
	if (object instanceof ConnectionRef) {
		return new DiagnosticMessage("Missing connection declaration", Severity.ERROR,
				IssueCodes.MISSING_CONNECTION_DECL, context.getLinkText());
	}
	return super.getUnresolvedProxyMessage(context);
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:11,代码来源:PhdlLinkingDiagnosticMessageProvider.java


示例20: getViolatedBoundsConstraintMessage

import org.eclipse.xtext.diagnostics.DiagnosticMessage; //导入依赖的package包/类
@Override
public DiagnosticMessage getViolatedBoundsConstraintMessage(final ILinkingDiagnosticContext context,
		final int size) {
	final 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);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:10,代码来源:GamlLinkingErrorMessageProvider.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java FileVersionsResponse类代码示例发布时间:2022-05-22
下一篇:
Java LocalVariableInstruction类代码示例发布时间: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