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


Java TextUtilities.endsWith方法代码示例

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


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

示例1: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
@Override
public void customizeDocumentCommand(final IDocument doc, final DocumentCommand cmd) {
	if (cmd.length != 0 || cmd.text == null) return;

	try {
		if (TextUtilities.endsWith(doc.getLegalLineDelimiters(), cmd.text) != -1) {
			if (AutoEdit.isBlankLine(doc, cmd.offset)) {
				int beg = AutoEdit.getLineOffset(doc, cmd.offset);
				int len = cmd.offset - beg;

				DeleteEdit blanks = new DeleteEdit(beg, len);
				blanks.apply(doc);
				cmd.offset = beg;

			} else {
				autoIndent(doc, cmd, false);	// return entered
			}

		} else if (evaluateInsertPoint(doc, cmd)) {
			autoIndent(doc, cmd, true);		// insert point exceeds limit
		} else if (evaluateLineWidth(doc, cmd)) {
			wrapLines(doc, cmd);			// line end exceeds limit
		}
	} catch (BadLocationException e) {}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:26,代码来源:LineWrapEditStrategy.java

示例2: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {

		if (!isSmartMode())
			return;

		if (command.text != null) {
			if (command.length == 0) {
				String[] lineDelimiters = document.getLegalLineDelimiters();
				int index = TextUtilities.endsWith(lineDelimiters, command.text);
				if (index > -1) {
					// ends with line delimiter
					if (lineDelimiters[index].equals(command.text))
						// just the line delimiter
						indentAfterNewLine(document, command);
					return;
				}
			}

			if (command.text.equals("/")) { //$NON-NLS-1$
				indentAfterCommentEnd(document, command);
				return;
			}
		}
	}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:25,代码来源:JSDocAutoIndentStrategy.java

示例3: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
@Override
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {

	if (!isSmartMode())
		return;

	if (command.text != null) {
		if (command.length == 0) {
			String[] lineDelimiters= document.getLegalLineDelimiters();
			int index= TextUtilities.endsWith(lineDelimiters, command.text);
			if (index > -1) {
				// ends with line delimiter
				if (lineDelimiters[index].equals(command.text))
					// just the line delimiter
					indentAfterNewLine(document, command);
				return;
			}
		}

		if (command.text.equals("/")) { //$NON-NLS-1$
			indentAfterCommentEnd(document, command);
			return;
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:JavaDocAutoIndentStrategy.java

示例4: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
@Override
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
	
	if (c.length == 0 && c.text != null && TextUtilities.endsWith(d.getLegalLineDelimiters(), c.text) != -1) {
		super.customizeDocumentCommand(d, c);
	} else {
		return;
	}
	
	try {
		//check if previous character was an opening brace
		if (d.getChar(c.offset -1 ) == OPEN_BRACE) {
			//we need to add a tab and a new line
			c.text = c.text + "\t\n";
			c.shiftsCaret = false;
			c.caretOffset = c.offset + c.text.length() - 1;
			super.customizeDocumentCommand(d, c);
		}
	} catch (Exception ex) {
		//do nothing
	}		
}
 
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:23,代码来源:SimpleIndentBracesOnEnterStrategy.java

示例5: getLineLength

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Returns a length of a line.
 * @param document 	IDocument that contains the line.
 * @param command 	DocumentCommand that determines the line.
 * @param delim 	are line delimiters counted to the line length 
 * @param target 	-1 = previous line, 0 = current line, 1 = next line etc... 
 * @return 			the line length 
 */
public int getLineLength(IDocument document, DocumentCommand command, 
		boolean delim, int target) {
	int line;
	
	int length = 0;
	try{
		line = document.getLineOfOffset(command.offset) + target;
		if (line < 0 || line >= document.getNumberOfLines()){
			//line = document.getLineOfOffset(command.offset);
			return 0;
		}
		
		length = document.getLineLength(line);
		if (length == 0){
			return 0;
		}
		if (!delim){
			String txt = document.get(document.getLineOffset(line), document.getLineLength(line));
			String[] del = document.getLegalLineDelimiters();
			int cnt = TextUtilities.endsWith(del ,txt);
			if (!delim && cnt > -1){
				length = length - del[cnt].length();				
			}
		}
	}catch(BadLocationException e){
		TexlipsePlugin.log("TexEditorTools.getLineLength:",e);
	}
	return length;
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:38,代码来源:TexEditorTools.java

示例6: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
    if (this.indent) {
        if (itemSetted && autoItem && command.length == 0 && command.text != null
                && TextUtilities.endsWith(document.getLegalLineDelimiters(), command.text) != -1) {
            dropItem(document, command);
        } else if (command.length == 0 && command.text != null
                &&  TextUtilities.endsWith(document.getLegalLineDelimiters(), command.text) != -1) {
            smartIndentAfterNewLine(document, command);
        } else if ("}".equals(command.text)) {
            smartIndentAfterBrace(document, command);
        } else {
            itemSetted = false;
        }
    }

    if (TexAutoIndentStrategy.hardWrap && command.length == 0 && command.text != null) {
        try {
            final String contentType = ((IDocumentExtension3) document).getContentType(
                    TexEditor.TEX_PARTITIONING, command.offset, true);
            // Do not wrap in verbatim partitions
            if (!FastLaTeXPartitionScanner.TEX_VERBATIM.equals(contentType)) {
                hlw.doWrapB(document, command, lineLength);
            }
        }
        catch (Exception e) {
            // If we cannot retrieve the current content type, do not break lines
        }
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:30,代码来源:TexAutoIndentStrategy.java

示例7: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
@Override
public void customizeDocumentCommand(@Nullable IDocument d, @Nullable DocumentCommand c) {
	if (c==null || d == null) {
		return;
	}
	if (c.length == 0 && c.text != null) {
		if (TextUtilities.endsWith(d.getLegalLineDelimiters(), c.text) != -1) {
			autoIndentAfterNewLine(d, c);
		} else if (c.text.equals("}")) {
			adjustClosingBracePosition(d, c);
		}
	}
}
 
开发者ID:peq,项目名称:rustyeclipse,代码行数:14,代码来源:RustAutoIndentStrategy.java

示例8: customizeDocumentCommand

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
@Override
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {

	if (c.length == 0 && c.text != null && TextUtilities.endsWith(d.getLegalLineDelimiters(), c.text) != -1) {
		autoIndentAfterNewLine(d, c);
	}
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:8,代码来源:JsonIndentLineAutoEditStrategy.java

示例9: smartIndentAfterNewLine

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
     * Performs indentation after new line is detected.
     * 
     * @param document Document where new line is detected.
     * @param command Command that represent the change of the document (new
     *            line).
     */
    private void smartIndentAfterNewLine(IDocument document, DocumentCommand command) {
        try {
            itemSetted = false;
            int commandOffset = command.offset;
            int line = document.getLineOfOffset(commandOffset);
            int lineOffset = document.getLineOffset(line);
            String startLine = document.get(lineOffset, commandOffset - lineOffset);
            //this is save
            String lineDelimiter = document.getLegalLineDelimiters()
                [TextUtilities.endsWith(document.getLegalLineDelimiters(), command.text)];
            int beginIndex;
            if ((beginIndex = LatexParserUtils.findCommand(startLine, "\\begin", 0)) != -1) {
                // test if line contains \begin and search the environment (itemize,
                // table...)
                IRegion r = LatexParserUtils.getCommandArgument(startLine, beginIndex);
                if (r == null){
                	//No environment found
                    super.customizeDocumentCommand(document, command);
                    return;
                }
                String envName = startLine.substring(r.getOffset(), r.getOffset()+r.getLength());
                StringBuilder buf = new StringBuilder(command.text);

                // get indentation of \begin
/*                String prevIndentation = this.tools.getIndentation(document, line,
                        "\\begin", this.tabWidth); // NEW*/
                String prevIndentation = getIndentation(startLine);
                
                if (Arrays.binarySearch(this.indentationItems, envName) >= 0) {
                    buf.append(prevIndentation);
                    buf.append(this.indentationString);
                } else {
                    buf.append(prevIndentation);
                }
                
                if (autoItem && (envName.equals("itemize") || envName.equals("enumerate"))) {
                    buf.append("\\item ");
                    itemSetted = true;
                    itemAtLine = document.getLineOfOffset(command.offset);
                } else if (autoItem && envName.equals("description")) {
                    buf.append("\\item[]");
                    itemSetted = true;
                    itemAtLine = document.getLineOfOffset(command.offset);
                }

                command.caretOffset = command.offset + buf.length();
                command.shiftsCaret = false;
                if (autoItem && envName.equals("description")) {
                    command.caretOffset--;
                }
                
                /*
                 * looks for the \begin-statement and inserts
                 * an equivalent \end-statement (respects \begin-indentation)
                 */
                if (needsEnd(envName, document.get(), lineOffset)){
                    buf.append(lineDelimiter);
                    buf.append(prevIndentation);
                    buf.append("\\end{" + envName + "}");
                }
                command.text = buf.toString();
                
            } else {
                if (autoItem && !itemInserted(document, command)) {
                    super.customizeDocumentCommand(document, command);
                } else {
                    super.customizeDocumentCommand(document, command);
                }
            }
        } catch (BadLocationException e) {
            TexlipsePlugin.log("TexAutoIndentStrategy:SmartIndentAfterNewLine", e);
        }
    }
 
开发者ID:eclipse,项目名称:texlipse,代码行数:81,代码来源:TexAutoIndentStrategy.java

示例10: endsWithDelimiter

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Returns whether or not the given text ends with one of the documents legal line delimiters.
 * 
 * @param d the document
 * @param txt the text
 * @return <code>true</code> if <code>txt</code> ends with one of the document's line delimiters, <code>false</code> otherwise
 */
private boolean endsWithDelimiter(IDocument d, String txt) {
	String[] delimiters = d.getLegalLineDelimiters();
	if (delimiters != null)
		return TextUtilities.endsWith(delimiters, txt) > -1;
	return false;
}
 
开发者ID:ncleclipse,项目名称:ncl30-eclipse,代码行数:14,代码来源:XMLAutoIdentStrategy.java

示例11: endsWithDelimiter

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Returns whether or not the given text ends with one of the documents legal
 * line delimiters.
 *
 * @param d the document
 * @param txt the text
 * @return <code>true</code> if <code>txt</code> ends with one of the
 *         document's line delimiters, <code>false</code> otherwise
 */
private boolean endsWithDelimiter(IDocument d, String txt) {
  String[] delimiters = d.getLegalLineDelimiters();
  if (delimiters != null) {
    return TextUtilities.endsWith(delimiters, txt) > -1;
  }

  return false;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:18,代码来源:JsniAutoEditStrategy.java

示例12: endsWithDelimiter

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Returns whether or not the given text ends with one of the documents legal line delimiters.
 *
 * @param d the document
 * @param txt the text
 * @return <code>true</code> if <code>txt</code> ends with one of the document's line delimiters,
 * <code>false</code> otherwise
 */
private boolean endsWithDelimiter(final IDocument d, final String txt) {
    String[] delimiters = d.getLegalLineDelimiters();
    if (delimiters != null) {
        return TextUtilities.endsWith(delimiters, txt) > -1;
    }
    return false;
}
 
开发者ID:apache,项目名称:syncope,代码行数:16,代码来源:HTMLAutoEditStrategy.java

示例13: endsWithDelimiter

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Returns whether or not the given text ends with one of the documents legal line delimiters.
 * 
 * @param d
 *            the document
 * @param txt
 *            the text
 * @return <code>true</code> if <code>txt</code> ends with one of the document's line delimiters,
 *         <code>false</code> otherwise
 */
private static boolean endsWithDelimiter(IDocument d, String txt) {
    String[] delimiters = d.getLegalLineDelimiters();
    if (delimiters != null) {
        return TextUtilities.endsWith(delimiters, txt) > -1;
    }
    return false;
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:18,代码来源:ApexAutoIndentStrategy.java

示例14: isEnter

import org.eclipse.jface.text.TextUtilities; //导入方法依赖的package包/类
/**
 * Returns true if text of the command is an enter and false otherwise.
 * 
 * @param d
 * @param c
 * @return true if text of the command is an enter and false otherwise.
 */
public static boolean isEnter(IDocument d, DocumentCommand c) {
	return (c.length == 0 && c.text != null && TextUtilities.endsWith(d.getLegalLineDelimiters(), c.text) != -1);
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:11,代码来源:TextUtils.java


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