本文整理汇总了Java中org.eclipse.xtext.nodemodel.INode类的典型用法代码示例。如果您正苦于以下问题:Java INode类的具体用法?Java INode怎么用?Java INode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
INode类属于org.eclipse.xtext.nodemodel包,在下文中一共展示了INode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: emitUnassignedTokens
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
if (transition.getAmbiguousSyntaxes().isEmpty()) return;
List<INode> transitionNodes = collectNodes(fromNode, toNode);
for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
if (match_Disjunction_VerticalLineKeyword_0_1_1_0_a.equals(syntax))
emit_Disjunction_VerticalLineKeyword_0_1_1_0_a(semanticObject, getLastNavigableState(), syntaxNodes);
else if (match_Disjunction_VerticalLineKeyword_0_1_1_0_p.equals(syntax))
emit_Disjunction_VerticalLineKeyword_0_1_1_0_p(semanticObject, getLastNavigableState(), syntaxNodes);
else if (match_Disjunction_VerticalLineKeyword_1_1_0_a.equals(syntax))
emit_Disjunction_VerticalLineKeyword_1_1_0_a(semanticObject, getLastNavigableState(), syntaxNodes);
else if (match_Disjunction_VerticalLineKeyword_1_1_0_p.equals(syntax))
emit_Disjunction_VerticalLineKeyword_1_1_0_p(semanticObject, getLastNavigableState(), syntaxNodes);
else acceptNodes(getLastNavigableState(), syntaxNodes);
}
}
示例2: getDoc
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
/**
* Get JSDoc comment for the given element. The element may be an AST node such as <code>N4MethodDeclaration</code>
* or a type model element such as <code>TMethod</code>. In the latter case, this method will follow the link to the
* AST which may cause a load of the N4JS resource if it is not fully loaded (i.e. if only the TModule was loaded
* from the Xtext index).
* <p>
* Thus, <b>this method may have a side effect on the containing resource of the given element</b>. If that is not
* desired, use method {@link #getDocSafely(ResourceSet, EObject)} instead.
*/
public String getDoc(EObject element) {
if (element == null)
throw new IllegalArgumentException("element must not be null");
if (element.eIsProxy()) {
return null;
// throw new IllegalArgumentException("element must not be proxy: " + element.toString());
}
final List<INode> docNodes = documentationProviderExt.getDocumentationNodes(element);
if (!docNodes.isEmpty()) {
final StringBuilder sb = new StringBuilder(docNodes.get(0).getText());
for (int idx = 1; idx < docNodes.size(); idx++) {
sb.append("\n").append(docNodes.get(idx).getText());
}
return sb.toString();
}
return null;
}
示例3: toValue
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_BINARYINT_CONVERT_EMPTY_STR(),
IssueCodes.VCO_BINARYINT_CONVERT_EMPTY_STR, node, null);
if (string.length() <= 2) {
throw new N4JSValueConverterWithValueException(
IssueCodes.getMessageForVCO_BINARYINT_CONVERT_TOO_SHORT(string),
IssueCodes.VCO_BINARYINT_CONVERT_TOO_SHORT, node,
BigDecimal.ZERO, null);
}
try {
return new BigDecimal(new BigInteger(string.substring(2), 2));
} catch (NumberFormatException e) {
throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_CONVERT_STR(string),
IssueCodes.VCO_HEXINT_CONVERT_STR, node, null);
}
}
示例4: findJSDocComment
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
/**
* Naive comment lookup, that doesn't consider parent. Returns comment that is closest to the lookup element. If
* flag is provided includes doublestar comments into search. Doublestar comments are prioritized over single star
* comments.
*
* Throws {@link InstantiationException} when it stumbles upon MultiLine comment that doesn't start with proper
* markers (</*> and <*\/>)
*
* @param eObject
* element on which lookup is performed
* @param considerDoubleStar
* swithc to include in luukup comments with double star
* @return CommentCandidate for given eObject.
* @throws InstantiationException
* if comment on element is malformatted.
*/
public CommentCandidate findJSDocComment(EObject eObject, boolean considerDoubleStar)
throws InstantiationException {
if (eObject == null) {
return null;
}
List<INode> comments = findMultiLineComments(eObject);
// fast result
if (comments == null || comments.isEmpty()) {
return null;
}
if (considerDoubleStar) {
return pickCommentConsiderDoubleStar(comments);
}
return pickCommentNoDoubleStar(comments);
}
示例5: addSyntaxErrors
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
/**
* This is aware of warnings from the {@link N4JSStringValueConverter}.
*
* Issues from the parser are commonly treated as errors but here we want to create a warning.
*/
@Override
protected void addSyntaxErrors() {
if (isValidationDisabled())
return;
// EList.add unnecessarily checks for uniqueness by default
// so we use #addUnique below to save some CPU cycles for heavily broken
// models
BasicEList<Diagnostic> errorList = (BasicEList<Diagnostic>) getErrors();
BasicEList<Diagnostic> warningList = (BasicEList<Diagnostic>) getWarnings();
for (INode error : getParseResult().getSyntaxErrors()) {
XtextSyntaxDiagnostic diagnostic = createSyntaxDiagnostic(error);
String code = diagnostic.getCode();
if (AbstractN4JSStringValueConverter.WARN_ISSUE_CODE.equals(code)
|| RegExLiteralConverter.ISSUE_CODE.equals(code)
|| LegacyOctalIntValueConverter.ISSUE_CODE.equals(code)) {
warningList.addUnique(diagnostic);
} else if (!InternalSemicolonInjectingParser.SEMICOLON_INSERTED.equals(code)) {
errorList.addUnique(diagnostic);
}
}
}
示例6: createSyntaxDiagnostic
import org.eclipse.xtext.nodemodel.INode; //导入依赖的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);
}
示例7: serializeCrossRef
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node,
Acceptor errors) {
if (((InternalEObject) target).eProxyURI() != null) {
if (((InternalEObject) target).eProxyURI().toString().startsWith("#")) {
return super.serializeCrossRef(semanticObject, crossref, getEObjectfromEProxy(semanticObject, target),
node, errors);
}
}
return super.serializeCrossRef(semanticObject, crossref, target, node, errors);
}
示例8: emitUnassignedTokens
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
if (transition.getAmbiguousSyntaxes().isEmpty()) return;
List<INode> transitionNodes = collectNodes(fromNode, toNode);
for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
acceptNodes(getLastNavigableState(), syntaxNodes);
}
}
示例9: getLocation
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
public Location getLocation(EObject eObject) {
INode node = NodeModelUtils.getNode(eObject);
if (node != null) {
return new Location(Type.XTEXT_LOCATION, node.getStartLine());
}
return new Location(Type.XTEXT_LOCATION, -1);
}
示例10: pickCommentConsiderDoubleStar
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
/**
* Select comment closest to lookup element. Assume comments to be ordered list. Includes comments with doublestar
* in search results. DoubleStar comments are prioritized over singlestar comemnts.
*
* @param comments
* list of commnets on luukup elements
* @throws InstantiationException
* if comment is malformed
*/
protected CommentCandidate pickCommentConsiderDoubleStar(List<INode> comments) throws InstantiationException {
// one commemnt - wins
if (comments.size() == 1) {
return new CommentCandidate(comments.get(0).getText());
}
// multiple comments
// arrList has reversed order
ListIterator<INode> iter = comments.listIterator(comments.size());
// so far best candidate
String bestCandidateString = iter.previous().getText();
if (bestCandidateString.startsWith("/**")) {
return new CommentCandidate(bestCandidateString); // automatic win
}
// if we get here we have first single star comment, so
// check if there is supreme candidate
String candidateTextString = "";
while (iter.hasPrevious()) {
candidateTextString = iter.previous().getText();
if (candidateTextString.startsWith("/**")) {
bestCandidateString = candidateTextString;
break; // first supreme wins
}
}
return new CommentCandidate(bestCandidateString);
}
示例11: toValue
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
throw new ValueConverterException("Couldn't convert empty string to an int value.", node, null);
try {
return new BigDecimal(string);
} catch (NumberFormatException e) {
throw new ValueConverterException("Couldn't convert '" + string + "' to an int value.", node, e);
}
}
示例12: deadCode
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
/**
* Checks whether the dead code analysis produces the expected result: dead code found or no dead code found.
*
* @param expectation
* "dead code" or "no dead code"
* @param offset
* the offset where the XPECT comment is used
*/
@Xpect
@ParameterParser(syntax = "('at' arg1=OFFSET)?")
public void deadCode(@StringExpectation IStringExpectation expectation,
// @ThisResource XtextResource resource,
INode offset) {
if (offset == null) {
return;
}
String actual = evaluateDeadCode(offset);
expectation.assertEquals(actual);
}
示例13: IEObjectCoveringRegion
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
/***/
@Creates
public IEObjectCoveringRegion IEObjectCoveringRegion() {
final boolean haveRegion = region != null;
int offset = haveRegion ? region.getOffset() : this.matchedOffset;
int length = haveRegion ? region.getLength() : 0;
int endOffset = offset + length;
EObject semanticObject = null;
INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
while (node != null) {
EObject actualObject = NodeModelUtils.findActualSemanticObjectFor(node);
if (actualObject != null) {
if (haveRegion) {
int nodeEndOffset = node.getEndOffset();
if (nodeEndOffset <= endOffset || semanticObject == null) {
semanticObject = actualObject;
}
if (nodeEndOffset >= endOffset) {
break;
}
} else { // no region given, just a matched offset
if (semanticObject == null) {
semanticObject = actualObject;
break;
}
}
}
node = node.getParent();
}
return new EObjectCoveringRegion(semanticObject, offset);
}
示例14: emitUnassignedTokens
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
@Override
protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
if (transition.getAmbiguousSyntaxes().isEmpty()) return;
List<INode> transitionNodes = collectNodes(fromNode, toNode);
for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
if (match_ProjectDescription___RightCurlyBracketKeyword_17_3_SourcesKeyword_17_0_LeftCurlyBracketKeyword_17_1__q.equals(syntax))
emit_ProjectDescription___RightCurlyBracketKeyword_17_3_SourcesKeyword_17_0_LeftCurlyBracketKeyword_17_1__q(semanticObject, getLastNavigableState(), syntaxNodes);
else if (match_ProjectDescription___RightCurlyBracketKeyword_18_3_ModuleFiltersKeyword_18_0_LeftCurlyBracketKeyword_18_1__q.equals(syntax))
emit_ProjectDescription___RightCurlyBracketKeyword_18_3_ModuleFiltersKeyword_18_0_LeftCurlyBracketKeyword_18_1__q(semanticObject, getLastNavigableState(), syntaxNodes);
else if (match_VersionConstraint_RightParenthesisKeyword_0_2_1_q.equals(syntax))
emit_VersionConstraint_RightParenthesisKeyword_0_2_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
else acceptNodes(getLastNavigableState(), syntaxNodes);
}
}
示例15: getPropertyAsString
import org.eclipse.xtext.nodemodel.INode; //导入依赖的package包/类
private String getPropertyAsString(ParameterizedPropertyAccessExpression propAccessExpr) {
final StringBuilder sb = new StringBuilder();
for (INode node : NodeModelUtils.findNodesForFeature(propAccessExpr,
N4JSPackage.eINSTANCE.getParameterizedPropertyAccessExpression_Property())) {
sb.append(NodeModelUtils.getTokenText(node));
}
return sb.toString();
}