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


Java ICharacterScanner.getLegalLineDelimiters方法代码示例

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


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

示例1: evaluate

import org.eclipse.jface.text.rules.ICharacterScanner; //导入方法依赖的package包/类
@Override
public IToken evaluate(ICharacterScanner scanner) {
	int c;
	if ((c = scanner.read()) != '[') {
		if ((c != 'h' || (!sequenceDetected(scanner, "http://".toCharArray(), false)
				&& !sequenceDetected(scanner, "https://".toCharArray(), false)))
				&& (c != 'f' || !sequenceDetected(scanner, "ftp://".toCharArray(), false))) {
			// Not even a non-standard link
			scanner.unread();
			return Token.UNDEFINED;
		}

		// + preventing NPE (Non-standard link should not be below as comment above suggests) by
		// Paul Verest
		if (fDelimiters == null) {
			scanner.unread();
			return Token.UNDEFINED;
		}

		// Non-standard link
		while ((c = scanner.read()) != ICharacterScanner.EOF && !Character.isWhitespace(c)) {
			for (char[] fDelimiter : fDelimiters) {
				if (c == fDelimiter[0] && sequenceDetected(scanner, fDelimiter, true)) {
					return fToken;
				}
			}
		}
		return fToken;
	}
	if (fDelimiters == null) {
		fDelimiters = scanner.getLegalLineDelimiters();
	}
	int readCount = 1;

	// Find '](' and then find ')'
	boolean sequenceFound = false;
	int delimiterFound = 0;
	while ((c = scanner.read()) != ICharacterScanner.EOF && delimiterFound < 2) {
		readCount++;
		if (!sequenceFound && c == ']') {
			c = scanner.read();
			if (c == '(') {
				readCount++;
				sequenceFound = true;
			} else {
				scanner.unread();
			}
		} else if (c == ')') { // '](' is already found
			return fToken;
		}

		int i;
		for (i = 0; i < fDelimiters.length; i++) {
			if (c == fDelimiters[i][0] && sequenceDetected(scanner, fDelimiters[i], true)) {
				delimiterFound++;
				break;
			}
		}
		if (i == fDelimiters.length) delimiterFound = 0;
	}

	for (; readCount > 0; readCount--) {
		scanner.unread();
	}
	return Token.UNDEFINED;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:67,代码来源:LinkRule.java

示例2: evaluate

import org.eclipse.jface.text.rules.ICharacterScanner; //导入方法依赖的package包/类
public IToken evaluate(ICharacterScanner scanner) {
	// Should be connected only on the right side
	scanner.unread();
	boolean sawSpaceBefore = Character.isWhitespace(scanner.read());
	if (!sawSpaceBefore && scanner.getColumn() != 0) {
		return Token.UNDEFINED;
	}

	int c = scanner.read();
	// Should be connected only on right side
	if (c != fSequence[0] || !sequenceDetected(scanner, fSequence, false)) {
		scanner.unread();
		return Token.UNDEFINED;
	}
	int readCount = fSequence.length;
	if (fDelimiters == null) {
		fDelimiters = scanner.getLegalLineDelimiters();
	}
	// Start sequence detected
	int delimiterFound = 0;
	// Is it a list item marker, or just a floating *?
	if (sawSpaceBefore) {
		boolean after = Character.isWhitespace(scanner.read());
		scanner.unread();
		if (after) delimiterFound = 2;
	}

	while (delimiterFound < 2 && (c = scanner.read()) != ICharacterScanner.EOF) {
		readCount++;

		if (!sawSpaceBefore && c == fSequence[0] && sequenceDetected(scanner, fSequence, false)) {
			return fToken;
		}

		int i;
		for (i = 0; i < fDelimiters.length; i++) {
			if (c == fDelimiters[i][0] && sequenceDetected(scanner, fDelimiters[i], true)) {
				delimiterFound++;
				break;
			}
		}
		if (i == fDelimiters.length) delimiterFound = 0;
		sawSpaceBefore = Character.isWhitespace(c);
	}
	// Reached ICharacterScanner.EOF
	for (; readCount > 0; readCount--) {
		scanner.unread();
	}
	return Token.UNDEFINED;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:51,代码来源:EmphasisRule.java

示例3: endSequenceDetected

import org.eclipse.jface.text.rules.ICharacterScanner; //导入方法依赖的package包/类
/**
 * Returns whether the end sequence was detected. As the pattern can be considered ended by a
 * line delimiter, the result of this method is <code>true</code> if the rule breaks on the end
 * of the line, or if the EOF character is read.
 *
 * @param scanner the character scanner to be used
 * @return <code>true</code> if the end sequence has been detected
 */
protected boolean endSequenceDetected(ICharacterScanner scanner) {
	char[][] originalDelimiters = scanner.getLegalLineDelimiters();
	int count = originalDelimiters.length;
	if (fLineDelimiters == null || fLineDelimiters.length != count) {
		fSortedLineDelimiters = new char[count][];
	} else {
		while (count > 0 && Arrays.equals(fLineDelimiters[count - 1], originalDelimiters[count - 1])) {
			count--;
		}
	}
	if (count != 0) {
		fLineDelimiters = originalDelimiters;
		System.arraycopy(fLineDelimiters, 0, fSortedLineDelimiters, 0, fLineDelimiters.length);
		Arrays.sort(fSortedLineDelimiters, fLineDelimiterComparator);
	}

	int readCount = 1;
	int c;
	while ((c = scanner.read()) != ICharacterScanner.EOF) {
		if (c == fEscapeCharacter) {
			// Skip escaped character(s)
			if (fEscapeContinuesLine) {
				c = scanner.read();
				for (int i = 0; i < fSortedLineDelimiters.length; i++) {
					if (c == fSortedLineDelimiters[i][0]
							&& sequenceDetected(scanner, fSortedLineDelimiters[i], fBreaksOnEOF)) {
						break;
					}
				}
			} else {
				scanner.read();
			}

			// Check if the specified end sequence has been found.
		} else if (sequenceDetected(scanner, fEndSequence, false, fBreaksOnEOF)) {
			return true;
		} else if (fBreaksOnEOL) {
			// Check for end of line since it can be used to terminate the pattern.
			for (int i = 0; i < fSortedLineDelimiters.length; i++) {
				if (c == fSortedLineDelimiters[i][0]
						&& sequenceDetected(scanner, fSortedLineDelimiters[i], true, fBreaksOnEOF))
					return true;
			}
		}
		readCount++;
	}

	if (fBreaksOnEOF) return true;

	for (; readCount > 0; readCount--)
		scanner.unread();

	return false;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:63,代码来源:MatchRule.java


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