Java Code Examples for com.intellij.util.text.StringTokenizer#hasMoreTokens()
The following examples show how to use
com.intellij.util.text.StringTokenizer#hasMoreTokens() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaxeCommonCompilerUtil.java From intellij-haxe with Apache License 2.0 | 6 votes |
private static List<String> generateNmeCommand(CompilationContext context) { final List<String> commandLine = new ArrayList<>(); final String haxelibPath = context.getHaxelibPath(); commandLine.add(haxelibPath); final HaxeModuleSettingsBase settings = context.getModuleSettings(); commandLine.add("run"); commandLine.add("nme"); commandLine.add("build"); commandLine.add(settings.getNmmlPath()); commandLine.add(settings.getNmeTarget().getTargetFlag()); if (context.isDebug()) { commandLine.add("-debug"); commandLine.add("-Ddebug"); } if (settings.getNmeTarget() == NMETarget.FLASH && context.isDebug()) { commandLine.add("-Dfdb"); } final StringTokenizer flagsTokenizer = new StringTokenizer(settings.getNmeFlags()); while (flagsTokenizer.hasMoreTokens()) { commandLine.add(flagsTokenizer.nextToken()); } return commandLine; }
Example 2
Source File: ConsoleViewUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void printWithHighlighting(@Nonnull ConsoleView console, @Nonnull String text, @Nonnull SyntaxHighlighter highlighter, Runnable doOnNewLine) { Lexer lexer = highlighter.getHighlightingLexer(); lexer.start(text, 0, text.length(), 0); IElementType tokenType; while ((tokenType = lexer.getTokenType()) != null) { ConsoleViewContentType contentType = getContentTypeForToken(tokenType, highlighter); StringTokenizer eolTokenizer = new StringTokenizer(lexer.getTokenText(), "\n", true); while (eolTokenizer.hasMoreTokens()) { String tok = eolTokenizer.nextToken(); console.print(tok, contentType); if (doOnNewLine != null && "\n".equals(tok)) { doOnNewLine.run(); } } lexer.advance(); } }
Example 3
Source File: HaxeCompilerServices.java From intellij-haxe with Apache License 2.0 | 5 votes |
private void formatAndAddCompilerArguments(ArrayList<String> commandLineArguments, String flags) { if (null != flags && !flags.isEmpty()) { final StringTokenizer flagsTokenizer = new StringTokenizer(flags); while (flagsTokenizer.hasMoreTokens()) { String nextToken = flagsTokenizer.nextToken(); if (!nextToken.isEmpty()) { commandLineArguments.add(nextToken); } } } }
Example 4
Source File: NMERunningState.java From intellij-haxe with Apache License 2.0 | 5 votes |
private HaxeCommandLine getCommandForNeko(Sdk sdk, HaxeModuleSettings settings) throws ExecutionException { final HaxeSdkData sdkData = sdk.getSdkAdditionalData() instanceof HaxeSdkData ? (HaxeSdkData)sdk.getSdkAdditionalData() : null; if (sdkData == null) { throw new ExecutionException(HaxeCommonBundle.message("invalid.haxe.sdk")); } final HaxeCommandLine commandLine = new HaxeCommandLine(module); commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath())); final String haxelibPath = sdkData.getHaxelibPath(); if (haxelibPath == null || haxelibPath.isEmpty()) { throw new ExecutionException(HaxeCommonBundle.message("no.haxelib.for.sdk", sdk.getName())); } commandLine.setExePath(haxelibPath); commandLine.addParameter("run"); commandLine.addParameter("nme"); commandLine.addParameter(myRunInTest ? "test" : "run"); commandLine.addParameter(settings.getNmmlPath()); for (String flag : settings.getNmeTarget().getFlags()) { commandLine.addParameter(flag); } if (myDebug) { commandLine.addParameter("-debug"); commandLine.addParameter("-Ddebug"); commandLine.addParameter("-args"); commandLine.addParameter("-start_debugger"); commandLine.addParameter("-debugger_host=localhost:" + myDebugPort); } final StringTokenizer flagsTokenizer = new StringTokenizer(settings.getNmeFlags()); while (flagsTokenizer.hasMoreTokens()) { commandLine.addParameter(flagsTokenizer.nextToken()); } final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject()); setConsoleBuilder(consoleBuilder); return commandLine; }
Example 5
Source File: HaxeCommonCompilerUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
private static List<String> generateUserPropertiesCommand(CompilationContext context) { final List<String> commandLine = new ArrayList<String>(); final String sdkExePath = HaxeSdkUtilBase.getCompilerPathByFolderPath(context.getSdkHomePath()); commandLine.add(sdkExePath); final HaxeModuleSettingsBase settings = context.getModuleSettings(); commandLine.add("-main"); commandLine.add(context.getCompilationClass()); final StringTokenizer argumentsTokenizer = new StringTokenizer(settings.getArguments()); while (argumentsTokenizer.hasMoreTokens()) { commandLine.add(argumentsTokenizer.nextToken()); } if (context.isDebug()) { commandLine.add("-debug"); } if (context.getHaxeTarget() == HaxeTarget.FLASH && context.isDebug()) { commandLine.add("-D"); commandLine.add("fdb"); } for (String sourceRoot : context.getSourceRoots()) { commandLine.add("-cp"); commandLine.add(sourceRoot); } commandLine.add(context.getHaxeTarget().getCompilerFlag()); commandLine.add(calculateOutputPath(context)); return commandLine; }
Example 6
Source File: TestsLocationProviderUtil.java From consulo with Apache License 2.0 | 5 votes |
public static List<VirtualFile> findSuitableFilesFor(final String filePath, final Project project) { final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); // at first let's try to find file as is, by it's real path // and check that file belongs to current project // this location provider designed for tests thus we will check only project content // (we cannot check just sources or tests folders because RM doesn't use it final VirtualFile file = getByFullPath(filePath); final boolean inProjectContent = file != null && (index.isInContent(file)); if (inProjectContent) { return Collections.singletonList(file); } //split file by "/" in parts final LinkedList<String> folders = new LinkedList<String>(); final StringTokenizer st = new StringTokenizer(filePath, "/", false); String fileName = null; while (st.hasMoreTokens()) { final String pathComponent = st.nextToken(); if (st.hasMoreTokens()) { folders.addFirst(pathComponent); } else { // last token fileName = pathComponent; } } if (fileName == null) { return Collections.emptyList(); } return findFilesClosestToTarget(folders, collectCandidates(project, fileName, true), MIN_PROXIMITY_THRESHOLD); }
Example 7
Source File: SplitterProportionsDataImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void readExternal(Element element) throws InvalidDataException { proportions.clear(); String prop = element.getAttributeValue(ATTRIBUTE_PROPORTIONS); String version = element.getAttributeValue(ATTRIBUTE_VERSION); if (prop != null && Comparing.equal(version, DATA_VERSION)) { StringTokenizer tokenizer = new StringTokenizer(prop, ","); while (tokenizer.hasMoreTokens()) { String p = tokenizer.nextToken(); proportions.add(Float.valueOf(p)); } } }
Example 8
Source File: SplitterProportionsDataImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override public SplitterProportionsDataImpl fromString(@Nonnull String value) { SplitterProportionsDataImpl data = new SplitterProportionsDataImpl(); StringTokenizer tokenizer = new StringTokenizer(value, ","); while (tokenizer.hasMoreTokens()) { data.proportions.add(Float.valueOf(tokenizer.nextToken())); } return data; }
Example 9
Source File: LibraryUtil.java From consulo with Apache License 2.0 | 5 votes |
private static boolean findInFile(VirtualFile file, final StringTokenizer tokenizer) { if (!tokenizer.hasMoreTokens()) return true; @NonNls StringBuilder name = new StringBuilder(tokenizer.nextToken()); if (!tokenizer.hasMoreTokens()) { name.append(".class"); } final VirtualFile child = file.findChild(name.toString()); return child != null && findInFile(child, tokenizer); }
Example 10
Source File: HorizontalLabeledIcon.java From consulo with Apache License 2.0 | 5 votes |
/** * @param icon not <code>null</code> icon. * @param text to be painted under the <code>icon<code>. This parameter can * be <code>null</code> if text isn't specified. In that case <code>LabeledIcon</code> */ public HorizontalLabeledIcon(Icon icon, String text, String mnemonic) { myIcon = icon; if (text != null) { StringTokenizer tokenizer = new StringTokenizer(text, "\n"); myStrings = new String[tokenizer.countTokens()]; for (int i = 0; tokenizer.hasMoreTokens(); i++) { myStrings[i] = tokenizer.nextToken(); } } else { myStrings = null; } myMnemonic = mnemonic; }
Example 11
Source File: OpenFLRunningState.java From intellij-haxe with Apache License 2.0 | 4 votes |
private HaxeCommandLine getCommandForOpenFL(Sdk sdk, HaxeModuleSettings settings) throws ExecutionException { final HaxeSdkData sdkData = sdk.getSdkAdditionalData() instanceof HaxeSdkData ? (HaxeSdkData)sdk.getSdkAdditionalData() : null; if (sdkData == null) { throw new ExecutionException(HaxeCommonBundle.message("invalid.haxe.sdk")); } final HaxeCommandLine commandLine = new HaxeCommandLine(module); commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath())); final String haxelibPath = sdkData.getHaxelibPath(); if (haxelibPath == null || haxelibPath.isEmpty()) { throw new ExecutionException(HaxeCommonBundle.message("no.haxelib.for.sdk", sdk.getName())); } commandLine.setExePath(haxelibPath); commandLine.addParameter("run"); commandLine.addParameter("lime"); commandLine.addParameter(myRunInTest ? "test" : "run"); if(!StringUtil.isEmpty(settings.getOpenFLPath())) { commandLine.addParameter(settings.getOpenFLPath()); } for (String flag : settings.getOpenFLTarget().getFlags()) { commandLine.addParameter(flag); } commandLine.addParameter("-verbose"); if (myDebug) { commandLine.addParameter("-Ddebug"); commandLine.addParameter("-debug"); if (settings.getOpenFLTarget() == OpenFLTarget.FLASH) { commandLine.addParameter("-Dfdb"); } else { commandLine.addParameter("-args"); commandLine.addParameter("-start_debugger"); commandLine.addParameter("-debugger_host=localhost:" + myDebugPort); } } final StringTokenizer flagsTokenizer = new StringTokenizer(settings.getOpenFLFlags()); while (flagsTokenizer.hasMoreTokens()) { commandLine.addParameter(flagsTokenizer.nextToken()); } final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject()); setConsoleBuilder(consoleBuilder); return commandLine; }
Example 12
Source File: HaxeCommonCompilerUtil.java From intellij-haxe with Apache License 2.0 | 4 votes |
private static List<List<String>> generateOpenflCommands(CompilationContext context) { final String haxelibPath = context.getHaxelibPath(); final HaxeModuleSettingsBase settings = context.getModuleSettings(); List<List<String>> clList = new ArrayList<>(); String cmds[] = {"update", "build"}; for (String cmd : cmds) { List<String> commandLine = new ArrayList<>(); commandLine.add(haxelibPath); commandLine.add("run"); commandLine.add("lime"); commandLine.add(cmd); // XXX: Isn't this an error if the openfl project file is missing? if(!StringUtil.isEmpty(settings.getOpenFLPath())) { commandLine.add(settings.getOpenFLPath()); } commandLine.add(settings.getOpenFLTarget().getTargetFlag()); commandLine.add("-verbose"); if (context.isDebug()) { commandLine.add("-debug"); commandLine.add("-Ddebug"); if (settings.getOpenFLTarget() == OpenFLTarget.FLASH) { commandLine.add("-Dfdb"); } } final StringTokenizer flagsTokenizer = new StringTokenizer(settings.getOpenFLFlags()); while (flagsTokenizer.hasMoreTokens()) { commandLine.add(flagsTokenizer.nextToken()); } clList.add(commandLine); } return clList; }