• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StringLiteralLexer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.lexer.StringLiteralLexer的典型用法代码示例。如果您正苦于以下问题:Java StringLiteralLexer类的具体用法?Java StringLiteralLexer怎么用?Java StringLiteralLexer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringLiteralLexer类属于com.intellij.lexer包,在下文中一共展示了StringLiteralLexer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: select

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
  List<TextRange> result = super.select(e, editorText, cursorOffset, editor);

  TextRange range = e.getTextRange();
  SelectWordUtil.addWordHonoringEscapeSequences(editorText, range, cursorOffset,
                                                new StringLiteralLexer('\"', JavaTokenType.STRING_LITERAL),
                                                result);

  result.add(new TextRange(range.getStartOffset() + 1, range.getEndOffset() - 1));

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:LiteralSelectioner.java


示例2: getHighlightingLexer

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
@NotNull
@Override
public Lexer getHighlightingLexer() {
  LayeredLexer layeredLexer = new LayeredLexer(new JsonLexer());
  layeredLexer.registerSelfStoppingLayer(new StringLiteralLexer('\"', JsonElementTypes.DOUBLE_QUOTED_STRING, false, "/", false, false),
                                         new IElementType[]{JsonElementTypes.DOUBLE_QUOTED_STRING}, IElementType.EMPTY_ARRAY);
  layeredLexer.registerSelfStoppingLayer(new StringLiteralLexer('\'', JsonElementTypes.SINGLE_QUOTED_STRING, false, "/", false, false),
                                         new IElementType[]{JsonElementTypes.SINGLE_QUOTED_STRING}, IElementType.EMPTY_ARRAY);
  return layeredLexer;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JsonSyntaxHighlighterFactory.java


示例3: select

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
  final IElementType type = e.getNode().getElementType();
  final StringLiteralLexer lexer = new StringLiteralLexer(type == SINGLE_QUOTED_STRING ? '\'' : '"', type, false, "/", false, false);
  final List<TextRange> result = new ArrayList<TextRange>();
  SelectWordUtil.addWordHonoringEscapeSequences(editorText, e.getTextRange(), cursorOffset, lexer, result);

  final PsiElement parent = e.getParent();
  result.add(ElementManipulators.getValueTextRange(parent).shiftRight(parent.getTextOffset()));
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JsonStringLiteralSelectionHandler.java


示例4: PropertiesHighlightingLexer

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
public PropertiesHighlightingLexer() {
  super(new PropertiesLexer());
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.VALUE_CHARACTERS, true, "#!=:"),
                            new IElementType[]{PropertiesTokenTypes.VALUE_CHARACTERS},
                            IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.KEY_CHARACTERS, true, "#!=: "),
                            new IElementType[]{PropertiesTokenTypes.KEY_CHARACTERS},
                            IElementType.EMPTY_ARRAY);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PropertiesHighlightingLexer.java


示例5: GroovyHighlightingLexer

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
private GroovyHighlightingLexer() {
  super(new GroovyLexer());
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, GroovyTokenTypes.mSTRING_LITERAL, true, "$"),
                            new IElementType[]{GroovyTokenTypes.mSTRING_LITERAL}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, GroovyTokenTypes.mGSTRING_LITERAL, true, "$"),
                            new IElementType[]{GroovyTokenTypes.mGSTRING_LITERAL}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, GroovyTokenTypes.mGSTRING_CONTENT, true, "$"),
                            new IElementType[]{GroovyTokenTypes.mGSTRING_CONTENT}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new GroovySlashyStringLexer(), new IElementType[]{GroovyTokenTypes.mREGEX_CONTENT}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new GroovyDollarSlashyStringLexer(), new IElementType[]{GroovyTokenTypes.mDOLLAR_SLASH_REGEX_CONTENT}, IElementType.EMPTY_ARRAY);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GroovySyntaxHighlighter.java


示例6: GroovyHighlightingLexer

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
private GroovyHighlightingLexer() {
  super(new GroovyLexer());
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, GroovyTokenTypes.mSTRING_LITERAL, true, "$"),
                            new IElementType[]{GroovyTokenTypes.mSTRING_LITERAL}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, GroovyTokenTypes.mGSTRING_LITERAL, true, "$"),
                            new IElementType[]{GroovyTokenTypes.mGSTRING_LITERAL}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, GroovyTokenTypes.mGSTRING_CONTENT, true, "$"),
                            new IElementType[]{GroovyTokenTypes.mGSTRING_CONTENT}, IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new GroovySlashyStringLexer(), new IElementType[]{GroovyTokenTypes.mREGEX_CONTENT},
                            IElementType.EMPTY_ARRAY);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:GroovySyntaxHighlighter.java


示例7: CSharpEditorHighlighter

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
public CSharpEditorHighlighter(@Nullable final VirtualFile virtualFile, @NotNull final EditorColorsScheme colors)
{
	super(new CSharpSyntaxHighlighter(), colors);
	registerLayer(CSharpTokens.STRING_LITERAL, new LayerDescriptor(new CSharpSyntaxHighlighter()
	{
		@NotNull
		@Override
		public Lexer getHighlightingLexer()
		{
			return new StringLiteralLexer('\"', CSharpTokens.STRING_LITERAL);
		}
	}, ""));
	registerLayer(CSharpTokensImpl.LINE_DOC_COMMENT, new LayerDescriptor(new CSharpDocSyntaxHighlighter(), ""));
	registerLayer(CSharpTokens.CHARACTER_LITERAL, new LayerDescriptor(new CSharpSyntaxHighlighter()
	{
		@NotNull
		@Override
		public Lexer getHighlightingLexer()
		{
			return new StringLiteralLexer('\'', CSharpTokens.CHARACTER_LITERAL);
		}
	}, ""));
	registerLayer(CSharpTokensImpl.INTERPOLATION_STRING_LITERAL, new LayerDescriptor(new CfsSyntaxHighlighter(CSharpCfsLanguageVersion
			.getInstance())
	{
		@NotNull
		@Override
		public TextAttributesKey[] getTokenHighlights(IElementType elementType)
		{
			if(elementType == CfsTokens.TEXT)
			{
				return pack(CSharpHighlightKey.STRING);
			}
			return super.getTokenHighlights(elementType);
		}
	}, ""));
	registerLayer(CSharpTemplateTokens.PREPROCESSOR_FRAGMENT, new LayerDescriptor(new CSharpPreprocessorSyntaxHighlighter(), ""));
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:39,代码来源:CSharpEditorHighlighter.java


示例8: preprocessEnter

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
@Override
public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull Ref<Integer> caretOffsetRef,
                              @NotNull final Ref<Integer> caretAdvanceRef, @NotNull final DataContext dataContext,
                              final EditorActionHandler originalHandler) {
  int caretOffset = caretOffsetRef.get().intValue();
  int caretAdvance = caretAdvanceRef.get().intValue();
  PsiElement psiAtOffset = file.findElementAt(caretOffset);
  if (psiAtOffset != null && psiAtOffset.getTextOffset() < caretOffset) {
    Document document = editor.getDocument();
    CharSequence text = document.getText();
    ASTNode token = psiAtOffset.getNode();
    JavaLikeQuoteHandler quoteHandler = getJavaLikeQuoteHandler(editor, psiAtOffset);

    if (quoteHandler != null &&
        quoteHandler.getConcatenatableStringTokenTypes() != null &&
        quoteHandler.getConcatenatableStringTokenTypes().contains(token.getElementType())) {
      TextRange range = token.getTextRange();
      final char literalStart = token.getText().charAt(0);
      final StringLiteralLexer lexer = new StringLiteralLexer(literalStart, token.getElementType());
      lexer.start(text, range.getStartOffset(), range.getEndOffset());

      while (lexer.getTokenType() != null) {
        if (lexer.getTokenStart() < caretOffset && caretOffset < lexer.getTokenEnd()) {
          if (StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(lexer.getTokenType())) {
            caretOffset = lexer.getTokenEnd();
          }
          break;
        }
        lexer.advance();
      }

      if (quoteHandler.needParenthesesAroundConcatenation(psiAtOffset)) {
        document.insertString(psiAtOffset.getTextRange().getEndOffset(), ")");
        document.insertString(psiAtOffset.getTextRange().getStartOffset(), "(");
        caretOffset++;
        caretAdvance++;
      }

      final String insertedFragment = literalStart + " " + quoteHandler.getStringConcatenationOperatorRepresentation();
      document.insertString(caretOffset, insertedFragment + " " + literalStart);
      caretOffset += insertedFragment.length();
      caretAdvance = 1;
      CommonCodeStyleSettings langSettings =
        CodeStyleSettingsManager.getSettings(file.getProject()).getCommonSettings(file.getLanguage());
      if (langSettings.BINARY_OPERATION_SIGN_ON_NEXT_LINE) {
        caretOffset -= 1;
        caretAdvance = 3;
      }
      caretOffsetRef.set(caretOffset);
      caretAdvanceRef.set(caretAdvance);
      return Result.DefaultForceIndent;
    }
  }
  return Result.Continue;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:EnterInStringLiteralHandler.java


示例9: PropertiesValueHighlightingLexer

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
public PropertiesValueHighlightingLexer() {
    super(new DummyLexer(PropertiesTokenTypes.VALUE_CHARACTERS));

    registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.VALUE_CHARACTERS, true, "#!=:"),
                              new IElementType[]{PropertiesTokenTypes.VALUE_CHARACTERS}, IElementType.EMPTY_ARRAY);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PropertiesValueHighlightingLexer.java


示例10: preprocessEnter

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
@Override
public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull Ref<Integer> caretOffsetRef,
                              @NotNull final Ref<Integer> caretAdvanceRef, @NotNull final DataContext dataContext,
                              final EditorActionHandler originalHandler) {
  int caretOffset = caretOffsetRef.get().intValue();
  int caretAdvance = caretAdvanceRef.get().intValue();
  PsiElement psiAtOffset = file.findElementAt(caretOffset);
  if (psiAtOffset != null && psiAtOffset.getTextOffset() < caretOffset) {
    Document document = editor.getDocument();
    CharSequence text = document.getText();
    ASTNode token = psiAtOffset.getNode();
    JavaLikeQuoteHandler quoteHandler = getJavaLikeQuoteHandler(editor, psiAtOffset);

    if (quoteHandler != null &&
        quoteHandler.getConcatenatableStringTokenTypes() != null &&
        quoteHandler.getConcatenatableStringTokenTypes().contains(token.getElementType())) {
      TextRange range = token.getTextRange();
      final char literalStart = token.getText().charAt(0);
      final StringLiteralLexer lexer = new StringLiteralLexer(literalStart, token.getElementType());
      lexer.start(text, range.getStartOffset(), range.getEndOffset());

      while (lexer.getTokenType() != null) {
        if (lexer.getTokenStart() < caretOffset && caretOffset < lexer.getTokenEnd()) {
          if (StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(lexer.getTokenType())) {
            caretOffset = lexer.getTokenEnd();
          }
          break;
        }
        lexer.advance();
      }

      if (quoteHandler.needParenthesesAroundConcatenation(psiAtOffset)) {
        document.insertString(psiAtOffset.getTextRange().getEndOffset(), ")");
        document.insertString(psiAtOffset.getTextRange().getStartOffset(), "(");
        caretOffset++;
        caretAdvance++;
      }

      final String insertedFragment = literalStart + " " + quoteHandler.getStringConcatenationOperatorRepresentation();
      document.insertString(caretOffset, insertedFragment + " " + literalStart);
      caretOffset += insertedFragment.length();
      caretAdvance = 1;
      if (CodeStyleSettingsManager.getSettings(file.getProject()).BINARY_OPERATION_SIGN_ON_NEXT_LINE) {
        caretOffset -= 1;
        caretAdvance = 3;
      }
      caretOffsetRef.set(caretOffset);
      caretAdvanceRef.set(caretAdvance);
      return Result.DefaultForceIndent;
    }
  }
  return Result.Continue;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:54,代码来源:EnterInStringLiteralHandler.java


示例11: preprocessEnter

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
@Override
public Result preprocessEnter(@Nonnull final PsiFile file, @Nonnull final Editor editor, @Nonnull Ref<Integer> caretOffsetRef,
                              @Nonnull final Ref<Integer> caretAdvanceRef, @Nonnull final DataContext dataContext,
                              final EditorActionHandler originalHandler) {
  int caretOffset = caretOffsetRef.get().intValue();
  int caretAdvance = caretAdvanceRef.get().intValue();
  if (!isInStringLiteral(editor, dataContext, caretOffset)) return Result.Continue;
  PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
  PsiElement psiAtOffset = file.findElementAt(caretOffset);
  if (psiAtOffset != null && psiAtOffset.getTextOffset() < caretOffset) {
    Document document = editor.getDocument();
    CharSequence text = document.getText();
    ASTNode token = psiAtOffset.getNode();
    JavaLikeQuoteHandler quoteHandler = getJavaLikeQuoteHandler(editor, psiAtOffset);

    if (quoteHandler != null &&
        quoteHandler.getConcatenatableStringTokenTypes() != null &&
        quoteHandler.getConcatenatableStringTokenTypes().contains(token.getElementType())) {
      TextRange range = token.getTextRange();
      final char literalStart = token.getText().charAt(0);
      final StringLiteralLexer lexer = new StringLiteralLexer(literalStart, token.getElementType());
      lexer.start(text, range.getStartOffset(), range.getEndOffset());

      while (lexer.getTokenType() != null) {
        if (lexer.getTokenStart() < caretOffset && caretOffset < lexer.getTokenEnd()) {
          if (StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(lexer.getTokenType())) {
            caretOffset = lexer.getTokenEnd();
          }
          break;
        }
        lexer.advance();
      }

      if (quoteHandler.needParenthesesAroundConcatenation(psiAtOffset)) {
        document.insertString(psiAtOffset.getTextRange().getEndOffset(), ")");
        document.insertString(psiAtOffset.getTextRange().getStartOffset(), "(");
        caretOffset++;
        caretAdvance++;
      }

      final String insertedFragment = literalStart + " " + quoteHandler.getStringConcatenationOperatorRepresentation();
      document.insertString(caretOffset, insertedFragment + " " + literalStart);
      caretOffset += insertedFragment.length();
      caretAdvance = 1;
      CommonCodeStyleSettings langSettings =
              CodeStyleSettingsManager.getSettings(file.getProject()).getCommonSettings(file.getLanguage());
      if (langSettings.BINARY_OPERATION_SIGN_ON_NEXT_LINE) {
        caretOffset -= 1;
        caretAdvance = 3;
      }
      caretOffsetRef.set(caretOffset);
      caretAdvanceRef.set(caretAdvance);
      return Result.DefaultForceIndent;
    }
  }
  return Result.Continue;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:58,代码来源:EnterInStringLiteralHandler.java


示例12: JavaScriptHighlightingLexer

import com.intellij.lexer.StringLiteralLexer; //导入依赖的package包/类
private JavaScriptHighlightingLexer(Factory<Lexer> baseLexerFactory, boolean withEmbeddments)
{
	super(baseLexerFactory.create());

	if(withEmbeddments)
	{
		registerSelfStoppingLayer(new StringLiteralLexer('\"', JSTokenTypes.STRING_LITERAL, true, "/"), new IElementType[]{JSTokenTypes.STRING_LITERAL},
				IElementType.EMPTY_ARRAY);

		registerSelfStoppingLayer(new JavaScriptHighlightingLexer(baseLexerFactory, false), new IElementType[]{JSTokenTypes.XML_JS_SCRIPT},
				IElementType.EMPTY_ARRAY);

		registerSelfStoppingLayer(new StringLiteralLexer('\'', JSTokenTypes.SINGLE_QUOTE_STRING_LITERAL, true, "/"),
				new IElementType[]{JSTokenTypes.SINGLE_QUOTE_STRING_LITERAL}, IElementType.EMPTY_ARRAY);

		final LayeredLexer docLexer = new LayeredLexer(new FlexAdapter(new _JSDocLexer(true)));
		final Lexer lexer = getHtmlHighlightingLexer();

		// Force html highlighting lexer not to return tag content type since it causes token type collision in javascript embedded to html
		docLexer.registerLayer(new LexerBase()
		{
			final IElementType tagContentType = getTagContentTokenType();


			@Override
			public void start(final CharSequence buffer, final int startOffset, final int endOffset, final int initialState)
			{
				lexer.start(buffer, startOffset, endOffset, initialState);
			}

			@Override
			public int getState()
			{
				return lexer.getState();
			}

			@Override
			public IElementType getTokenType()
			{
				final IElementType tokenType = lexer.getTokenType();
				if(tokenType == tagContentType)
				{
					return JSTokenTypes.JSDOC_TAG_DATA;
				}
				return tokenType;
			}

			@Override
			public int getTokenStart()
			{
				return lexer.getTokenStart();
			}

			@Override
			public int getTokenEnd()
			{
				return lexer.getTokenEnd();
			}

			@Override
			public void advance()
			{
				lexer.advance();
			}

			@Override
			public CharSequence getBufferSequence()
			{
				return lexer.getBufferSequence();
			}


			@Override
			public int getBufferEnd()
			{
				return lexer.getBufferEnd();
			}
		}, JSDocTokenTypes.DOC_COMMENT_DATA);
		registerSelfStoppingLayer(docLexer, new IElementType[]{JSTokenTypes.DOC_COMMENT}, new IElementType[]{JSDocTokenTypes.DOC_COMMENT_END});
	}
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:82,代码来源:JavaScriptHighlightingLexer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VKApiFriends类代码示例发布时间:2022-05-22
下一篇:
Java KDFFeedbackParameters类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap