本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.IStructuredModel.getIndexedRegion方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredModel.getIndexedRegion方法的具体用法?Java IStructuredModel.getIndexedRegion怎么用?Java IStructuredModel.getIndexedRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.sse.core.internal.provisional.IStructuredModel
的用法示例。
在下文中一共展示了IStructuredModel.getIndexedRegion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNodeByOffset
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
/**
* Returns the SSE DOM Node {@link IDOMNode} by offset from the
* {@link IStructuredModel} SSE mode and null if not found.
*
* @param model
* the SSE model.
* @param offset
* the offset.
* @return
*/
public static final IDOMNode getNodeByOffset(IStructuredModel model, int offset) {
IndexedRegion node = null;
if (model != null) {
node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return (IDOMNode) node;
}
if (model != null) {
int lastOffset = offset;
node = model.getIndexedRegion(offset);
while (node == null && lastOffset >= 0) {
lastOffset--;
node = model.getIndexedRegion(lastOffset);
}
}
}
return (IDOMNode) node;
}
示例2: smartInsertCloseEndEL
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
private void smartInsertCloseEndEL(DocumentCommand command, IDocument document, IStructuredModel model) {
try {
if (isPreferenceEnabled(AngularUIPreferenceNames.TYPING_COMPLETE_END_EL) && command.text.equals("{") //$NON-NLS-1$
&& document.getLength() > 0 && document.getChar(command.offset - 1) == '{') {
IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset - 1);
command.text += "}}";
command.shiftsCaret = false;
command.caretOffset = command.offset + 1;
command.doit = false;
}
} catch (BadLocationException e) {
}
}
示例3: getNodeByOffset
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
/**
* Returns the SSE DOM Node {@link IDOMNode} by offset from the
* {@link IStructuredModel} SSE mode and null if not found.
*
* @param model
* the SSE model.
* @param offset
* the offset.
* @return
*/
public static final IDOMNode getNodeByOffset(IStructuredModel model,
int offset) {
IndexedRegion node = null;
if (model != null) {
node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return (IDOMNode) node;
}
int lastOffset = offset;
node = model.getIndexedRegion(offset);
while (node == null && lastOffset >= 0) {
lastOffset--;
node = model.getIndexedRegion(lastOffset);
}
}
return (IDOMNode) node;
}
示例4: smartInsertCloseEndEL
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
private void smartInsertCloseEndEL(DocumentCommand command,
IDocument document, IStructuredModel model) {
try {
if (isPreferenceEnabled(AngularUIPreferenceNames.TYPING_COMPLETE_END_EL)
&& command.text.equals("{") && document.getLength() > 0 && document.getChar(command.offset - 1) == '{') { //$NON-NLS-1$
IDOMNode node = (IDOMNode) model
.getIndexedRegion(command.offset - 1);
command.text += "}}";
command.shiftsCaret = false;
command.caretOffset = command.offset + 1;
command.doit = false;
}
} catch (BadLocationException e) {
}
}
示例5: collectJSONNodes
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
public List collectJSONNodes(IStructuredModel model, int start, int length) {
List nodes = new ArrayList();
IndexedRegion startNode = model.getIndexedRegion(start);
IndexedRegion endNode = model.getIndexedRegion(start + length - 1);
if (startNode == null || endNode == null) {
return nodes;
}
if (model instanceof IJSONModel && startNode instanceof IJSONNode
&& endNode instanceof IJSONNode) {
// JSON model
IJSONNode ca = getCommonAncestor((IJSONNode) startNode,
(IJSONNode) endNode);
if (ca != null) {
for (IJSONNode node = ca.getFirstChild(); node != null
&& start + length < ((IndexedRegion) node)
.getStartOffset(); node = node.getNextSibling()) {
if (start < ((IndexedRegion) node).getEndOffset()) {
nodes.add(node);
}
}
}
}
return nodes;
}
示例6: getCurrentNode
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
/**
* Returns the node the cursor is currently on in the document. null if no node is selected
*
* @param offset
* @return Node either element, doctype, text, or null
*/
private Node getCurrentNode(IDocument document, int offset)
{
// get the current node at the offset (returns either: element,
// doctype, text)
IndexedRegion inode = null;
IStructuredModel sModel = null;
try
{
sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (sModel != null)
{
inode = sModel.getIndexedRegion(offset);
if (inode == null)
{
inode = sModel.getIndexedRegion(offset - 1);
}
}
}
finally
{
if (sModel != null)
sModel.releaseFromRead();
}
if (inode instanceof Node)
{
return (Node)inode;
}
return null;
}
示例7: getAttrByOffset
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入方法依赖的package包/类
public static final IDOMAttr getAttrByOffset(IStructuredModel model,
int offset) {
if (model != null) {
IndexedRegion node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return getAttrByOffset(node, offset);
}
}
return null;
}