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


Java GroovyLexer.start方法代码示例

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


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

示例1: findStringLiteral

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
@Nullable
private static <T> T findStringLiteral(@NotNull String textToSearchPrefix,
                                       @NotNull String fileContents,
                                       @NotNull Function<Pair<String, GroovyLexer>, T> consumer) {
  GroovyLexer lexer = new GroovyLexer();
  lexer.start(fileContents);
  while (lexer.getTokenType() != null) {
    IElementType type = lexer.getTokenType();
    if (type == GroovyTokenTypes.mSTRING_LITERAL) {
      String text = unquoteString(lexer.getTokenText());
      if (text.startsWith(textToSearchPrefix)) {
        return consumer.fun(Pair.create(text, lexer));
      }
    }
    lexer.advance();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GradleUtil.java

示例2: checkStringApplicable

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
private static boolean checkStringApplicable(Editor editor, int caret) {
  final GroovyLexer lexer = new GroovyLexer();
  lexer.start(editor.getDocument().getText());

  while (lexer.getTokenEnd() < caret) {
    lexer.advance();
  }
  final IElementType leftToken = lexer.getTokenType();
  if (lexer.getTokenEnd() <= caret) lexer.advance();
  final IElementType rightToken = lexer.getTokenType();

  if (!(ALL_STRINGS.contains(leftToken))) {
    return false;
  }
  if (BEFORE_DOLLAR.contains(leftToken) && !AFTER_DOLLAR.contains(rightToken)) {
    return false;
  }
  if (EXPR_END.contains(leftToken) && !AFTER_EXPR_END.contains(rightToken)) {
    return false;
  }
  if (STRING_END.contains(leftToken) && !STRING_END.contains(rightToken)) {
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GroovyEnterHandler.java

示例3: findCompileSdkVersionValueOffset

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
@VisibleForTesting
static int findCompileSdkVersionValueOffset(@NotNull String buildFileContents) {
  GroovyLexer lexer = new GroovyLexer();
  lexer.start(buildFileContents);

  int end = -1;

  while (lexer.getTokenType() != null) {
    IElementType type = lexer.getTokenType();
    String text = lexer.getTokenText();
    if (type == GroovyTokenTypes.mIDENT) {
      if ("compileSdkVersion".equals(text)) {
        end = lexer.getTokenEnd();
      }
      else if (end > -1) {
        return end;
      }
    }
    else if (type == TokenType.WHITE_SPACE && end > -1) {
      end++;
    }
    else if (end > -1) {
      return end;
    }
    lexer.advance();
  }

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

示例4: forPluginDefinition

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
/**
 * Checks given file contents (assuming that it's build.gradle config) and finds target plugin's definition (given the plugin
 * name in a form <code>'group-id:artifact-id:'</code>. Supplies given callback with the plugin definition string (unquoted) and
 * a {@link GroovyLexer} which state points to the plugin definition string (quoted).
 * <p/>
 * Example:
 * <pre>
 *     buildscript {
 *       repositories {
 *         mavenCentral()
 *       }
 *       dependencies {
 *         classpath 'com.google.appengine:gradle-appengine-plugin:1.9.4'
 *       }
 *     }
 * </pre>
 * Suppose that this method is called for the given build script content and
 * <code>'com.google.appengine:gradle-appengine-plugin:'</code> as a plugin name argument. Given callback is supplied by a
 * string <code>'com.google.appengine:gradle-appengine-plugin:1.9.4'</code> (without quotes) and a {@link GroovyLexer} which
 * {@link GroovyLexer#getTokenStart() points} to the string <code>'com.google.appengine:gradle-appengine-plugin:1.9.4'</code>
 * (with quotes), i.e. we can get exact text range for the target string in case we need to do something like replacing plugin's
 * version.
 *
 * @param fileContents  target gradle config text
 * @param pluginName    target plugin's name in a form <code>'group-id:artifact-id:'</code>
 * @param consumer      a callback to be notified for the target plugin's definition string
 * @param <T>           given callback's return type
 * @return              given callback's call result if target plugin definition is found; <code>null</code> otherwise
 */
@Nullable
public static <T> T forPluginDefinition(@NotNull String fileContents,
                                        @NotNull String pluginName,
                                        @NotNull Function<Pair<String, GroovyLexer>, T> consumer) {
  GroovyLexer lexer = new GroovyLexer();
  lexer.start(fileContents);
  while (lexer.getTokenType() != null) {
    IElementType type = lexer.getTokenType();
    if (type == GroovyTokenTypes.mSTRING_LITERAL) {
      String text = unquoteString(lexer.getTokenText());
      if (text.startsWith(pluginName)) {
        return consumer.fun(Pair.create(text, lexer));
      }
    }
    lexer.advance();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:GradleUtil.java

示例5: isValidReferenceName

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
public static boolean isValidReferenceName(@NotNull String text) {
  final GroovyLexer lexer = new GroovyLexer();
  lexer.start(text);
  return TokenSets.REFERENCE_NAMES_WITHOUT_NUMBERS.contains(lexer.getTokenType()) && lexer.getTokenEnd() == text.length();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PsiUtil.java

示例6: isKeyword

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
public static boolean isKeyword(@NotNull String name) {
  final GroovyLexer lexer = new GroovyLexer();
  lexer.start(name);
  final IElementType type = lexer.getTokenType();
  return TokenSets.KEYWORDS.contains(type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:GroovyNamesUtil.java

示例7: isValidReferenceName

import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer; //导入方法依赖的package包/类
public static boolean isValidReferenceName(String text) {
  final GroovyLexer lexer = new GroovyLexer();
  lexer.start(text);
  return TokenSets.REFERENCE_NAMES_WITHOUT_NUMBERS.contains(lexer.getTokenType()) && lexer.getTokenEnd() == text.length();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:6,代码来源:PsiUtil.java


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