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


Java InputAttributes.setValue方法代码示例

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


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

示例1: testInterferenceBraceIdent

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testInterferenceBraceIdent() {
    String text = "() -> {A::a();}";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LPAREN, "(");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.RPAREN, ")");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ARROW, "->");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LBRACE, "{");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "A");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.COLONCOLON, "::");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "a");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LPAREN, "(");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.RPAREN, ")");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.SEMICOLON, ";");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.RBRACE, "}");

    assertFalse(ts.moveNext());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavaLexerBatchTest.java

示例2: testNoBinaryLiterals

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testNoBinaryLiterals() {
    String text = "0b101 0B101 0b101l 0b101L";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(5), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "b101");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "B101");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "b101l");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "b101L");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JavaLexerBatchTest.java

示例3: getTokenHierarchy

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
@NonNull
public final TokenHierarchy<?> getTokenHierarchy() throws IOException {
    if (this.tokens == null) {
        final CharBuffer charBuffer = getCharContent(true);
        InputAttributes attrs = new InputAttributes();
        attrs.setValue(JavaTokenId.language(), "fileName", (Supplier<String>) () -> getName(), true); //NOI18N            
        this.tokens = TokenHierarchy.create(charBuffer, false, JavaTokenId.language(), null, attrs); //TODO: .createSnapshot();
    }
    return this.tokens;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AbstractSourceFileObject.java

示例4: createStyledDocument

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
@Override
protected StyledDocument createStyledDocument (EditorKit kit) {
    StyledDocument doc = super.createStyledDocument(kit);
    // Enter the file object in to InputAtrributes. It can be used by lexer.
    InputAttributes attributes = new InputAttributes();
    FileObject fileObject = NbEditorUtilities.getFileObject(doc);
    final GsfLanguage lng = language.getGsfLanguage();
    if (lng != null) {
        attributes.setValue(lng.getLexerLanguage(), FileObject.class, fileObject, false);
    }
    doc.putProperty(InputAttributes.class, attributes);
    return doc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:GsfDataObject.java

示例5: xtestExoticIdentifiers

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void xtestExoticIdentifiers() {//Support for exotic identifiers has been removed 6999438
    String text = "a #\" \" #\"\\\"\"";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "a");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "#\" \"");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "#\"\\\"\"");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JavaLexerBatchTest.java

示例6: testNoExoticIdentifiers

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testNoExoticIdentifiers() {
    String text = "a #\" \"";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(5), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "a");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ERROR, "#");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.STRING_LITERAL, "\" \"");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JavaLexerBatchTest.java

示例7: testBinaryLiterals

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testBinaryLiterals() {
    String text = "0b101 0B101 0b101l 0b101L";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0b101");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0B101");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LONG_LITERAL, "0b101l");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LONG_LITERAL, "0b101L");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JavaLexerBatchTest.java

示例8: testUnderscoresInLiterals

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testUnderscoresInLiterals() {
    String text = "_12 1_2 12_ 0_12 01_2 0x1_2";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "_12");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "1_2");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "12");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "_");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0_12");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "01_2");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0x1_2");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:JavaLexerBatchTest.java

示例9: testUnicode

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testUnicode() {
    String text = "//\\u000Aint\\u0020\\u002E\\uuuuuu002E\\u000A";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.noneOf(JavaTokenId.class), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LINE_COMMENT, "//\\u000A");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT, "int");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.WHITESPACE, "\\u0020");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.DOT, "\\u002E");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.DOT, "\\uuuuuu002E");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.WHITESPACE, "\\u000A");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JavaLexerBatchTest.java

示例10: testBrokenUnicode

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testBrokenUnicode() {
    String text = "\\u000X\\u00";
    InputAttributes attr = new InputAttributes();
    attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
    TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.noneOf(JavaTokenId.class), attr);
    TokenSequence<?> ts = hi.tokenSequence();

    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ERROR, "\\");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "u000X");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ERROR, "\\");
    LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "u00");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JavaLexerBatchTest.java

示例11: testGenericCssClassEmbedding

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testGenericCssClassEmbedding() {
    Map<String, Collection<String>> map = new HashMap<>();
    map.put("c:button", Collections.singletonList("styleClass"));

    InputAttributes inputAttributes = new InputAttributes();
    inputAttributes.setValue(HTMLTokenId.language(), "cssClassTagAttrMap", map, false); //NOI18N

    String text = "<c:button styleClass=\"myclass\"/>";
    TokenHierarchy th = TokenHierarchy.create(text, true, HTMLTokenId.language(), Collections.<HTMLTokenId>emptySet(), inputAttributes);
    TokenSequence ts = th.tokenSequence();

    checkTokens(ts, "<|TAG_OPEN_SYMBOL", "c:button|TAG_OPEN", " |WS", "styleClass|ARGUMENT",
            "=|OPERATOR", "\"myclass\"|VALUE_CSS", "/>|TAG_CLOSE_SYMBOL");
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HtmlLexerTest.java

示例12: initDocument

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
protected void initDocument(BaseDocument doc) {
//        doc.addLayer(new JavaDrawLayerFactory.JavaLayer(),
//                JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);
        doc.putProperty(SyntaxUpdateTokens.class,
              new SyntaxUpdateTokens() {
                  
                  private List tokenList = new ArrayList();
                  
                  public void syntaxUpdateStart() {
                      tokenList.clear();
                  }
      
                  public List syntaxUpdateEnd() {
                      return tokenList;
                  }
      
                  public void syntaxUpdateToken(TokenID id, TokenContextPath contextPath, int offset, int length) {
                      if (JavaTokenContext.LINE_COMMENT == id) {
                          tokenList.add(new TokenInfo(id, contextPath, offset, length));
                      }
                  }
              }
          );
        InputAttributes attrs = new InputAttributes();
        attrs.setValue(JavaTokenId.language(), "fileName", (Supplier<String>) () -> { //NOI18N
            FileObject fo = NbEditorUtilities.getFileObject(doc);
            return fo != null ? fo.getNameExt() : null;
        }, true);
        doc.putProperty(InputAttributes.class, attrs);
      }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:JavaKit.java

示例13: testEarlyNullToken

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testEarlyNullToken() throws Exception {
    Document doc = new ModificationTextDocument();
    // Assign a language to the document
    InputAttributes attrs = new InputAttributes();
    doc.putProperty(InputAttributes.class, attrs);
    
    // Insert text into document
    String text = "abc";
    doc.insertString(0, text, null);
    // Put the language now into the document so that lexing starts from scratch
    doc.putProperty(Language.class, StateTokenId.language());
    TokenHierarchy<?> hi = TokenHierarchy.get(doc);
    ((AbstractDocument)doc).readLock();
    try {
        TokenSequence<?> ts = hi.tokenSequence();

        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.A, "a", 0);
        assertEquals(LexerTestUtilities.lookahead(ts), 0);
        assertEquals(LexerTestUtilities.state(ts), StateLexer.AFTER_A);

        attrs.setValue(StateTokenId.language(), "returnNullToken", Boolean.TRUE, true);
        try {
            // Lexer will return null token too early
            assertTrue(ts.moveNext());
            fail("IllegalStateException not thrown when null token returned before input end.");
        } catch (IllegalStateException e) {
            // Expected fail of lexer
        }
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:InvalidLexerOperationTest.java

示例14: testIncLexerRelease

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void testIncLexerRelease() throws Exception {
    Document doc = new ModificationTextDocument();
    // Assign a language to the document
    InputAttributes attrs = new InputAttributes();
    doc.putProperty(InputAttributes.class, attrs);
    
    // Insert initial text into document
    String text = "ab";
    doc.insertString(0, text, null);
    // Put the language now into the document so that lexing starts from scratch
    doc.putProperty(Language.class, StateTokenId.language());
    TokenHierarchy<?> hi = TokenHierarchy.get(doc);
    TokenSequence<?> ts;
    LanguagePath lp;
    
    ((AbstractDocument)doc).readLock();
    try {
        ts = hi.tokenSequence();

        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.A, "a", 0);
        lp = LanguagePath.get(StateTokenId.language());
        assertFalse(Boolean.TRUE.equals(attrs.getValue(lp, "lexerRelease")));
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.BMULTI, "b", 1);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.ERROR, "\n", 2);
        assertFalse(ts.moveNext());
        assertTrue(Boolean.TRUE.equals(attrs.getValue(lp, "lexerRelease")));
        attrs.setValue(lp, "lexerRelease", Boolean.FALSE, false);
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }

    // Do modification and check lexer release after it
    doc.insertString(1, "b", null);
    assertTrue(Boolean.TRUE.equals(attrs.getValue(lp, "lexerRelease")));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:InvalidLexerOperationTest.java

示例15: test

import org.netbeans.api.lexer.InputAttributes; //导入方法依赖的package包/类
public void test() throws Exception {
    Document doc = new ModificationTextDocument();
    // Assign a language to the document
    InputAttributes attrs = new InputAttributes();
    doc.putProperty(InputAttributes.class, attrs);
    doc.putProperty(Language.class, StateTokenId.language());
    TokenHierarchy<?> hi = TokenHierarchy.get(doc);
    TokenSequence<?> ts;
    ((AbstractDocument)doc).readLock();
    try {
        ts = hi.tokenSequence();
        // Extra newline at the end of document returned in DocumentUtilities.getText(doc) is lexed too
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.ERROR, "\n", 0);
        assertFalse(ts.moveNext());
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
    
    // Insert text into document
    String text = "abc";
    doc.insertString(0, text, null);

    ((AbstractDocument)doc).readLock();
    try {
        ts = hi.tokenSequence();
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.A, "a", 0);
        assertEquals(LexerTestUtilities.lookahead(ts), 0);
        assertEquals(LexerTestUtilities.state(ts), StateLexer.AFTER_A);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.BMULTI, "b", 1);
        assertEquals(LexerTestUtilities.state(ts), StateLexer.AFTER_B);
        assertEquals(LexerTestUtilities.lookahead(ts), 1);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.ERROR, "c", 2);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts, StateTokenId.ERROR, "\n", 3);
        assertEquals(LexerTestUtilities.state(ts), null);
        assertFalse(ts.moveNext());

        LexerTestUtilities.incCheck(doc, false);
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
    
    // Should relex "b" so restart state should be AFTER_A
    attrs.setValue(StateTokenId.language(), "restartState", StateLexer.AFTER_A, true);
    doc.insertString(2, "b", null);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:StateLexerIncTest.java


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