本文整理汇总了Java中org.netbeans.editor.Syntax类的典型用法代码示例。如果您正苦于以下问题:Java Syntax类的具体用法?Java Syntax怎么用?Java Syntax使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Syntax类属于org.netbeans.editor包,在下文中一共展示了Syntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.netbeans.editor.Syntax; //导入依赖的package包/类
/** Goes through all the syntaxes and inits them. If the multi-state-info has
* valid state-info for the given syntax the state-info is used.
* Otherwise the syntax is inited to the init state.
*/
void load(MultiSyntax masterSyntax, char[] buffer, int offset, int len,
boolean lastBuffer, int stopPosition) {
SyntaxInfo syntaxItem = masterSyntax.slaveSyntaxChain;
while (syntaxItem != null) {
StateInfo loadInfo = null;
int masterOffsetDelta = 0;
Syntax s = syntaxItem.syntax;
if (syntaxItem.active) {
Class sc = s.getClass();
ChainItem item = stateInfoChain;
while (item != null) {
if (item.syntaxClass == sc && item.valid) {
loadInfo = item.stateInfo;
masterOffsetDelta = item.masterOffsetDelta;
break;
}
item = item.prev;
}
}
s.load(loadInfo, buffer, offset + masterOffsetDelta,
len - masterOffsetDelta, lastBuffer, stopPosition);
syntaxItem = syntaxItem.next;
}
}
示例2: compare
import org.netbeans.editor.Syntax; //导入依赖的package包/类
int compare(MultiSyntax masterSyntax) {
int ret = Syntax.EQUAL_STATE;
// Go through valid state-info chain items
ChainItem item = stateInfoChain;
while (item != null && ret == Syntax.EQUAL_STATE) {
if (item.valid) {
Class sc = item.syntaxClass;
SyntaxInfo syntaxItem = masterSyntax.slaveSyntaxChain;
while (syntaxItem != null) {
if (syntaxItem.syntax.getClass() == sc) {
if (syntaxItem.active) {
ret = syntaxItem.syntax.compareState(item.stateInfo);
} else { // syntax not active but should be
ret = Syntax.DIFFERENT_STATE;
}
break;
}
syntaxItem = syntaxItem.next;
}
}
item = item.prev;
}
return ret;
}
示例3: doParse
import org.netbeans.editor.Syntax; //导入依赖的package包/类
private void doParse(String m, TokenID[] expected) {
Syntax s = new PolicySyntax();
s.load(null, m.toCharArray(), 0, m.length(), true, m.length());
TokenID token = null;
Iterator i = Arrays.asList(expected).iterator();
do {
token = s.nextToken();
if (token != null) {
if (!i.hasNext()) {
fail("More tokens returned than expected.");
} else {
assertSame("Tokens differ", i.next(), token);
}
} else {
assertFalse("More tokens expected than returned.", i.hasNext());
}
System.out.println(token);
} while (token != null);
System.out.println("---");
}
示例4: doParse
import org.netbeans.editor.Syntax; //导入依赖的package包/类
public void doParse(String m, List expected) {
Syntax s = new ManifestSyntax();
s.load(null, m.toCharArray(), 0, m.length(), true, m.length());
TokenID token = null;
Iterator i = expected.iterator();
do {
token = s.nextToken();
if (token != null) {
if (!i.hasNext()) {
fail("More tokens returned than expected.");
} else {
assertSame("Tokens differ", i.next(), token);
}
} else {
assertFalse("More tokens expected than returned.", i.hasNext());
}
System.out.println(token);
} while (token != null);
}
示例5: doParse
import org.netbeans.editor.Syntax; //导入依赖的package包/类
private void doParse(String m, TokenID[] expected) {
Syntax s = new ManifestSyntax();
s.load(null, m.toCharArray(), 0, m.length(), true, m.length());
TokenID token = null;
Iterator i = Arrays.asList(expected).iterator();
do {
token = s.nextToken();
if (token != null) {
if (!i.hasNext()) {
fail("More tokens returned than expected.");
} else {
assertSame("Tokens differ", i.next(), token);
}
} else {
assertFalse("More tokens expected than returned.", i.hasNext());
}
System.out.println(token);
} while (token != null);
}
示例6: registerSyntax
import org.netbeans.editor.Syntax; //导入依赖的package包/类
/** Register a particular slave syntax. */
protected void registerSyntax(Syntax slaveSyntax) {
slaveSyntaxChainEnd = new SyntaxInfo(slaveSyntax, slaveSyntaxChainEnd);
if (slaveSyntaxChain == null) {
slaveSyntaxChain = slaveSyntaxChainEnd;
}
}
示例7: store
import org.netbeans.editor.Syntax; //导入依赖的package包/类
void store(MultiSyntax masterSyntax) {
// Invalidate all state-info chain items
ChainItem item = stateInfoChain;
while (item != null) {
item.valid = false;
item = item.prev;
}
// Go through active syntaxes and store their info and master-offset
SyntaxInfo syntaxItem = masterSyntax.slaveSyntaxChain;
while (syntaxItem != null) {
if (syntaxItem.active) {
Syntax s = syntaxItem.syntax;
Class sc = s.getClass();
item = stateInfoChain;
while (item != null) {
if (item.syntaxClass == sc) { // found right item
break;
}
item = item.prev;
}
if (item == null) { // not found, add new
item = stateInfoChain = new ChainItem(s.createStateInfo(),
sc, stateInfoChain);
}
// Store the state and compute masterOffsetDelta
s.storeState(item.stateInfo);
item.masterOffsetDelta = s.getOffset() - masterSyntax.getOffset();
item.valid = true;
}
syntaxItem = syntaxItem.next;
}
}
示例8: SyntaxInfo
import org.netbeans.editor.Syntax; //导入依赖的package包/类
SyntaxInfo(Syntax syntax, SyntaxInfo prevChainEnd) {
this.syntax = syntax;
if (prevChainEnd != null) {
prev = prevChainEnd;
prevChainEnd.next = this;
}
}
示例9: compareSubStates
import org.netbeans.editor.Syntax; //导入依赖的package包/类
/** @return whether passed substates equals to this substates. */
public int compareSubStates(int[] sub) {
if (states == null) return Syntax.DIFFERENT_STATE;
if (sub == null) return Syntax.DIFFERENT_STATE;
if (states.length != sub.length) return Syntax.DIFFERENT_STATE;
for (int i = states.length-1; i>=0; i--) { //faster
if (states[i] != sub[i]) return Syntax.DIFFERENT_STATE;
}
return Syntax.EQUAL_STATE;
}
示例10: createSyntax
import org.netbeans.editor.Syntax; //导入依赖的package包/类
@Override
public Syntax createSyntax(Document doc) {
Syntax syn = null;
LegacySyntaxBridge bridge = MimeLookup.getLookup(getContentType()).lookup(LegacySyntaxBridge.class);
if (bridge != null) {
syn = bridge.createSyntax(this, doc, getContentType());
}
return syn != null ? syn : super.createSyntax(doc);
}
示例11: createSyntax
import org.netbeans.editor.Syntax; //导入依赖的package包/类
/**
* Create a syntax object suitable for highlighting Policy file syntax
*/
public Syntax createSyntax(Document doc) {
if (LOG) {
LOGGER.log(ErrorManager.INFORMATIONAL, "createSyntax"); // NOI18N
}
return new PolicySyntax();
}
示例12: createSyntax
import org.netbeans.editor.Syntax; //导入依赖的package包/类
/**
* Create a syntax object suitable for highlighting Manifest file syntax
*/
public Syntax createSyntax(Document doc) {
if (LOG) {
LOGGER.log(ErrorManager.INFORMATIONAL, "createSyntax"); // NOI18N
}
return new ManifestSyntax();
}
示例13: toString
import org.netbeans.editor.Syntax; //导入依赖的package包/类
public String toString(Syntax syntax) {
return super.toString(syntax)
+ ", subState=" + syntax.getStateName(getSubState()) // NOI18N
+ ", inDTD=" + subState; // NOI18N
}
示例14: acceptSyntax
import org.netbeans.editor.Syntax; //导入依赖的package包/类
protected boolean acceptSyntax(Syntax syntax) {
return (syntax instanceof JJEditorSyntax);
}
示例15: createSyntax
import org.netbeans.editor.Syntax; //导入依赖的package包/类
/** Create new instance of syntax coloring parser */
@Override
public Syntax createSyntax(Document doc) {
return new PropertiesSyntax();
}