本文整理汇总了Java中org.eclipse.jface.text.rules.ITokenScanner类的典型用法代码示例。如果您正苦于以下问题:Java ITokenScanner类的具体用法?Java ITokenScanner怎么用?Java ITokenScanner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ITokenScanner类属于org.eclipse.jface.text.rules包,在下文中一共展示了ITokenScanner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public static void configure(TextLayout textLayout) {
String text = textLayout.getText();
Document doc = new Document(text);
ITokenScanner scanner = getRecipeScanner(doc);
scanner.setRange(doc, 0, doc.getLength());
IToken token;
while ((token = scanner.nextToken()) != Token.EOF) {
int offset = scanner.getTokenOffset();
int length = scanner.getTokenLength();
Object data = token.getData();
if (data != null && data instanceof TextStyle) {
TextStyle textStyle = (TextStyle) data;
textLayout.setStyle(textStyle, offset, offset + length - 1);
}
}
}
示例2: getRecipeScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
private static ITokenScanner getRecipeScanner(final IDocument doc) {
// IPreferenceStore store = Activator.getDefault().getPreferenceStore();
final InnerTagScanner scanner = new InnerTagScanner();
// store.addPropertyChangeListener(new IPropertyChangeListener() {
//
// public void propertyChange(PropertyChangeEvent event) {
// String property = event.getProperty();
// if (IPreferenceConstants.TAG_FOREGROUND.equals(property)
// || IPreferenceConstants.TAG_BACKGROUND.equals(property)) {
// scanner.updateToken(IPreferenceConstants.TAG_FOREGROUND, IPreferenceConstants.TAG_BACKGROUND);
//
// if (doc != null) { // 刷新
// try {
// doc.replace(doc.getLength(), 0, "");
// } catch (BadLocationException e) {
// e.printStackTrace();
// }
// }
// }
// }
// });
return scanner;
}
示例3: configure
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public static void configure(TextLayout textLayout) {
String text = textLayout.getText();
Document doc = new Document(text);
ITokenScanner scanner = getRecipeScanner(doc);
scanner.setRange(doc, 0, doc.getLength());
IToken token;
while ((token = scanner.nextToken()) != Token.EOF) {
int offset = scanner.getTokenOffset();
int length = scanner.getTokenLength();
Object data = token.getData();
if (data != null && data instanceof TextStyle) {
TextStyle textStyle = (TextStyle) data;
textLayout.setStyle(textStyle, offset, offset + length - 1);
}
}
scanner = null;
doc = null;
}
示例4: getRecipeScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
private static ITokenScanner getRecipeScanner(final IDocument doc) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
/*final*/ InnerTagScanner scanner = new InnerTagScanner(store, IColorPreferenceConstant.TAG_FG_COLOR,
IColorPreferenceConstant.TAG_BG_COLOR);
// store.addPropertyChangeListener(new IPropertyChangeListener() {
//
// public void propertyChange(PropertyChangeEvent event) {
// String property = event.getProperty();
// if (IColorPreferenceConstant.TAG_FG_COLOR.equals(property)
// || IColorPreferenceConstant.TAG_BG_COLOR.equals(property)) {
// scanner.updateToken(IColorPreferenceConstant.TAG_FG_COLOR, IColorPreferenceConstant.TAG_BG_COLOR);
//
// if (doc != null) { // 刷新
// try {
// doc.replace(doc.getLength(), 0, "");
// } catch (BadLocationException e) {
// e.printStackTrace();
// }
// }
// }
// }
// });
return scanner;
}
示例5: getPresentationReconciler
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
final PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
final SyntaxHighlighter scanner = new SyntaxHighlighter(
com.abstratt.mdd.frontend.textuml.core.TextUMLConstants.KEYWORDS);
final DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
reconciler.setDamager(dr, ContentTypes.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, ContentTypes.DEFAULT_CONTENT_TYPE);
// fix bug 2127735 --multiline comment is broken
final ITokenScanner commentScanner = scanner.getCommentScanner();
final DefaultDamagerRepairer commentDamagerRepairer = new DefaultDamagerRepairer(commentScanner);
reconciler.setDamager(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);
reconciler.setRepairer(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);
return reconciler;
}
示例6: getRecipeScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
private static ITokenScanner getRecipeScanner(final IDocument doc) {
// IPreferenceStore store = Activator.getDefault().getPreferenceStore();
InnerTagScanner scanner = new InnerTagScanner();
// store.addPropertyChangeListener(new IPropertyChangeListener() {
//
// public void propertyChange(PropertyChangeEvent event) {
// String property = event.getProperty();
// if (IPreferenceConstants.TAG_FOREGROUND.equals(property)
// || IPreferenceConstants.TAG_BACKGROUND.equals(property)) {
// scanner.updateToken(IPreferenceConstants.TAG_FOREGROUND, IPreferenceConstants.TAG_BACKGROUND);
//
// if (doc != null) { // 刷新
// try {
// doc.replace(doc.getLength(), 0, "");
// } catch (BadLocationException e) {
// e.printStackTrace();
// }
// }
// }
// }
// });
return scanner;
}
示例7: scan
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public static String scan(ITokenScanner scanner, IDocument document) {
scanner.setRange(document, 0, document.getLength());
ArrayList<String> found = new ArrayList<String>();
FastStringBuffer buf = new FastStringBuffer();
IToken token = scanner.nextToken();
while (!token.isEOF()) {
Object data = token.getData();
if (data != null) {
buf.clear();
buf.append(data.toString()).append(":");
buf.append(scanner.getTokenOffset()).append(":");
buf.append(scanner.getTokenLength());
found.add(buf.toString());
} else {
buf.clear();
buf.append("null").append(":");
buf.append(scanner.getTokenOffset()).append(":");
buf.append(scanner.getTokenLength());
found.add(buf.toString());
}
token = scanner.nextToken();
}
return listToExpected(found);
}
示例8: getPresentationReconciler
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
DSLPresentationReconciler reconciler = new DSLPresentationReconciler(sourceViewer);
ITokenScanner scanner = new TokenScanner();
String contentType = IDocument.DEFAULT_CONTENT_TYPE;
// TODO preference store
long delay = 300;
DefaultDamagerRepairer dr = new DelayedDamagerRepairer(scanner, reconciler, delay);
reconciler.setDamager(dr, contentType);
reconciler.setRepairer(dr, contentType);
// IResource file = this.extractResource(this.editor);
return reconciler;
}
示例9: getTLACodeScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
/**
* @return
*/
public ITokenScanner getTLACodeScanner()
{
if (tlaCodeScanner== null)
{
tlaCodeScanner = new TLACodeScanner();
}
return tlaCodeScanner;
}
示例10: getPCALCodeScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public ITokenScanner getPCALCodeScanner()
{
if (pcalCodeScanner== null)
{
pcalCodeScanner = new PCALCodeScanner();
}
return pcalCodeScanner;
}
示例11: getPreProcessorScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
/**
* getPreProcessorScanner
*
* @return
*/
private ITokenScanner getPreProcessorScanner()
{
XMLTagScanner preProcessorScanner = new XMLTagScanner();
preProcessorScanner.setDefaultReturnToken(getToken("meta.tag.preprocessor.xml.svg")); //$NON-NLS-1$
return preProcessorScanner;
}
示例12: processLanguage
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
protected void processLanguage(String language, short endToken) throws IOException, Exception
{
ITokenScanner tokenScanner = fScanner.getTokenScanner().getPrimaryTokenScanner();
if (tokenScanner instanceof HTMLTokenScanner)
{
((HTMLTokenScanner) tokenScanner).setInsideSpecialTag(true);
}
Symbol startTag = fCurrentSymbol;
advance();
int start = fCurrentSymbol.getStart();
int end = start - 1;
short id = fCurrentSymbol.getId();
while (id != endToken && id != HTMLTokens.EOF)
{
end = fCurrentSymbol.getEnd();
advance();
id = fCurrentSymbol.getId();
}
if (tokenScanner instanceof HTMLTokenScanner)
{
((HTMLTokenScanner) tokenScanner).setInsideSpecialTag(false);
}
IParseNode[] nested = getParseResult(language, start, end);
if (fCurrentElement != null)
{
HTMLSpecialNode node = new HTMLSpecialNode(startTag, nested, startTag.getStart(), fCurrentSymbol.getEnd());
node.setEndNode(fCurrentSymbol.getStart(), fCurrentSymbol.getEnd());
parseAttribute(node, startTag);
fCurrentElement.addChild(node);
}
}
示例13: ThemeingDamagerRepairer
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public ThemeingDamagerRepairer(ITokenScanner scanner)
{
super(scanner);
maxLinesToColor = Platform.getPreferencesService().getInt(CommonEditorPlugin.PLUGIN_ID,
IPreferenceConstants.EDITOR_MAX_COLORED_COLUMNS,
IPreferenceConstants.EDITOR_MAX_COLORED_COLUMNS_DEFAULT,
new IScopeContext[] { EclipseUtil.instanceScope(), EclipseUtil.defaultScope() });
}
示例14: Entry
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
public Entry(ITokenScanner tokenScanner, IToken token, int offset, int length)
{
this.tokenScanner = tokenScanner;
this.token = token;
this.offset = offset;
this.length = length;
}
示例15: getStartEndTokenScanner
import org.eclipse.jface.text.rules.ITokenScanner; //导入依赖的package包/类
private ITokenScanner getStartEndTokenScanner() {
if (startEndTokenScanner == null) {
RuleBasedScanner ts = new RuleBasedScanner();
IToken seqToken = new Token(getStartEndTokenType());
List<IRule> rules = new ArrayList<IRule>();
for (String[] pair : getPartitionerSwitchStrategy().getSwitchTagPairs()) {
rules.add(new SingleTagRule(pair[0], seqToken));
rules.add(new SingleTagRule(pair[1], seqToken));
}
ts.setRules(rules.toArray(new IRule[rules.size()]));
ts.setDefaultReturnToken(new Token("text")); //$NON-NLS-1$
startEndTokenScanner = ts;
}
return startEndTokenScanner;
}