當前位置: 首頁>>代碼示例>>Java>>正文


Java INode.getStartLine方法代碼示例

本文整理匯總了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);
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:9,代碼來源:XtextLocator.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:79,代碼來源:EObjectDescriptionToNameWithPositionMapper.java


注:本文中的org.eclipse.xtext.nodemodel.INode.getStartLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。