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


Java BadPositionCategoryException类代码示例

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


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

示例1: getPositions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * Returns the partitioner's positions.   Apparently, this is an array of TypedPosition objects
 * that partitions the document, ordered from start to end.  These TypedPosition objects mark
 * all the non-TLA+ portions of the document--that is, comments, strings, and PlusCal tokens.
 *
 * @return the partitioner's positions
 * @throws BadPositionCategoryException if getting the positions from the
 *         document fails
 */
protected final Position[] getPositions() throws BadPositionCategoryException {
    if (fCachedPositions == null) {
        fCachedPositions= fDocument.getPositions(fPositionCategory);
    } else if (CHECK_CACHE_CONSISTENCY) {
        Position[] positions= fDocument.getPositions(fPositionCategory);
        int len= Math.min(positions.length, fCachedPositions.length);
        for (int i= 0; i < len; i++) {
            if (!positions[i].equals(fCachedPositions[i]))
                System.err.println("FastPartitioner.getPositions(): cached position is not up to date: from document: " + toString(positions[i]) + " in cache: " + toString(fCachedPositions[i])); //$NON-NLS-1$ //$NON-NLS-2$
        }
        for (int i= len; i < positions.length; i++)
            System.err.println("FastPartitioner.getPositions(): new position in document: " + toString(positions[i])); //$NON-NLS-1$
        for (int i= len; i < fCachedPositions.length; i++)
            System.err.println("FastPartitioner.getPositions(): stale position in cache: " + toString(fCachedPositions[i])); //$NON-NLS-1$
    }
    return fCachedPositions;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:27,代码来源:TLAFastPartitioner.java

示例2: getPositions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * Returns the partitioners positions.
 * 
 * @return the partitioners positions
 * @throws BadPositionCategoryException
 *             if getting the positions from the document fails
 * @since 2.2
 */
protected final Position[] getPositions() throws BadPositionCategoryException {
	if (fCachedPositions == null) {
		fCachedPositions = fDocument.getPositions(fPositionCategory);
	} else if (CHECK_CACHE_CONSISTENCY) {
		Position[] positions = fDocument.getPositions(fPositionCategory);
		int len = Math.min(positions.length, fCachedPositions.length);
		for (int i = 0; i < len; i++) {
			if (!positions[i].equals(fCachedPositions[i]))
				System.err
						.println("FastPartitioner.getPositions(): cached position is not up to date: from document: " + toString(positions[i]) + " in cache: " + toString(fCachedPositions[i])); //$NON-NLS-1$ //$NON-NLS-2$
		}
		for (int i = len; i < positions.length; i++)
			System.err
					.println("FastPartitioner.getPositions(): new position in document: " + toString(positions[i])); //$NON-NLS-1$
		for (int i = len; i < fCachedPositions.length; i++)
			System.err
					.println("FastPartitioner.getPositions(): stale position in cache: " + toString(fCachedPositions[i])); //$NON-NLS-1$
	}
	return fCachedPositions;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:29,代码来源:DocumentPartitioner.java

示例3: getPositions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * Returns the partitioners positions.
 *
 * @return the partitioners positions
 * @throws BadPositionCategoryException if getting the positions from the document fails
 */
protected final Position[] getPositions() throws BadPositionCategoryException {
  if (fCachedPositions == null) {
    fCachedPositions = fDocument.getPositions(fPositionCategory);
  } else if (CHECK_CACHE_CONSISTENCY) {
    Position[] positions = fDocument.getPositions(fPositionCategory);
    int len = Math.min(positions.length, fCachedPositions.length);
    for (int i = 0; i < len; i++) {
      if (!positions[i].equals(fCachedPositions[i]))
        System.err.println(
            "FastPartitioner.getPositions(): cached position is not up to date: from document: "
                + toString(positions[i])
                + " in cache: "
                + toString(fCachedPositions[i])); // $NON-NLS-1$ //$NON-NLS-2$
    }
    for (int i = len; i < positions.length; i++)
      System.err.println(
          "FastPartitioner.getPositions(): new position in document: "
              + toString(positions[i])); // $NON-NLS-1$
    for (int i = len; i < fCachedPositions.length; i++)
      System.err.println(
          "FastPartitioner.getPositions(): stale position in cache: "
              + toString(fCachedPositions[i])); // $NON-NLS-1$
  }
  return fCachedPositions;
}
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:FastPartitioner.java

示例4: createEdit

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * Creates a new edition on the document of this factory.
 *
 * @param offset the offset of the edition at the point when is created.
 * @param length the length of the edition (not updated via the position update mechanism)
 * @param text the text to be replaced on the document
 * @return an <code>Edit</code> reflecting the edition on the document
 */
public Edit createEdit(int offset, int length, String text) throws BadLocationException {

	if (!fDocument.containsPositionCategory(fCategory)) {
		fDocument.addPositionCategory(fCategory);
		fUpdater= new DefaultPositionUpdater(fCategory);
		fDocument.addPositionUpdater(fUpdater);
	}

	Position position= new Position(offset);
	try {
		fDocument.addPosition(fCategory, position);
	} catch (BadPositionCategoryException e) {
		Assert.isTrue(false);
	}
	return new Edit(fDocument, length, text, position);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:BlockCommentAction.java

示例5: getExclusions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * Get all positions of the given position category
 * In sexp's these positions are typically skipped
 * 
 * @param doc
 * @param pos_names
 * @return the positions to exclude
 */
public static List<Position> getExclusions(IDocument doc, String[] pos_names) {
	List<Position> excludePositions = new LinkedList<Position>();
	String cat = getTypeCategory(doc);
	if (cat != null) {
		try {
			Position[] xpos = doc.getPositions(cat);
			for (int j = 0; j < xpos.length; j++) {
				if (xpos[j] instanceof TypedPosition) {

					for (int jj = 0; jj < pos_names.length; jj++) {
						if (((TypedPosition) xpos[j]).getType().contains(pos_names[jj])) {
							excludePositions.add(xpos[j]);
						}
					}
				}
			}
		} catch (BadPositionCategoryException e) {}
	}
	return excludePositions;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:29,代码来源:EmacsPlusUtils.java

示例6: partClosed

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
public void partClosed(IWorkbenchPartReference partRef) {
	
	if (partRef instanceof IEditorReference) {
		IEditorPart epart = ((IEditorReference) partRef).getEditor(false);
		ITextEditor editor = (location != null ? location.getEditor() : null);
		if (editor == EmacsPlusUtils.getTextEditor(epart, false)) {
			RegisterLocation loc = location;
			// we're out of here
			removeListener(this);
			IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
			// remove position category, if still present
			if (document.containsPositionCategory(MarkRing.MARK_CATEGORY)) {
				try {
					document.removePositionUpdater(MarkRing.updater);
					document.removePositionCategory(MarkRing.MARK_CATEGORY);
				} catch (BadPositionCategoryException e) {
				}
			}
			// convert to path
			loc.setPath(convertToPath(editor));
		}
	}
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:24,代码来源:TecoRegister.java

示例7: configureForwardReaderKeepingPositions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
public void configureForwardReaderKeepingPositions(int offset, int end) throws IOException,
        BadPositionCategoryException {
    if (!fSupportKeepPositions) {
        throw new AssertionError("configureForwardReader must be called with supportKeepPositions=true.");
    }
    fOffset = offset;
    fStartForwardOffset = offset;
    fForward = true;
    fEnd = Math.min(fDocument.getLength(), end);
    fcurrentPositionI = 0;
    if (fPositions.length > 0) {
        fCurrentPosition = fPositions[0];
    } else {
        fCurrentPosition = null;
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:17,代码来源:PartitionCodeReader.java

示例8: configureForwardReader

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
public void configureForwardReader(IDocument document, int offset, int end, boolean supportKeepPositions)
        throws IOException,
        BadPositionCategoryException {
    fSupportKeepPositions = supportKeepPositions;
    fDocument = document;
    fOffset = offset;
    fStartForwardOffset = offset;
    fForward = true;
    fEnd = Math.min(fDocument.getLength(), end);
    fcurrentPositionI = 0;
    fPositions = createPositions(document);
    if (fPositions.length > 0) {
        fCurrentPosition = fPositions[0];
    } else {
        fCurrentPosition = null;
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:18,代码来源:PartitionCodeReader.java

示例9: createPositions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
private Position[] createPositions(IDocument document) throws BadPositionCategoryException {
    Position[] positions = getDocumentTypedPositions(document, contentType);
    List<TypedPosition> typedPositions = PartitionMerger.sortAndMergePositions(positions, document.getLength());
    int size = typedPositions.size();
    List<Position> list = new ArrayList<Position>(size);
    for (int i = 0; i < size; i++) {
        Position position = typedPositions.get(i);
        if (isPositionValid(position, contentType)) {
            list.add(position);
        }
    }

    if (!fForward) {
        Collections.reverse(list);
    }
    Position[] ret = list.toArray(new Position[list.size()]);
    return ret;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:19,代码来源:PartitionCodeReader.java

示例10: DocCopy

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
public DocCopy(IDocument document) {
    this.contents = document.get();
    this.document = document;
    categoryToPos = new HashMap<>();
    String[] positionCategories = document.getPositionCategories();
    for (String string : positionCategories) {
        try {
            categoryToPos.put(string, document.getPositions(string));
        } catch (BadPositionCategoryException e) {
            Log.log(e);
        }
    }

    IDocumentExtension4 doc4 = (IDocumentExtension4) document;
    modificationStamp = doc4.getModificationStamp();
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:17,代码来源:DocCopy.java

示例11: processIOConsole

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
@SuppressWarnings("restriction")
private void processIOConsole(IOConsole ioConsole) {
    IDocument document = ioConsole.getDocument();
    try {
        Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
        Arrays.sort(positions, new Comparator<Position>() {

            @Override
            public int compare(Position o1, Position o2) {
                return Integer.compare(o1.getOffset(), o2.getOffset());
            }
        });
        if (positions.length > 0) {
            Position p = positions[positions.length - 1];
            if (p instanceof ConsoleHyperlinkPosition) {
                ConsoleHyperlinkPosition consoleHyperlinkPosition = (ConsoleHyperlinkPosition) p;
                IHyperlink hyperLink = consoleHyperlinkPosition.getHyperLink();
                hyperLink.linkActivated();
            }
        }
    } catch (BadPositionCategoryException e) {
        Log.log(e);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:25,代码来源:PyOpenLastConsoleHyperlink.java

示例12: ensurePositionCategoryRemoved

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
private void ensurePositionCategoryRemoved(IDocument document) {
	if (document.containsPositionCategory(getCategory())) {
		try {
			document.removePositionCategory(getCategory());
		} catch (BadPositionCategoryException e) {
			// ignore
		}
		document.removePositionUpdater(fUpdater);
	}
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:11,代码来源:EditorConfigCompletionProposal.java

示例13: getFirstPosition

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * <p>
 * Returns the first position of a specific category of the given document.
 * </p>
 * 
 * @param document the document to get the positions from
 * @param category the category of the position
 * 
 * @return a position. If there is none return <code>null</code>.
 */
public Position getFirstPosition(IDocument document, String category) {
	try {
		Position[] positions = document.getPositions(category);
		if (positions.length > 0) {
			return positions[0];
		}
	} catch (BadPositionCategoryException e) {
	}
	return null;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:21,代码来源:DwprofilePositionHelper.java

示例14: updateDocumentPositions

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * Traverses the OutlineNode tree and adds a Position for each
 * node to Document.
 * 
 * Also adds the nodes to type lists of the OutlineInput and 
 * calculates the tree depth.
 * 
 * Old Positions are removed before adding new ones.
 * 
 * @param rootNodes
 * @param monitor monitor for the job calling this method
 */
private void updateDocumentPositions(List<OutlineNode> rootNodes, IProgressMonitor monitor) {
    TexOutlineInput newOutlineInput = new TexOutlineInput(rootNodes);
    
    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    
    // remove previous positions
    try {
    	document.removePositionCategory("__outline");
    } catch (BadPositionCategoryException bpce) {
        // do nothing, the category will be added again next, it does not exists the first time
    }
    
    document.addPositionCategory("__outline");
    pollCancel(monitor);
    
    // add new positions for nodes and their children
    int maxDepth = 0;
    for (Iterator<OutlineNode> iter = rootNodes.iterator(); iter.hasNext(); ) {
        OutlineNode node = iter.next();
        int localDepth = addNodePosition(node, document, 0, newOutlineInput); 
        
        if (localDepth > maxDepth) {
            maxDepth = localDepth;
        }
        pollCancel(monitor);
    }
    pollCancel(monitor);

    // set the new outline input
    newOutlineInput.setTreeDepth(maxDepth);
    this.outlineInput = newOutlineInput;
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:45,代码来源:TexDocumentModel.java

示例15: disconnect

import org.eclipse.jface.text.BadPositionCategoryException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * May be extended by subclasses.
 * </p>
 */
public void disconnect() {

    Assert.isTrue(fDocument.containsPositionCategory(fPositionCategory));

    try {
        fDocument.removePositionCategory(fPositionCategory);
    } catch (BadPositionCategoryException x) {
        // can not happen because of Assert
    }
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:17,代码来源:TLAFastPartitioner.java


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