Java Code Examples for com.intellij.util.StringBuilderSpinAllocator#alloc()
The following examples show how to use
com.intellij.util.StringBuilderSpinAllocator#alloc() .
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: SqliteMagicLightMethodBuilder.java From sqlitemagic with Apache License 2.0 | 6 votes |
private PsiMethod rebuildMethodFromString() { final StringBuilder builder = StringBuilderSpinAllocator.alloc(); try { builder.append(getAllModifierProperties((LightModifierList) getModifierList())); PsiType returnType = getReturnType(); if (null != returnType) { builder.append(returnType.getCanonicalText()).append(' '); } builder.append(getName()); builder.append('('); if (getParameterList().getParametersCount() > 0) { for (PsiParameter parameter : getParameterList().getParameters()) { builder.append(parameter.getType().getCanonicalText()).append(' ').append(parameter.getName()).append(','); } builder.deleteCharAt(builder.length() - 1); } builder.append(')'); builder.append('{').append(" ").append('}'); PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getManager().getProject()).getElementFactory(); return elementFactory.createMethodFromText(builder.toString(), getContainingClass()); } finally { StringBuilderSpinAllocator.dispose(builder); } }
Example 2
Source File: HaxeProjectStructureDetector.java From intellij-haxe with Apache License 2.0 | 6 votes |
@Nullable static String readQualifiedName(final CharSequence charSequence, final Lexer lexer, boolean allowStar) { final StringBuilder buffer = StringBuilderSpinAllocator.alloc(); try { while (true) { if (lexer.getTokenType() != HaxeTokenTypes.ID && !(allowStar && lexer.getTokenType() != HaxeTokenTypes.OMUL)) break; buffer.append(charSequence, lexer.getTokenStart(), lexer.getTokenEnd()); if (lexer.getTokenType() == HaxeTokenTypes.OMUL) break; lexer.advance(); if (lexer.getTokenType() != HaxeTokenTypes.ODOT) break; buffer.append('.'); lexer.advance(); } String packageName = buffer.toString(); if (StringUtil.endsWithChar(packageName, '.')) return null; return packageName; } finally { StringBuilderSpinAllocator.dispose(buffer); } }
Example 3
Source File: CompilerPathsEx.java From consulo with Apache License 2.0 | 6 votes |
protected void acceptDirectory(final VirtualFile file, final String fileRoot, final String filePath) { ProgressManager.checkCanceled(); final VirtualFile[] children = file.getChildren(); for (final VirtualFile child : children) { final String name = child.getName(); final String _filePath; final StringBuilder buf = StringBuilderSpinAllocator.alloc(); try { buf.append(filePath).append("/").append(name); _filePath = buf.toString(); } finally { StringBuilderSpinAllocator.dispose(buf); } accept(child, fileRoot, _filePath); } }
Example 4
Source File: PackagingElementPath.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public String getPathStringFrom(String separator, @Nullable CompositePackagingElement<?> ancestor) { final StringBuilder builder = StringBuilderSpinAllocator.alloc(); try { final List<CompositePackagingElement<?>> parents = getParentsFrom(ancestor); for (int i = parents.size() - 1; i >= 0; i--) { builder.append(parents.get(i).getName()); if (i > 0) { builder.append(separator); } } return builder.toString(); } finally { StringBuilderSpinAllocator.dispose(builder); } }
Example 5
Source File: ModuleChunk.java From consulo with Apache License 2.0 | 6 votes |
public String getSourcePath(final int sourcesFilter) { if (getModuleCount() == 0) { return ""; } final VirtualFile[] filteredRoots = getSourceRoots(sourcesFilter); final StringBuilder buffer = StringBuilderSpinAllocator.alloc(); try { ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { for (VirtualFile root : filteredRoots) { if (buffer.length() > 0) { buffer.append(File.pathSeparatorChar); } buffer.append(root.getPath().replace('/', File.separatorChar)); } } }); return buffer.toString(); } finally { StringBuilderSpinAllocator.dispose(buffer); } }
Example 6
Source File: LogFilterModel.java From consulo with Apache License 2.0 | 6 votes |
@javax.annotation.Nullable private Pattern getCustomPattern() { String customFilter = getCustomFilter(); if (myCustomPattern == null && customFilter != null) { final StringBuilder buf = StringBuilderSpinAllocator.alloc(); try { for (int i = 0; i < customFilter.length(); i++) { final char c = customFilter.charAt(i); if (Character.isLetterOrDigit(c)) { buf.append(Character.toUpperCase(c)); } else { buf.append("\\").append(c); } } myCustomPattern = Pattern.compile(".*" + buf + ".*", Pattern.DOTALL); } finally { StringBuilderSpinAllocator.dispose(buf); } } return myCustomPattern; }
Example 7
Source File: ProjectStructureProblemsHolderImpl.java From consulo with Apache License 2.0 | 6 votes |
public String composeTooltipMessage() { final StringBuilder buf = StringBuilderSpinAllocator.alloc(); try { buf.append("<html><body>"); if (myProblemDescriptions != null) { int problems = 0; for (ProjectStructureProblemDescription problemDescription : myProblemDescriptions) { buf.append(XmlStringUtil.escapeString(problemDescription.getMessage(false))).append("<br>"); problems++; if (problems >= 10 && myProblemDescriptions.size() > 12) { buf.append(myProblemDescriptions.size() - problems).append(" more problems...<br>"); break; } } } buf.append("</body></html>"); return buf.toString(); } finally { StringBuilderSpinAllocator.dispose(buf); } }
Example 8
Source File: PackagingElementNode.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(PresentationData presentation) { final Collection<ArtifactProblemDescription> problems = ((ArtifactEditorImpl)myContext.getThisArtifactEditor()).getValidationManager().getProblems(this); if (problems == null || problems.isEmpty()) { super.update(presentation); return; } StringBuilder buffer = StringBuilderSpinAllocator.alloc(); final String tooltip; boolean isError = false; try { for (ArtifactProblemDescription problem : problems) { isError |= problem.getSeverity() == ProjectStructureProblemType.Severity.ERROR; buffer.append(problem.getMessage(false)).append("<br>"); } tooltip = XmlStringUtil.wrapInHtml(buffer); } finally { StringBuilderSpinAllocator.dispose(buffer); } getElementPresentation().render(presentation, addErrorHighlighting(isError, SimpleTextAttributes.REGULAR_ATTRIBUTES), addErrorHighlighting(isError, SimpleTextAttributes.GRAY_ATTRIBUTES)); presentation.setTooltip(tooltip); }
Example 9
Source File: SqliteMagicLightMethodBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
public String getAllModifierProperties(LightModifierList modifierList) { final StringBuilder builder = StringBuilderSpinAllocator.alloc(); try { for (String modifier : modifierList.getModifiers()) { if (!PsiModifier.PACKAGE_LOCAL.equals(modifier)) { builder.append(modifier).append(' '); } } return builder.toString(); } finally { StringBuilderSpinAllocator.dispose(builder); } }
Example 10
Source File: CacheUtils.java From consulo with Apache License 2.0 | 5 votes |
public static String getMethodSignature(String name, String descriptor) { final StringBuilder builder = StringBuilderSpinAllocator.alloc(); try { builder.append(name); builder.append(descriptor.substring(0, descriptor.indexOf(')') + 1)); return builder.toString(); } finally { StringBuilderSpinAllocator.dispose(builder); } }
Example 11
Source File: CompileDriver.java From consulo with Apache License 2.0 | 5 votes |
private void showNotSpecifiedError(@NonNls final String resourceId, List<String> modules, String editorNameToSelect) { String nameToSelect = null; final StringBuilder names = StringBuilderSpinAllocator.alloc(); final String message; try { final int maxModulesToShow = 10; for (String name : modules.size() > maxModulesToShow ? modules.subList(0, maxModulesToShow) : modules) { if (nameToSelect == null) { nameToSelect = name; } if (names.length() > 0) { names.append(",\n"); } names.append("\""); names.append(name); names.append("\""); } if (modules.size() > maxModulesToShow) { names.append(",\n..."); } message = CompilerBundle.message(resourceId, modules.size(), names.toString()); } finally { StringBuilderSpinAllocator.dispose(names); } if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error(message); } Messages.showMessageDialog(myProject, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon()); showConfigurationDialog(nameToSelect, editorNameToSelect); }