本文整理汇总了Java中org.eclipse.xtext.nodemodel.INode.getStartLine方法的典型用法代码示例。如果您正苦于以下问题:Java INode.getStartLine方法的具体用法?Java INode.getStartLine怎么用?Java INode.getStartLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.nodemodel.INode
的用法示例。
在下文中一共展示了INode.getStartLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: descriptionToNameWithPosition
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
/**
* Returns a string with name and position of the described object. The position is specified by line number (if
* possible, otherwise the uri fragment of the proxy is used). If the object is a {@link SyntaxRelatedTElement}, a
* "T" is used as a prefix of the line number.
*
* The following examples shows different mappings, depending on the described object:
* <table>
* <tr>
* <th>Mapping</th>
* <th>Described Object</th>
* </tr>
* <tr>
* <td><code>bar - 42</code></td>
* <td>Some element "bar", located in same resource on line 42</td>
* </tr>
* <tr>
* <td><code>foo - T23</code></td>
* <td>A type "foo" (or other syntax related element, a function is a type) which syntax related element (from which
* the type is build) is located in same file on line 23</td>
* </tr>
* <tr>
* <td><code>Infinity - global.n4ts:3</code></td>
* <td>An element "Infinity", located in another resource "global.n4ts" on line 3.</td>
* </tr>
* <tr>
* <td><code>decodeURI - global.n4ts:11</code></td>
* <td>An element "decodeURI", located in another resource "global.n4ts" on line 11. Although the element may be a
* type, there is no syntax related element because "n4ts" directly describes types.</td>
* </tr>
* </table>
*
* @param currentURI
* the current resource's URI, if described object is in same resource, resource name is omitted
* @param desc
* the object descriptor
*/
public static String descriptionToNameWithPosition(URI currentURI, boolean withLineNumber,
IEObjectDescription desc) {
String name = desc.getName().toString();
EObject eobj = desc.getEObjectOrProxy();
if (eobj == null) {
return "No EObject or proxy for " + name + " at URI " + desc.getEObjectURI();
}
String location = "";
if (eobj instanceof SyntaxRelatedTElement) {
EObject syntaxElement = ((SyntaxRelatedTElement) eobj).getAstElement();
if (syntaxElement != null) {
location += "T";
eobj = syntaxElement;
}
}
Resource eobjRes = eobj.eResource();
URI uri = eobjRes == null ? null : eobjRes.getURI();
if (uri != currentURI && uri != null) {
location = uri.lastSegment();
if (eobj.eIsProxy() || withLineNumber) {
location += ":";
}
}
if (eobj.eIsProxy()) {
URI proxyUri = desc.getEObjectURI();
location += "proxy:" + simpleURIString(proxyUri);
} else if (withLineNumber) {
INode node = NodeModelUtils.findActualNodeFor(eobj);
if (node == null) {
location += "no node:" + simpleURIString(desc.getEObjectURI());
} else {
location += node.getStartLine();
}
}
return name + SEPARATOR + location;
}