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


Java SyntaxErrorMessage类代码示例

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


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

示例1: reportError

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
/**
 * Reports errors that should be present in the node model. This is specialized because we want real errors to
 * override the synthesized diagnostics for automatically inserted semicolons.
 *
 * Usually only one syntax error message will be reported per location. For input documents of the form
 *
 * <pre>
 * var i};
 * </pre>
 *
 * we insert a semicolon automatically before the closing brace. That implies, that we have a message on the brace
 * itself. The parser will try to match the real brace afterwards against the follow element set and fails. It tries
 * to report that error but since there is already a message it would be discarded. Here we force the real error
 * message to be replace the former info.
 */
@Override
public void reportError(RecognitionException e) {
	if (state.errorRecovery) {
		return;
	}
	try {
		SyntaxErrorMessage currentError = (SyntaxErrorMessage) reflectCurrentError.get(this);
		if (currentError != null && SEMICOLON_INSERTED.equals(currentError.getIssueCode())) {
			setCurrentError(null);
		}
		super.reportError(e);
	} catch (IllegalArgumentException | IllegalAccessException e1) {
		super.reportError(e);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:31,代码来源:InternalSemicolonInjectingParser.java

示例2: getSyntaxErrorMessage

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(
		IValueConverterErrorContext context) {
	ValueConverterException cause = context.getValueConverterException();
	if (cause instanceof N4JSStringValueConverter.BadEscapementException) {
		if (((N4JSStringValueConverter.BadEscapementException) cause).isError())
			return new SyntaxErrorMessage(context.getDefaultMessage(), AbstractN4JSStringValueConverter.ERROR_ISSUE_CODE);
		return new SyntaxErrorMessage(context.getDefaultMessage(), AbstractN4JSStringValueConverter.WARN_ISSUE_CODE);
	}
	if (cause instanceof LegacyOctalIntValueConverter.LeadingZerosException) {
		return new SyntaxErrorMessage(context.getDefaultMessage(), LegacyOctalIntValueConverter.ISSUE_CODE);
	}
	if (cause instanceof RegExLiteralConverter.BogusRegExLiteralException) {
		return new SyntaxErrorMessage(context.getDefaultMessage(), RegExLiteralConverter.ISSUE_CODE);
	}
	return super.getSyntaxErrorMessage(context);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:BadEscapementAwareMessageProvider.java

示例3: createSyntaxDiagnostic

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
private XtextSyntaxDiagnostic createSyntaxDiagnostic(INode error) {
	SyntaxErrorMessage syntaxErrorMessage = error.getSyntaxErrorMessage();
	if (org.eclipse.xtext.diagnostics.Diagnostic.SYNTAX_DIAGNOSTIC_WITH_RANGE.equals(syntaxErrorMessage
			.getIssueCode())) {
		String[] issueData = syntaxErrorMessage.getIssueData();
		if (issueData.length == 1) {
			String data = issueData[0];
			int colon = data.indexOf(':');
			return new XtextSyntaxDiagnosticWithRange(error, Integer.valueOf(data.substring(0, colon)),
					Integer.valueOf(data.substring(colon + 1)), null) {
				@Override
				public int getLine() {
					return getNode().getTotalStartLine();
				}
			};
		}
	}
	return new XtextSyntaxDiagnostic(error);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:N4JSResource.java

示例4: newLeafNode

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
public ILeafNode newLeafNode(int offset, int length, EObject grammarElement, boolean isHidden, /* @Nullable */ SyntaxErrorMessage errorMessage,
		ICompositeNode parent) {
	LeafNode result = null;
	if (errorMessage != null) {
		if (isHidden) {
			result = new HiddenLeafNodeWithSyntaxError();
			((HiddenLeafNodeWithSyntaxError)result).basicSetSyntaxErrorMessage(errorMessage);
		} else {
			result = new LeafNodeWithSyntaxError();
			((LeafNodeWithSyntaxError)result).basicSetSyntaxErrorMessage(errorMessage);
		}
	} else {
		if (isHidden) {
			result = new HiddenLeafNode();
		} else {
			result = new LeafNode();
		}
	}
	result.basicSetGrammarElement(grammarElement);
	result.basicSetTotalOffset(offset);
	result.basicSetTotalLength(length);
	addChild(parent, result);
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:NodeModelBuilder.java

示例5: isIgnoredSyntaxErrorNode

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
/**
 * {@code true} if the leaf node argument is an instance of {@link LeafNodeWithSyntaxError} and the issue code of
 * the syntax error message matches with any of the ignored syntax error issue codes argument. Otherwise, returns
 * with {@code false}.
 */
public static boolean isIgnoredSyntaxErrorNode(final INode leaf, final String... ignoredSyntaxErrorIssues) {
	if (leaf instanceof LeafNodeWithSyntaxError) {
		final SyntaxErrorMessage errorMessage = leaf.getSyntaxErrorMessage();
		if (null != errorMessage) {
			return contains(errorMessage.getIssueCode(), ignoredSyntaxErrorIssues);
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:UtilN4.java

示例6: nextToken

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
/**
 * Implementation of the {@link TokenSource} interface. Return new tokens as long as there are some, afterwards
 * return {@link Token#EOF_TOKEN}.
 */
@Override
public Token nextToken() {
	if (next != null) {
		Token result = next;
		next = null;
		return result;
	}
	if (!leafNodes.hasNext()) {
		return Token.EOF_TOKEN;
	}
	ILeafNode leaf = leafNodes.next();
	if (leaf.getTotalOffset() >= endOffset) {
		leafNodes = Iterators.emptyIterator();
		return Token.EOF_TOKEN;
	}
	if (leaf.getTotalEndOffset() <= startOffset) {
		return nextToken();
	}
	if (leaf.getTotalEndOffset() > endOffset) {
		return toPrefixToken(leaf);
	}
	SyntaxErrorMessage syntaxErrorMessage = leaf.getSyntaxErrorMessage();
	if (syntaxErrorMessage != null && SEMICOLON_INSERTED.equals(syntaxErrorMessage.getIssueCode())) {
		return toASIToken(leaf);
	}
	if (leaf.isHidden()) {
		return processHiddenToken(leaf);
	}
	int tokenType = tokenTypeMapper.getInternalTokenType(leaf);
	return new CommonToken(tokenType, leaf.getText());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:NodeModelTokenSource.java

示例7: setCurrentError

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
private void setCurrentError(SyntaxErrorMessage syntaxErrorMessage) {
	try {
		reflectCurrentError.set(this, syntaxErrorMessage);
	} catch (Exception e) {
		throw new RuntimeException();
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:8,代码来源:InternalSemicolonInjectingParser.java

示例8: addASIMessage

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
/**
 * <p>
 * Overrides method stub generated by customized ANTLR/Xtext generator.
 * </p>
 */
@Override
public void addASIMessage() {
	if (!hasCurrentError()) {
		SyntaxErrorMessage message = new SyntaxErrorMessage("Automatically inserted semicolon", SEMICOLON_INSERTED);
		setCurrentError(message);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:InternalSemicolonInjectingParser.java

示例9: parse

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> ParserResults<T> parse(String parseRuleName, String versionNo) {
	final ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
	parserRule.setName(parseRuleName);
	final N4MFParser parser = getService(N4MFParser.class, getRandomURI());
	final IParseResult result = parser.parse(parserRule, new StringReader(versionNo));
	final ParserResults<T> res = new ParserResults<>();
	res.ast = (T) result.getRootASTElement();
	result.getSyntaxErrors().forEach(n -> {
		SyntaxErrorMessage syntaxErrorMessage = n.getSyntaxErrorMessage();
		res.addErrors(syntaxErrorMessage.getMessage());
	});
	return res;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:ManifestValuesParsingUtil.java

示例10: assertNoSyntaxErrors

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
protected void assertNoSyntaxErrors(XtextResource resource) {
	Iterable<INode> syntaxErrors = resource.getParseResult().getSyntaxErrors();
	if (!Iterables.isEmpty(syntaxErrors)) {
		StringBuilder builder = new StringBuilder();
		builder.append("This document can't be formatted because of syntax errors:\n");
		for (INode node : syntaxErrors) {
			SyntaxErrorMessage msg = node.getSyntaxErrorMessage();
			builder.append(String.format("Line %02d: %s\n", node.getTotalStartLine(), msg.getMessage()));
		}
		fail(builder, resource.getParseResult().getRootNode().getText());
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:FormatterTester.java

示例11: writeSyntaxErrorMessage

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
public static void writeSyntaxErrorMessage(DataOutputStream out, SerializationConversionContext scc,
		SyntaxErrorMessage syntaxErrorMessage) throws IOException {
	if (syntaxErrorMessage == null) {
		out.writeBoolean(true);
	} else {
		out.writeBoolean(false);
		SerializationUtil.writeString(out, syntaxErrorMessage.getMessage());
		SerializationUtil.writeString(out, syntaxErrorMessage.getIssueCode());
		SerializationUtil.writeStringArray(out, syntaxErrorMessage.getIssueData());
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:SerializationUtil.java

示例12: readSyntaxErrorMessage

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
public static SyntaxErrorMessage readSyntaxErrorMessage(DataInputStream in, DeserializationConversionContext context)
		throws IOException {
	boolean isNull = in.readBoolean();
	if (isNull)
		return null;
	String message = SerializationUtil.readString(in);
	String issueCode = SerializationUtil.readString(in);
	String[] issueData = SerializationUtil.readStringArray(in);
	SyntaxErrorMessage result = new SyntaxErrorMessage(message, issueCode, issueData);
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:SerializationUtil.java

示例13: getSyntaxErrorMessage

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(IValueConverterErrorContext context) {
	ValueConverterException cause = context.getValueConverterException();
	if (cause instanceof MoreThanOneCardinalityException) {
		return new SyntaxErrorMessage(context.getDefaultMessage(), CARDINALITY_ISSUE);
	}
	return super.getSyntaxErrorMessage(context);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:9,代码来源:CardinalityAwareSyntaxErrorMessageProvider.java

示例14: addSyntaxDiagnostic

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
/**
 * @since 2.9
 */
@Override
protected void addSyntaxDiagnostic(List<Diagnostic> diagnostics, INode node) {
	SyntaxErrorMessage syntaxErrorMessage = node.getSyntaxErrorMessage();
	if (CardinalityAwareSyntaxErrorMessageProvider.CARDINALITY_ISSUE.equals(syntaxErrorMessage.getIssueCode())) {
		super.getWarnings().add(new XtextSyntaxDiagnostic(node));
	} else {
		super.addSyntaxDiagnostic(diagnostics, node);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:GrammarResource.java

示例15: createLeafNode

import org.eclipse.xtext.nodemodel.SyntaxErrorMessage; //导入依赖的package包/类
private ILeafNode createLeafNode(Token token, EObject grammarElement) {
	boolean isHidden = token.getChannel() == HIDDEN;
	SyntaxErrorMessage error = null;
	if (!isHidden) {
		if (currentError != null) {
			error = currentError;
			currentError = null;
		}
	}
	if (token.getType() == Token.INVALID_TOKEN_TYPE) {
		if (error == null) {
			String lexerErrorMessage = ((XtextTokenStream) input).getLexerErrorMessage(token);
			LexerErrorContext errorContext = new LexerErrorContext(lexerErrorMessage);
			error = syntaxErrorProvider.getSyntaxErrorMessage(errorContext);
		}
	}
	if (grammarElement == null) {
		String ruleName = antlrTypeToLexerName.get(token.getType());
		grammarElement = allRules.get(ruleName);
	}
	CommonToken commonToken = (CommonToken) token;
	if (error != null)
		hadErrors = true;
	return nodeBuilder.newLeafNode(
			commonToken.getStartIndex(), 
			commonToken.getStopIndex() - commonToken.getStartIndex() + 1, 
			grammarElement, 
			isHidden, 
			error, 
			currentNode);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:32,代码来源:AbstractInternalAntlrParser.java


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