Java Code Examples for com.intellij.openapi.util.text.StringUtil#endsWith()

The following examples show how to use com.intellij.openapi.util.text.StringUtil#endsWith() . 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: CSharpIntroduceLocalVariableHandler.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
protected String getDeclarationString(CSharpIntroduceOperation operation, String initExpression)
{
	StringBuilder builder = new StringBuilder();
	DotNetExpression initializer = operation.getInitializer();
	CSharpCodeGenerationSettings generationSettings = CSharpCodeGenerationSettings.getInstance(operation.getProject());
	buildVariableTypeString(operation.getProject(), initializer, builder, generationSettings.USE_VAR_FOR_EXTRACT_LOCAL_VARIABLE);
	builder.append(" ").append(operation.getName()).append(" = ").append(initExpression);
	PsiElement parent = initializer.getParent();
	if(!(parent instanceof CSharpExpressionStatementImpl) || !StringUtil.endsWith(parent.getText(), ";") || ((CSharpExpressionStatementImpl) parent).getExpression() != initializer)
	{
		builder.append(";");
	}
	builder.append('\n');
	return builder.toString();
}
 
Example 2
Source File: IdeaGateway.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean isVersioned(@Nonnull VirtualFile f, boolean shouldBeInContent) {
  if (!f.isInLocalFileSystem()) return false;

  if (!f.isDirectory() && StringUtil.endsWith(f.getNameSequence(), ".class")) return false;

  VersionedFilterData versionedFilterData = getVersionedFilterData();

  boolean isInContent = false;
  int numberOfOpenProjects = versionedFilterData.myOpenedProjects.size();
  for (int i = 0; i < numberOfOpenProjects; ++i) {
    if (f.equals(versionedFilterData.myWorkspaceFiles.get(i))) return false;
    ProjectFileIndex index = versionedFilterData.myProjectFileIndices.get(i);

    if (index.isExcluded(f)) return false;
    isInContent |= index.isInContent(f);
  }
  if (shouldBeInContent && !isInContent) return false;

  // optimisation: FileTypeManager.isFileIgnored(f) already checked inside ProjectFileIndex.isIgnored()
  return numberOfOpenProjects != 0 || !FileTypeManager.getInstance().isFileIgnored(f);
}
 
Example 3
Source File: TfIgnoreUtil.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
private static void addLineToFile(VirtualFile file, String line) {
    FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    Document document = ObjectUtils.assertNotNull(fileDocumentManager.getDocument(file));
    CharSequence contents = document.getCharsSequence();
    if (!StringUtil.isEmpty(contents) && !StringUtil.endsWith(contents, "\n")) {
        document.insertString(contents.length(), "\n");
    }
    document.insertString(document.getTextLength(), line);
    fileDocumentManager.saveDocument(document);
}
 
Example 4
Source File: ContentRoot.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
public String getPackageRoot() {
  // source_root might contain '.' in the path.

  final boolean sourceRootMatchesPackage = StringUtil.endsWith(source_root.replace(File.separatorChar, '.'), package_prefix);
  return sourceRootMatchesPackage ?
         source_root.substring(0, source_root.length() - package_prefix.length()) :
         source_root;
}
 
Example 5
Source File: IgnoredPatternSet.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean isIgnored(@Nonnull CharSequence fileName) {
  if (myIgnorePatterns.findAssociatedFileType(fileName) == Boolean.TRUE) {
    return true;
  }

  //Quite a hack, but still we need to have some name, which
  //won't be caught by VFS for sure.
  return StringUtil.endsWith(fileName, FileUtil.ASYNC_DELETE_EXTENSION);
}
 
Example 6
Source File: WildcardFileNameMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(final CharSequence filename) {
  return StringUtil.endsWith(filename, mySuffix);
}
 
Example 7
Source File: UrlPartNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
boolean urlEndsWithName(@Nonnull String urlAfter, VirtualFile fileAfter) {
  return StringUtil.endsWith(urlAfter, getName());
}
 
Example 8
Source File: FilePointerPartNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
boolean urlEndsWithName(@Nonnull String urlAfter, VirtualFile fileAfter) {
  if (fileAfter != null) {
    return nameId == getNameId(fileAfter);
  }
  return StringUtil.endsWith(urlAfter, getName());
}