Java 类com.intellij.util.ObjectUtil 实例源码

项目:consulo-csharp    文件:CSharpLambdaExpressionImplUtil.java   
@NotNull
@RequiredReadAction
public static DotNetTypeRef resolveTypeForParameter(CSharpLambdaExpressionImpl target, int parameterIndex)
{
    CSharpLambdaResolveResult leftTypeRef = resolveLeftLambdaTypeRef(target);
    if(leftTypeRef == null)
    {
        return DotNetTypeRef.ERROR_TYPE;
    }

    if(leftTypeRef == CSharpUndefinedLambdaResolveResult.INSTANCE)
    {
        return DotNetTypeRef.UNKNOWN_TYPE;
    }
    DotNetTypeRef[] leftTypeParameters = leftTypeRef.getParameterTypeRefs();
    DotNetTypeRef typeRef = ArrayUtil2.safeGet(leftTypeParameters, parameterIndex);
    return ObjectUtil.notNull(typeRef, DotNetTypeRef.ERROR_TYPE);
}
项目:consulo-csharp    文件:CS1106.java   
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull CSharpMethodDeclaration element)
{
    DotNetParameter[] parameters = element.getParameters();
    if(parameters.length > 0 && parameters[0].hasModifier(CSharpModifier.THIS))
    {
        PsiElement parent = element.getParent();
        if(parent instanceof CSharpTypeDeclaration)
        {
            if(((CSharpTypeDeclaration) parent).getGenericParametersCount() > 0 || !((CSharpTypeDeclaration) parent).hasModifier(DotNetModifier.STATIC))
            {
                return newBuilder(ObjectUtil.notNull(element.getNameIdentifier(), element), formatElement(element));
            }
        }
    }
    return super.checkImpl(languageVersion, highlightContext, element);
}
项目:consulo-csharp    文件:CS0708.java   
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull DotNetModifierListOwner element)
{
    PsiElement parent = element.getParent();
    if(parent instanceof DotNetTypeDeclaration && ((DotNetTypeDeclaration) parent).hasModifier(DotNetModifier.STATIC))
    {
        if(CSharpPsiUtilImpl.isTypeLikeElement(element))
        {
            return null;
        }
        if(!element.hasModifier(DotNetModifier.STATIC))
        {
            PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
            return newBuilder(ObjectUtil.notNull(nameIdentifier, element), formatElement(element)).addQuickFix(new AddModifierFix
                    (DotNetModifier.STATIC, element));
        }
    }
    return null;
}
项目:consulo    文件:BinaryContent.java   
@Override
@SuppressWarnings({"EmptyCatchBlock"})
@Nullable
public Document getDocument() {
  if (myDocument == null) {
    if (isBinary()) return null;

    String text = null;
    try {
      Charset charset = ObjectUtil
              .notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
      text = CharsetToolkit.bytesToString(myBytes, charset);
    }
    catch (IllegalCharsetNameException e) {
    }

    //  Still NULL? only if not supported or an exception was thrown.
    //  Decode a string using the truly default encoding.
    if (text == null) text = new String(myBytes);
    text = LineTokenizer.correctLineSeparators(text);

    myDocument = EditorFactory.getInstance().createDocument(text);
    myDocument.setReadOnly(true);
  }
  return myDocument;
}
项目:consulo    文件:MessageDialogBuilder.java   
@Messages.YesNoCancelResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  String cancelText = ObjectUtil.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  }
  catch (Exception ignored) {}

  int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption);
  return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL;

}
项目:consulo    文件:TreeTable.java   
@Override
protected void processKeyEvent(KeyEvent e){
  if (!myProcessCursorKeys) {
    super.processKeyEvent(e);
    return;
  }

  int keyCode = e.getKeyCode();
  final int selColumn = columnModel.getSelectionModel().getAnchorSelectionIndex();
  boolean treeHasFocus = selColumn == -1 || selColumn >= 0 && isTreeColumn(selColumn);
  boolean oneRowSelected = getSelectedRowCount() == 1;
  if(treeHasFocus && oneRowSelected && ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT))){
    myTree._processKeyEvent(e);
    int rowToSelect = ObjectUtil.notNull(myTree.getSelectionRows())[0];
    getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
    TableUtil.scrollSelectionToVisible(this);
  }
  else{
    super.processKeyEvent(e);
  }
}
项目:consulo    文件:LoginAction.java   
@RequiredDispatchThread
@Override
public void update(@Nonnull AnActionEvent e) {
  if (!EarlyAccessProgramManager.is(ServiceAuthEarlyAccessProgramDescriptor.class)) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  ServiceAuthConfiguration configuration = ServiceAuthConfiguration.getInstance();

  Presentation presentation = e.getPresentation();

  String email = configuration.getEmail();
  if (email == null) {
    presentation.setText("Logged as anonymous");
    presentation.setIcon(AllIcons.Actions.LoginAvator);
  }
  else {
    presentation.setText("Logged as '" + email + "'");

    Icon userIcon = configuration.getUserIcon();
    presentation.setIcon(ObjectUtil.notNull(userIcon, AllIcons.Actions.LoginAvator));
  }
}
项目:consulo    文件:LocalFileSystemImpl.java   
@Nonnull
@Override
public Set<WatchRequest> replaceWatchedRoots(@Nonnull Collection<WatchRequest> watchRequests,
                                             @Nullable Collection<String> recursiveRoots,
                                             @Nullable Collection<String> flatRoots) {
  recursiveRoots = ObjectUtil.notNull(recursiveRoots, Collections.emptyList());
  flatRoots = ObjectUtil.notNull(flatRoots, Collections.emptyList());

  Set<WatchRequest> result = new HashSet<>();
  synchronized (myLock) {
    boolean update = doAddRootsToWatch(recursiveRoots, flatRoots, result) |
                     doRemoveWatchedRoots(watchRequests);
    if (update) {
      myNormalizedTree = null;
      setUpFileWatcher();
    }
  }
  return result;
}
项目:consulo    文件:DataManagerImpl.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getData(@Nonnull Key<T> dataId) {
  int currentEventCount = IdeEventQueue.getInstance().getEventCount();
  if (myEventCount != -1 && myEventCount != currentEventCount) {
    LOG.error("cannot share data context between Swing events; initial event count = " + myEventCount + "; current event count = " + currentEventCount);
    return doGetData(dataId);
  }

  if (ourSafeKeys.contains(dataId)) {
    Object answer = myCachedData.get(dataId);
    if (answer == null) {
      answer = doGetData(dataId);
      myCachedData.put(dataId, answer == null ? ObjectUtil.NULL : answer);
    }
    return answer != ObjectUtil.NULL ? (T)answer : null;
  }
  else {
    return doGetData(dataId);
  }
}
项目:consulo    文件:RemoteUtil.java   
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (method.getDeclaringClass() == Object.class) {
    return method.invoke(myRemote, args);
  }
  else {
    Method m = ourRemoteToLocalMap.get(Pair.<Class<?>, Class<?>>create(myRemote.getClass(), myClazz)).get(method);
    if (m == null) throw new NoSuchMethodError(method.getName() + " in " + myRemote.getClass());
    try {
      return handleRemoteResult(m.invoke(myRemote, args), method.getReturnType(), myLoader, false);
    }
    catch (InvocationTargetException e) {
      Throwable cause = e.getCause(); // root cause may go deeper than we need, so leave it like this
      if (cause instanceof ServerError) cause = ObjectUtil.chooseNotNull(cause.getCause(), cause);
      if (cause instanceof RuntimeException) throw cause;
      if (cause instanceof Error) throw cause;
      if (canThrow(cause, method)) throw cause;
      throw new RuntimeException(cause);
    }
  }
}
项目:consulo    文件:PsiPackageManagerImpl.java   
@RequiredReadAction
@Nullable
@Override
public PsiPackage findPackage(@Nonnull String qualifiedName, @Nonnull Class<? extends ModuleExtension> extensionClass) {
  ConcurrentMap<String, Object> map = myPackageCache.get(extensionClass);
  if (map != null) {
    final Object value = map.get(qualifiedName);
    // if we processed - but not found package
    if (value == ObjectUtil.NULL) {
      return null;
    }
    else if (value != null) {
      return (PsiPackage)value;
    }
  }

  PsiPackage newPackage = createPackage(qualifiedName, extensionClass);

  Object valueForInsert = ObjectUtil.notNull(newPackage, ObjectUtil.NULL);

  myPackageCache.computeIfAbsent(extensionClass, aClass -> ContainerUtil.newConcurrentMap()).putIfAbsent(qualifiedName, valueForInsert);

  return newPackage;
}
项目:consulo    文件:NavBarModel.java   
private Object calculateRoot(DataContext dataContext) {
  // Narrow down the root element to the first interesting one
  Object root = dataContext.getData(LangDataKeys.MODULE);
  if (root != null) return root;

  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) return null;

  Object projectChild;
  Object projectGrandChild = null;

  CommonProcessors.FindFirstAndOnlyProcessor<Object> processor = new CommonProcessors.FindFirstAndOnlyProcessor<>();
  processChildren(project, processor);
  projectChild = processor.reset();
  if (projectChild != null) {
    processChildren(projectChild, processor);
    projectGrandChild = processor.reset();
  }
  return ObjectUtil.chooseNotNull(projectGrandChild, ObjectUtil.chooseNotNull(projectChild, project));
}
项目:consulo-javascript    文件:JomUtil.java   
@Nullable
public static String getJsonGetPropertyName(@NotNull Method method)
{
    JomPropertyGetter annotation = method.getAnnotation(JomPropertyGetter.class);
    if(annotation == null)
    {
        return null;
    }

    String propertyName = StringUtil.getPropertyName(method.getName());
    propertyName = ObjectUtil.notNull(propertyName, method.getName());
    if(!StringUtil.isEmpty(annotation.value()))
    {
        propertyName = annotation.value();
    }
    return propertyName;
}
项目:consulo-java    文件:JavaParametersUtil.java   
private static Sdk createAlternativeJdk(@NotNull String jreHome) throws CantRunException
{
    final Sdk configuredJdk = SdkTable.getInstance().findSdk(jreHome);
    if(configuredJdk != null)
    {
        return configuredJdk;
    }

    if(!OwnJdkUtil.checkForJre(jreHome))
    {
        throw new CantRunException(JavaExecutionBundle.message("jre.path.is.not.valid.jre.home.error.message", jreHome));
    }

    final JavaSdk javaSdk = JavaSdk.getInstance();
    return javaSdk.createJdk(ObjectUtil.notNull(javaSdk.getVersionString(jreHome), ""), jreHome);
}
项目:consulo-unity3d    文件:Unity3dMetaManager.java   
@Nullable
@RequiredReadAction
public String getGUID(@NotNull VirtualFile virtualFile)
{
    String name = virtualFile.getName();

    VirtualFile parent = virtualFile.getParent();
    if(parent == null)
    {
        return null;
    }

    int targetId = FileBasedIndex.getFileId(virtualFile);

    Object o = myGUIDs.computeIfAbsent(targetId, integer ->
    {
        VirtualFile child = parent.findChild(name + "." + Unity3dMetaFileType.INSTANCE.getDefaultExtension());
        if(child != null)
        {
            String guid = null;
            PsiFile file = PsiManager.getInstance(myProject).findFile(child);
            if(file instanceof YAMLFile)
            {
                guid = Unity3dMetaIndexExtension.findGUIDFromFile((YAMLFile) file);
            }
            return guid == null ? ObjectUtil.NULL : guid;
        }
        return ObjectUtil.NULL;
    });
    return o instanceof String ? (String) o : null;
}
项目:consulo-csharp    文件:CSharpNamespaceResolveContext.java   
@RequiredReadAction
@Nullable
@Override
@SuppressWarnings("unchecked")
public CSharpElementGroup<CSharpMethodDeclaration> findExtensionMethodGroupByName(@NotNull String name)
{
    Object o = myExtensionGroups.get(name);
    return o == ObjectUtil.NULL ? null : (CSharpElementGroup<CSharpMethodDeclaration>) o;
}
项目:consulo-csharp    文件:ConsuloModuleAsAssemblyModule.java   
@RequiredReadAction
@NotNull
@Override
public String getName()
{
    String assemblyTitle = DotNetAssemblyUtil.getAssemblyTitle(myModule);
    return ObjectUtil.notNull(assemblyTitle, myModule.getName());
}
项目:consulo-csharp    文件:CSharpCompositeTypeDeclaration.java   
@RequiredReadAction
@NotNull
public static DotNetTypeDeclaration selectCompositeOrSelfType(@NotNull DotNetTypeDeclaration parent)
{
    if(parent.hasModifier(CSharpModifier.PARTIAL))
    {
        CSharpCompositeTypeDeclaration compositeType = findCompositeType((CSharpTypeDeclaration) parent);
        return ObjectUtil.notNull(compositeType, parent);
    }
    return parent;
}
项目:consulo-csharp    文件:CSharpCompositeTypeDeclaration.java   
@RequiredReadAction
@Nullable
public static CSharpCompositeTypeDeclaration findCompositeType(@NotNull CSharpTypeDeclaration parent)
{
    Object cachedValue = CachedValuesManager.getCachedValue(parent, () -> CachedValueProvider.Result.create(findCompositeTypeImpl(parent), PsiModificationTracker
            .OUT_OF_CODE_BLOCK_MODIFICATION_COUNT));
    return cachedValue == ObjectUtil.NULL ? null : (CSharpCompositeTypeDeclaration) cachedValue;
}
项目:consulo-csharp    文件:CS1105.java   
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull CSharpMethodDeclaration element)
{
    DotNetParameter[] parameters = element.getParameters();
    if(parameters.length > 0 && parameters[0].hasModifier(CSharpModifier.THIS))
    {
        if(!element.hasModifier(DotNetModifier.STATIC))
        {
            return newBuilder(ObjectUtil.notNull(element.getNameIdentifier(), element), formatElement(element));
        }
    }
    return null;
}
项目:consulo-dotnet    文件:LimitableDotNetLogicValueView.java   
@Override
@SuppressWarnings("unchecked")
public void computeChildren(@NotNull UserDataHolderBase dataHolder,
        @NotNull DotNetDebugContext debugContext,
        @NotNull DotNetAbstractVariableValueNode parentNode,
        @NotNull DotNetStackFrameProxy frameProxy,
        @Nullable DotNetValueProxy oldValue,
        @NotNull XCompositeNode node)
{
    if(oldValue == null || !isMyValue(oldValue))
    {
        node.setErrorMessage("No value");
        return;
    }

    T value = (T) oldValue;

    final int length = getSize(value);
    final int startIndex = ObjectUtil.notNull(dataHolder.getUserData(ourLastIndex), 0);

    XValueChildrenList childrenList = new XValueChildrenList();
    int max = Math.min(startIndex + XCompositeNode.MAX_CHILDREN_TO_SHOW, length);
    for(int i = startIndex; i < max; i++)
    {
        childrenList.add(createChildValue(i, debugContext, frameProxy, value));
    }

    dataHolder.putUserData(ourLastIndex, max);

    node.addChildren(childrenList, true);

    if(length > max)
    {
        node.tooManyChildren(length - max);
    }
}
项目:consulo    文件:MessageDialogBuilder.java   
@Messages.YesNoResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  } catch (Exception ignored) {}

  return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO;

}
项目:consulo    文件:IOExceptionDialog.java   
@Nonnull
@Override
protected Action[] createLeftSideActions() {
  return new Action[] {
    new AbstractAction(CommonBundle.message("dialog.ioexception.proxy")) {
      @Override
      public void actionPerformed(@Nonnull ActionEvent e) {
        HttpConfigurable.editConfigurable(ObjectUtil.tryCast(e.getSource(), JComponent.class));
      }
    }
  };
}
项目:consulo    文件:FirefoxSettingsConfigurable.java   
@Override
public void reset() {
  File defaultFile = FirefoxUtil.getDefaultProfileIniPath();
  myDefaultProfilesIniPath = defaultFile != null ? defaultFile.getAbsolutePath() : "";

  String path = mySettings.getProfilesIniPath();
  myProfilesIniPathField.setText(path != null ? FileUtilRt.toSystemDependentName(path) : myDefaultProfilesIniPath);
  updateProfilesList();
  myProfileCombobox.setSelectedItem(ObjectUtil.notNull(mySettings.getProfile(), myDefaultProfile));
}
项目:consulo    文件:StubBase.java   
@Override
public T getPsi() {
  T psi = myPsi;
  if (psi != null) return psi;

  psi = (T)getStubType().createPsi(this);
  return ourPsiUpdater.compareAndSet(this, null, psi) ? psi : ObjectUtil.assertNotNull(myPsi);
}
项目:consulo    文件:LanguageSubstitutors.java   
private static void processLanguageSubstitution(@Nonnull final VirtualFile file,
                                                @Nonnull Language originalLang,
                                                @Nonnull final Language substitutedLang) {
  if (file instanceof VirtualFileWindow) {
    // Injected files are created with substituted language, no need to reparse:
    //   com.intellij.psi.impl.source.tree.injected.MultiHostRegistrarImpl#doneInjecting
    return;
  }
  Language prevSubstitutedLang = SUBSTITUTED_LANG_KEY.get(file);
  final Language prevLang = ObjectUtil.notNull(prevSubstitutedLang, originalLang);
  if (!prevLang.is(substitutedLang)) {
    if (file.replace(SUBSTITUTED_LANG_KEY, prevSubstitutedLang, substitutedLang)) {
      if (prevSubstitutedLang == null) {
        return; // no need to reparse for the first language substitution
      }
      if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;
      }
      file.putUserData(REPARSING_SCHEDULED, true);
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (file.replace(REPARSING_SCHEDULED, true, null)) {
            LOG.info("Reparsing " + file.getPath() + " because of language substitution " +
                     prevLang.getID() + "->" + substitutedLang.getID());
            FileContentUtilCore.reparseFiles(file);
          }
        }
      }, ModalityState.defaultModalityState());
    }
  }
}
项目:consulo    文件:ToolWindowBase.java   
@RequiredUIAccess
@Override
@Nonnull
public final String getStripeTitle() {
  UIAccess.assertIsUIThread();
  return ObjectUtil.notNull(myStripeTitle, myId);
}
项目:consulo    文件:DataManagerImpl.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getData(@Nonnull Key<T> dataId) {
  if (ourSafeKeys.contains(dataId)) {
    Object answer = myCachedData.get(dataId);
    if (answer == null) {
      answer = doGetData(dataId);
      myCachedData.put(dataId, answer == null ? ObjectUtil.NULL : answer);
    }
    return answer != ObjectUtil.NULL ? (T)answer : null;
  }
  else {
    return doGetData(dataId);
  }
}
项目:consulo    文件:SdkUtil.java   
@Nonnull
public static Icon getIcon(@Nullable Sdk sdk) {
  if (sdk == null) {
    return AllIcons.Toolbar.Unknown;
  }
  SdkType sdkType = (SdkType)sdk.getSdkType();
  Icon icon = ObjectUtil.notNull(sdkType.getIcon(), AllIcons.Toolbar.Unknown);
  if(sdk.isPredefined()) {
    return new IconDescriptor(icon).addLayerIcon(AllIcons.Nodes.Locked).toIcon();
  }
  else {
    return icon;
  }
}
项目:consulo    文件:NullableLazyKey.java   
@Nullable
public final T getValue(H h) {
  T data = h.getUserData(this);
  if (data == null) {
    data = myFunction.fun(h);
    h.putUserData(this, data == null ? (T)ObjectUtil.NULL : data);
  }
  return data == ObjectUtil.NULL ? null : data;
}
项目:consulo    文件:XDebuggerTreeSpeedSearch.java   
@Nullable
@Override
protected Object findElement(String s) {
  String string = s.trim();

  XDebuggerTreeNode node = ObjectUtil.tryCast(myComponent.getLastSelectedPathComponent(), XDebuggerTreeNode.class);
  if (node == null) {
    node = ObjectUtil.tryCast(myComponent.getModel().getRoot(), XDebuggerTreeNode.class);
    if (node == null) {
      return null;
    }
  }
  return findPath(string, node, true);
}
项目:consulo    文件:ShowDiffWithLocalAction.java   
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return;

  VcsRevisionNumber currentRevisionNumber = e.getRequiredData(VcsDataKeys.HISTORY_SESSION).getCurrentRevisionNumber();
  VcsFileRevision selectedRevision = e.getRequiredData(VcsDataKeys.VCS_FILE_REVISIONS)[0];
  FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH);

  if (currentRevisionNumber != null && selectedRevision != null) {
    DiffFromHistoryHandler diffHandler =
            ObjectUtil.notNull(e.getRequiredData(VcsDataKeys.HISTORY_PROVIDER).getHistoryDiffHandler(), new StandardDiffFromHistoryHandler());
    diffHandler.showDiffForTwo(project, filePath, selectedRevision, new CurrentRevision(filePath.getVirtualFile(), currentRevisionNumber));
  }
}
项目:consulo    文件:FileOrDirectoryDependencyTabContext.java   
public FileOrDirectoryDependencyTabContext(Disposable parent, ClasspathPanel panel, StructureConfigurableContext context) {
  super(panel, context);

  myLibraryTypes = new HashMap<LibraryRootsComponentDescriptor, LibraryType>();
  myDefaultDescriptor = new DefaultLibraryRootsComponentDescriptor();

  for (LibraryType<?> libraryType : LibraryEditingUtil.getSuitableTypes(myClasspathPanel)) {
    LibraryRootsComponentDescriptor descriptor = null;
    if (libraryType != null) {
      descriptor = libraryType.createLibraryRootsComponentDescriptor();
    }
    if (descriptor == null) {
      descriptor = myDefaultDescriptor;
    }
    if (!myLibraryTypes.containsKey(descriptor)) {
      myLibraryTypes.put(descriptor, libraryType);
    }
  }

  Module module = myClasspathPanel.getRootModel().getModule();

  myFileChooserDescriptor = createFileChooserDescriptor();
  myFileSystemTree = new FileSystemTreeImpl(module.getProject(), myFileChooserDescriptor);
  Disposer.register(parent, myFileSystemTree);
  myFileSystemTree.showHiddens(true);
  final VirtualFile dirForSelect = ObjectUtil.chooseNotNull(module.getModuleDir(), module.getProject().getBaseDir());
  if(dirForSelect != null) {
    myFileSystemTree.select(dirForSelect, new Runnable() {
      @Override
      public void run() {
        myFileSystemTree.expand(dirForSelect, null);
      }
    });
  }
}
项目:consulo    文件:TemplateCommentPanel.java   
private void initEditor() {
  if (myEditor == null) {
    myPreviewEditorPanel.removeAll();
    EditorFactory editorFactory = EditorFactory.getInstance();
    myDocument = editorFactory.createDocument("");

    myEditor = editorFactory.createEditor(myDocument, myProject, ObjectUtil.notNull(myFileType, PlainTextFileType.INSTANCE), true);
    CopyrightConfigurable.setupEditor(myEditor);

    myPreviewEditorPanel.add(myEditor.getComponent(), BorderLayout.CENTER);
  }
}
项目:consulo    文件:GotoDeclarationAction.java   
@Nonnull
public static Pair<PsiElement[], GotoDeclarationHandler> findAllTargetElementsInfo(Project project, Editor editor, int offset) {
  if (TargetElementUtil.inVirtualSpace(editor, offset)) {
    return Pair.create(PsiElement.EMPTY_ARRAY, null);
  }

  Pair<PsiElement[], GotoDeclarationHandler> pair = findTargetElementsNoVSWithHandler(project, editor, offset, true);
  return Pair.create(ObjectUtil.notNull(pair.getFirst(), PsiElement.EMPTY_ARRAY), pair.getSecond());
}
项目:consulo    文件:DesktopToolWindowManagerImpl.java   
private EditorSplitters getSplittersToFocus() {
  Window activeWindow = myWindowManager.getMostRecentFocusedWindow();

  if (activeWindow instanceof DesktopFloatingDecorator) {
    IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
    IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
    JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
    Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
    activeWindow = ObjectUtil.notNull(lastFocusedWindow, activeWindow);
  }

  FileEditorManagerEx fem = FileEditorManagerEx.getInstanceEx(myProject);
  EditorSplitters splitters = activeWindow != null ? fem.getSplittersFor(activeWindow) : null;
  return splitters != null ? splitters : fem.getSplitters();
}
项目:consulo-java    文件:DefaultJreSelector.java   
private static <T extends ComboBox<?>> boolean isClassInProductionSources(T moduleComboBox, Function<T, Module> getSelectedModule, EditorTextFieldWithBrowseButton classSelector)
{
    Module module = getSelectedModule.apply(moduleComboBox);
    if(module == null)
    {
        return false;
    }
    return ObjectUtil.notNull(JavaParametersUtil.isClassInProductionSources(classSelector.getText(), module), Boolean.FALSE);
}
项目:consulo-java    文件:DelegationContract.java   
@NotNull
@Override
public List<StandardMethodContract> toContracts(PsiMethod method, Supplier<PsiCodeBlock> body)
{
    PsiMethodCallExpression call = ObjectUtil.tryCast(expression.restoreExpression(body.get()), PsiMethodCallExpression.class);
    if(call == null)
    {
        return Collections.emptyList();
    }

    JavaResolveResult result = call.resolveMethodGenerics();
    PsiMethod targetMethod = ObjectUtil.tryCast(result.getElement(), PsiMethod.class);
    if(targetMethod == null)
    {
        return Collections.emptyList();
    }
    PsiParameter[] parameters = targetMethod.getParameterList().getParameters();
    PsiExpression[] arguments = call.getArgumentList().getExpressions();
    boolean varArgCall = MethodCallInstruction.isVarArgCall(targetMethod, result.getSubstitutor(), arguments, parameters);


    List<StandardMethodContract> fromDelegate = ContainerUtil.mapNotNull(ControlFlowAnalyzer.getMethodContracts(targetMethod), dc -> convertDelegatedMethodContract(method, parameters, arguments,
            varArgCall, dc));

    if(NullableNotNullManager.isNotNull(targetMethod))
    {
        return ContainerUtil.concat(ContainerUtil.map(fromDelegate, DelegationContract::returnNotNull), Collections.singletonList(new StandardMethodContract(emptyConstraints(method),
                MethodContract.ValueConstraint.NOT_NULL_VALUE)));
    }
    return fromDelegate;
}
项目:consulo-unity3d    文件:UnityLogPostHandlerRequest.java   
@MagicConstant(valuesFromClass = MessageCategory.class)
public int getMessageCategory()
{
    return ObjectUtil.notNull(ourTypeMap.get(type), MessageCategory.INFORMATION);
}
项目:consulo-csharp    文件:ThisObjectEvaluator.java   
@NotNull
public static DotNetValueProxy calcThisObject(@NotNull DotNetStackFrameProxy proxy, DotNetValueProxy thisObject)
{
    return ObjectUtil.notNull(tryToFindObjectInsideYieldOrAsyncThis(proxy, thisObject), thisObject);
}