@NotNull public static String joinPsiElementText(List<? extends PsiElement> items) { return StringUtil.join(items, PsiElement::getText, ", "); }
public void setFailedTests(@NotNull List<AbstractTestProxy> failedTests) { myFailedTestsPattern = "^" + StringUtil.join(failedTests, AbstractTestProxy::getName, "|") + "$"; } }
@Override public String getText() { return StringUtil.join(getTypeList(), PsiElement::getText, ", "); } }
@NotNull public String toText(@NotNull List<PsiComment> comments) { return StringUtil.join(getStrings(comments), "\n"); }
private static void removeRedundantExpressions(@NotNull GoBinaryExpr binaryExpr, @NotNull Project project, @NotNull List<GoExpression> expressions, @NotNull List<GoExpression> toRemove, boolean and) { for (GoExpression e : toRemove) { expressions.remove(e); } String separator = and ? " && " : " || "; String text = StringUtil.join(expressions, PsiElement::getText, separator); GoExpression expression = GoElementFactory.createExpression(project, text); binaryExpr.replace(expression); }
@NotNull public static String retrieveGoPath(@NotNull Project project, @Nullable Module module) { return StringUtil.join(ContainerUtil.map(getGoPathRoots(project, module), VirtualFile::getPath), File.pathSeparator); }
@NotNull public static String retrieveEnvironmentPathForGo(@NotNull Project project, @Nullable Module module) { return StringUtil.join(ContainerUtil.map(getGoPathBins(project, module), VirtualFile::getPath), File.pathSeparator); }
@NotNull @Override public GoConstSpecStub createStub(@NotNull GoConstSpec psi, StubElement parentStub) { String join = StringUtil.join(psi.getExpressionList(), PsiElement::getText, ";"); return new GoConstSpecStub(parentStub, this, StringRef.fromString(join)); }
@NotNull private static GoType createGoTypeListOrGoType(@NotNull List<GoType> types, @NotNull PsiElement context) { if (types.size() < 2) { return getInterfaceIfNull(ContainerUtil.getFirstItem(types), context); } return GoElementFactory.createTypeList(context.getProject(), StringUtil.join(types, type -> type == null ? GoConstants.INTERFACE_TYPE : type.getText(), ", ")); }
@NotNull private static String getParametersAsString(@NotNull GoParameters parameters) { String contextImportPath = getImportPathForElement(parameters); return StringUtil.join(GoParameterInfoHandler.getParameterPresentations(parameters, element -> getTypePresentation(element, new GoDocumentationPresentationFunction(contextImportPath))), ", "); }
@NotNull @Override protected String buildFilterPatternForFile(GoFile file) { Collection<String> testNames = ContainerUtil.newLinkedHashSet(); for (GoMethodDeclaration method : file.getMethods()) { ContainerUtil.addIfNotNull(testNames, GocheckFramework.getGocheckTestName(method)); } return "^" + StringUtil.join(testNames, "|") + "$"; }
@Nullable public String getBuildFlags() { GoFileStub stub = getStub(); if (stub != null) { return stub.getBuildFlags(); } // https://code.google.com/p/go/source/browse/src/pkg/go/build/build.go?r=2449e85a115014c3d9251f86d499e5808141e6bc#790 Collection<String> buildFlags = ContainerUtil.newArrayList(); int buildFlagLength = GoConstants.BUILD_FLAG.length(); for (PsiComment comment : getCommentsToConsider(this)) { String commentText = StringUtil.trimStart(comment.getText(), "//").trim(); if (commentText.startsWith(GoConstants.BUILD_FLAG) && commentText.length() > buildFlagLength && StringUtil.isWhiteSpace(commentText.charAt(buildFlagLength))) { ContainerUtil.addIfNotNull(buildFlags, StringUtil.nullize(commentText.substring(buildFlagLength).trim(), true)); } } return !buildFlags.isEmpty() ? StringUtil.join(buildFlags, "|") : null; }
@NotNull @Override protected String buildFilterPatternForFile(GoFile file) { Collection<String> benchmarkNames = ContainerUtil.newLinkedHashSet(); for (GoFunctionDeclaration function : file.getFunctions()) { ContainerUtil.addIfNotNull(benchmarkNames, GoTestFinder.isBenchmarkFunction(function) ? function.getName() : null); } return "^" + StringUtil.join(benchmarkNames, "|") + "$"; }
private void processStdOut(@NotNull String testName, Key outputType, ServiceMessageVisitor visitor) throws ParseException { if (myStdOut == null) { return; } String allStdOut = StringUtil.join(myStdOut, ""); if (!StringUtil.isEmptyOrSpaces(allStdOut)) { String testStdOutMsg = ServiceMessageBuilder.testStdOut(testName).addAttribute("out", allStdOut).toString(); super.processServiceMessages(testStdOutMsg, outputType, visitor); } myStdOut = null; }
@NotNull protected String buildFilterPatternForFile(GoFile file) { Collection<String> testNames = ContainerUtil.newLinkedHashSet(); for (GoFunctionDeclaration function : file.getFunctions()) { ContainerUtil.addIfNotNull(testNames, GoTestFinder.isTestOrExampleFunction(function) ? function.getName() : null); } return "^" + StringUtil.join(testNames, "|") + "$"; }
@Nullable protected TextRange surroundStatementsWithIfElse(@NotNull Project project, @NotNull PsiElement container, @NotNull PsiElement[] statements, boolean withElse) { PsiElement first = ArrayUtil.getFirstElement(statements); PsiElement last = ArrayUtil.getLastElement(statements); String block = StringUtil.join(statements, PsiElement::getText, "\n"); GoIfStatement ifStatement = GoElementFactory.createIfStatement(project, "", block, withElse ? "" : null); ifStatement = (GoIfStatement)container.addAfter(ifStatement, last); container.deleteChildRange(first, last); int offset = getOffsetLBraceOfBlock(ifStatement.getBlock()); return offset > -1 ? new TextRange(offset, offset) : null; }
@Nullable @Override protected TextRange surroundStatements(@NotNull Project project, @NotNull PsiElement container, @NotNull PsiElement[] statements) throws IncorrectOperationException { String text = StringUtil.join(statements, PsiElement::getText, "\n"); GoForStatement forStatement = GoElementFactory.createForStatement(project, text); PsiElement first = ArrayUtil.getFirstElement(statements); PsiElement last = ArrayUtil.getLastElement(statements); forStatement = (GoForStatement)container.addAfter(forStatement, last); container.deleteChildRange(first, last); int offset = getOffsetLBraceOfBlock(forStatement.getBlock()); return offset > -1 ? new TextRange(offset, offset) : null; } }
public void reset(@NotNull GoBuildTargetSettings buildTargetSettings) { myOSCombo.setSelectedItem(expandDefault(buildTargetSettings.os, myDefaultOSValue)); myArchCombo.setSelectedItem(expandDefault(buildTargetSettings.arch, myDefaultArchValue)); myGoVersionCombo.setSelectedItem(expandDefault(buildTargetSettings.goVersion, myDefaultGoVersion)); myCgoCombo.setSelectedItem(expandDefault(cgo(buildTargetSettings.cgo), myDefaultCgo)); myCompilerCombo.setSelectedItem(buildTargetSettings.compiler); myCustomTagsField.setText(StringUtil.join(buildTargetSettings.customFlags, " ")); }
private void doTest() { myFixture.configureByFile(getTestName(false) + ".go"); List<String> textList = ContainerUtil.newArrayList(); for (GutterMark gutter : myFixture.findGuttersAtCaret()) { String text = gutter.getTooltipText(); textList.add(text); if ("Recursive call".equals(text) && AllIcons.Gutter.RecursiveMethod.equals(gutter.getIcon())) return; } fail("Not found gutter mark: " + "Recursive call" + " " + AllIcons.Gutter.RecursiveMethod + "\nin\n" + StringUtil.join(textList, "\n")); } }
private void doTopLevelTest(@NotNull String text, @NotNull String expectedTypeText) { myFixture.configureByText("a.go", "package a;" + text); PsiElement elementAt = findElementAtCaretOrInSelection(); GoExpression typeOwner = PsiTreeUtil.getNonStrictParentOfType(elementAt, GoExpression.class); assertNotNull("Cannot find type owner. Context element: " + elementAt.getText(), typeOwner); assertEquals(expectedTypeText, StringUtil.join(GoTypeUtil.getExpectedTypes(typeOwner), PsiElement::getText, "; ")); }