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


Java TextUtilities.indexOf方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.TextUtilities.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtilities.indexOf方法的具体用法?Java TextUtilities.indexOf怎么用?Java TextUtilities.indexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.TextUtilities的用法示例。


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

示例1: isBlockCommented

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
	try {
		// check for occurrences of prefixes in the given lines
		for (int i = startLine; i <= endLine; i++) {
			IRegion line = document.getLineInformation(i);
			String text = document.get(line.getOffset(), line.getLength());
			int[] found = TextUtilities.indexOf(prefixes, text, 0);
			if (found[0] == -1) {
				// found a line which is not commented
				return false;
			}
			String s = document.get(line.getOffset(), found[0]);
			s = s.trim();
			if (s.length() != 0) {
				// found a line which is not commented
				return false;
			}
		}
		return true;
	} catch (BadLocationException x) {
		// should not happen
	}
	return false;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:25,代码来源:DwprofileToggleCommentHandler.java

示例2: isBlockCommented

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Determines whether each line is prefixed by one of the prefixes.
 *
 * @param startLine Start line in document
 * @param endLine End line in document
 * @param prefixes Possible comment prefixes
 * @param document The document
 * @return <code>true</code> iff each line from <code>startLine</code>
 *             to and including <code>endLine</code> is prepended by one
 *             of the <code>prefixes</code>, ignoring whitespace at the
 *             begin of line
 */
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document)
{

    try
    {

        // check for occurrences of prefixes in the given lines
        for (int i = startLine; i <= endLine; i++)
        {

            IRegion line = document.getLineInformation(i);
            String text = document.get(line.getOffset(), line.getLength());

            int[] found = TextUtilities.indexOf(prefixes, text, 0);

            if (found[0] == -1)
                // found a line which is not commented
                return false;

            String s = document.get(line.getOffset(), found[0]);
            s = s.trim();
            if (s.length() != 0)
                // found a line which is not commented
                return false;

        }

        return true;

    } catch (BadLocationException x)
    {
        // should not happen
        // TODO
    }

    return false;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:50,代码来源:ToggleCommentAction.java

示例3: isBlockCommented

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Determines whether each line is prefixed by one of the prefixes.
 *
 * @param startLine Start line in document
 * @param endLine End line in document
 * @param prefixes Possible comment prefixes
 * @param document The document
 * @return <code>true</code> iff each line from <code>startLine</code>
 *             to and including <code>endLine</code> is prepended by one
 *             of the <code>prefixes</code>, ignoring whitespace at the
 *             begin of line
 * @since 2.1
 */
protected boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {

	try {

		// check for occurrences of prefixes in the given lines
		for (int i= startLine; i <= endLine; i++) {

			IRegion line= document.getLineInformation(i);
			String text= document.get(line.getOffset(), line.getLength());

			int[] found= TextUtilities.indexOf(prefixes, text, 0);

			if (found[0] == -1)
				// found a line which is not commented
				return false;

			String s= document.get(line.getOffset(), found[0]);
			s= s.trim();
			if (s.length() != 0)
				// found a line which is not commented
				return false;

		}

		return true;

	} catch (BadLocationException x) {
		// should not happen
		log.error(x.getMessage(), x);
	}

	return false;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:ToggleSLCommentAction.java

示例4: isBlockCommented

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Determines whether each line is prefixed by one of the prefixes.
 * 
 * @param startLine
 *            Start line in document
 * @param endLine
 *            End line in document
 * @param prefixes
 *            Possible comment prefixes
 * @param document
 *            The document
 * @return <code>true</code> iff each line from <code>startLine</code>
 *         to and including <code>endLine</code> is prepended by one of
 *         the <code>prefixes</code>, ignoring whitespace at the begin of
 *         line
 */
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document)
{
    try
    {
        // check for occurrences of prefixes in the given lines
        for (int i = startLine; i <= endLine; i++)
        {
            IRegion line = document.getLineInformation(i);
            String text = document.get(line.getOffset(), line.getLength());
            int[] found = TextUtilities.indexOf(prefixes, text, 0);
            if (found[0] == -1)
            // found a line which is not commented
                return false;
            String s = document.get(line.getOffset(), found[0]);
            s = s.trim();
            if (s.length() != 0)
            // found a line which is not commented
                return false;
        }
        return true;
    }
    catch (BadLocationException x)
    {
        // should not happen
        // JavaPlugin.log(x);
    }
    return false;
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:45,代码来源:ToggleCommentAction.java

示例5: isBlockCommented

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Determines whether each line is prefixed by one of the prefixes.
 *
 * @param startLine Start line in document
 * @param endLine End line in document
 * @param prefixes Possible comment prefixes
 * @param document The document
 * @return <code>true</code> iff each line from <code>startLine</code>
 *             to and including <code>endLine</code> is prepended by one
 *             of the <code>prefixes</code>, ignoring whitespace at the
 *             begin of line
 */
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {

	try {

		// check for occurrences of prefixes in the given lines
		for (int i= startLine; i <= endLine; i++) {

			IRegion line= document.getLineInformation(i);
			String text= document.get(line.getOffset(), line.getLength());

			int[] found= TextUtilities.indexOf(prefixes, text, 0);

			if (found[0] == -1)
				// found a line which is not commented
				return false;

			String s= document.get(line.getOffset(), found[0]);
			s= s.trim();
			if (s.length() != 0)
				// found a line which is not commented
				return false;

		}

		return true;

	} catch (BadLocationException x) {
		// should not happen
		JavaPlugin.log(x);
	}

	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:46,代码来源:ToggleCommentAction.java

示例6: isBlockCommented

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Determines whether each line is prefixed by one of the prefixes.
 *
 * @param startLine Start line in document
 * @param endLine End line in document
 * @param prefixes Possible comment prefixes
 * @param document The document
 * @return <code>true</code> iff each line from <code>startLine</code>
 *             to and including <code>endLine</code> is prepended by one
 *             of the <code>prefixes</code>, ignoring whitespace at the
 *             begin of line
 */
protected boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {

	try {

		// check for occurrences of prefixes in the given lines
		for (int i= startLine; i <= endLine; i++) {

			IRegion line= document.getLineInformation(i);
			String text= document.get(line.getOffset(), line.getLength());

			int[] found= TextUtilities.indexOf(prefixes, text, 0);

			if (found[0] == -1)
				// found a line which is not commented
				return false;

			String s= document.get(line.getOffset(), found[0]);
			s= s.trim();
			if (s.length() != 0)
				// found a line which is not commented
				return false;

		}

		return true;

	} catch (BadLocationException x) {
		// should not happen
		LangCore.logError("Unexpected error.", x);
	}

	return false;
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:46,代码来源:ToggleCommentAction.java


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