congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
JavaDirectoryService.getPackage
Code IndexAdd Tabnine to your IDE (free)

How to use
getPackage
method
in
com.intellij.psi.JavaDirectoryService

Best Java code snippets using com.intellij.psi.JavaDirectoryService.getPackage (Showing top 4 results out of 315)

origin: dubreuia/intellij-plugin-save-actions

PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory);
if (aPackage == memberPackage || aPackage != null && memberPackage != null && Comparing.strEqual(aPackage.getQualifiedName(), memberPackage.getQualifiedName())) {
 return suggestPackageLocal(member);
origin: t28hub/json2java4idea

  @Override
  protected void run(@NotNull Result<PsiFile> result) throws Throwable {
    final PsiPackage packageElement = directoryService.getPackage(directory);
    if (packageElement == null) {
      throw new InvalidDirectoryException("Target directory does not provide a package");
    }

    final String fileName = Extensions.append(name, StdFileTypes.JAVA);
    final PsiFile found = directory.findFile(fileName);
    if (found != null) {
      throw new ClassAlreadyExistsException("Class '" + name + "'already exists in " + packageElement.getName());
    }

    final String packageName = packageElement.getQualifiedName();
    final String className = Extensions.remove(this.name, StdFileTypes.JAVA);
    try {
      final String java = converter.convert(packageName, className, json);
      final PsiFile classFile = fileFactory.createFileFromText(fileName, JavaFileType.INSTANCE, java);
      CodeStyleManager.getInstance(classFile.getProject()).reformat(classFile);
      JavaCodeStyleManager.getInstance(classFile.getProject()).optimizeImports(classFile);
      final PsiFile created = (PsiFile) directory.add(classFile);
      result.setResult(created);
    } catch (IOException e) {
      throw new ClassCreationException("Failed to create new class from JSON", e);
    }
  }
}
origin: JetBrains/Grammar-Kit

 @Override
 protected void run() throws Throwable {
  try {
   PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile.getParent());
   assert psiDirectory != null;
   PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory);
   String packageName = aPackage == null ? null : aPackage.getQualifiedName();
   String text = generateLexerText(bnfFile, packageName);
   VfsUtil.saveText(virtualFile, text);
   Notifications.Bus.notify(new Notification(BnfConstants.GENERATION_GROUP,
     virtualFile.getName() + " generated", "to " + virtualFile.getParent().getPath(),
     NotificationType.INFORMATION), project);
   associateFileTypeAndNavigate(project, virtualFile);
  }
  catch (final IncorrectOperationException e) {
   ApplicationManager.getApplication().invokeLater(
    () -> Messages.showErrorDialog(project, "Unable to create file " + flexFileName + "\n" + e.getLocalizedMessage(), "Create JFlex Lexer"));
  }
 }
}.execute();
origin: dubreuia/intellij-plugin-save-actions

PsiPackage memberPackage = memberDirectory == null ? null : JavaDirectoryService.getInstance().getPackage(memberDirectory);
log(member.getName()+ ": checking effective level for "+member);
com.intellij.psiJavaDirectoryServicegetPackage

Javadoc

Returns the package corresponding to the directory.

Popular methods of JavaDirectoryService

  • getInstance
  • createClass
  • getLanguageLevel
  • isSourceRoot
    Checks if the directory is a source root for the project to which it belongs.

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setRequestProperty (URLConnection)
  • getSystemService (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Permission (java.security)
    Legacy security code; do not use.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now