当前位置: 首页>>代码示例>>Java>>正文


Java ContainerUtilRt.newStack方法代码示例

本文整理汇总了Java中com.intellij.util.containers.ContainerUtilRt.newStack方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtilRt.newStack方法的具体用法?Java ContainerUtilRt.newStack怎么用?Java ContainerUtilRt.newStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.ContainerUtilRt的用法示例。


在下文中一共展示了ContainerUtilRt.newStack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConfigPath

import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
/**
 * Allows to build file system path to the target gradle sub-project given the root project path.
 *
 * @param subProject       target sub-project which config path we're interested in
 * @param rootProjectPath  path to root project's directory which contains 'build.gradle'
 * @return                 path to the given sub-project's directory which contains 'build.gradle'
 */
@NotNull
public static String getConfigPath(@NotNull GradleProject subProject, @NotNull String rootProjectPath) {
  try {
    GradleScript script = subProject.getBuildScript();
    if (script != null) {
      File file = script.getSourceFile();
      if (file != null) {
        if (file.isFile()) {
          // The file points to 'build.gradle' at the moment but we keep it's parent dir path instead.
          file = file.getParentFile();
        }
        return ExternalSystemApiUtil.toCanonicalPath(file.getCanonicalPath());
      }
    }
  }
  catch (Exception e) {
    // As said by gradle team: 'One thing I'm interested in is whether you have any thoughts about how the tooling API should
    // deal with missing details from the model - for example, when asking for details about the build scripts when using
    // a version of Gradle that does not supply that information. Currently, you'll get a `UnsupportedOperationException`
    // when you call the `getBuildScript()` method'.
    //
    // So, just ignore it and assume that the user didn't define any custom build file name.
  }
  File rootProjectParent = new File(rootProjectPath);
  StringBuilder buffer = new StringBuilder(FileUtil.toCanonicalPath(rootProjectParent.getAbsolutePath()));
  Stack<String> stack = ContainerUtilRt.newStack();
  for (GradleProject p = subProject; p != null; p = p.getParent()) {
    stack.push(p.getName());
  }

  // pop root project
  stack.pop();
  while (!stack.isEmpty()) {
    buffer.append(ExternalSystemConstants.PATH_SEPARATOR).append(stack.pop());
  }
  return buffer.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:GradleUtil.java

示例2: getConfigPath

import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
/**
 * Allows to build file system path to the target gradle sub-project given the root project path.
 *
 * @param subProject       target sub-project which config path we're interested in
 * @param rootProjectPath  path to root project's directory which contains 'build.gradle'
 * @return                 path to the given sub-project's directory which contains 'build.gradle'
 */
@NotNull
public static String getConfigPath(@NotNull GradleProject subProject, @NotNull String rootProjectPath) {
  File rootProjectParent = new File(rootProjectPath).getParentFile();
  StringBuilder buffer = new StringBuilder(FileUtil.toCanonicalPath(rootProjectParent.getAbsolutePath()));
  Stack<String> stack = ContainerUtilRt.newStack();
  for (GradleProject p = subProject; p != null; p = p.getParent()) {
    stack.push(p.getName());
  }
  while (!stack.isEmpty()) {
    buffer.append(ExternalSystemConstants.PATH_SEPARATOR).append(stack.pop());
  }
  return buffer.toString();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:GradleUtil.java

示例3: setStructureViewSelection

import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
private void setStructureViewSelection(@NotNull final String propertyName) {
  if (myStructureViewComponent.isDisposed()) {
    return;
  }
  JTree tree = myStructureViewComponent.getTree();
  if (tree == null) {
    return;
  }

  Object root = tree.getModel().getRoot();
  if (AbstractTreeUi.isLoadingChildrenFor(root)) {
    boolean isEditorVisible = false;
    for (FileEditor editor : FileEditorManager.getInstance(myProject).getSelectedEditors()) {
      if (editor == this) {
        isEditorVisible = true;
        break;
      }
    }
    if (!isEditorVisible) {
      myPropertyToSelectWhenVisible = propertyName;
      return;
    }
    mySelectionChangeAlarm.cancelAllRequests();
    mySelectionChangeAlarm.addRequest(new Runnable() {
      @Override
      public void run() {
        mySelectionChangeAlarm.cancelAllRequests();
        setStructureViewSelection(propertyName);
      }
    }, 500);
    return;
  }

  Stack<TreeElement> toCheck = ContainerUtilRt.newStack();
  toCheck.push(myStructureViewComponent.getTreeModel().getRoot());

  while (!toCheck.isEmpty()) {
    TreeElement element = toCheck.pop();
    PsiElement value = element instanceof ResourceBundlePropertyStructureViewElement
                   ? ((ResourceBundlePropertyStructureViewElement)element).getProperty().getPsiElement()
                   : null;
    if (value != null) {
      final IProperty property = PropertiesImplUtil.getProperty(value);
      if (propertyName.equals(property.getUnescapedKey())) {
        final PropertiesAnchorizer.PropertyAnchor anchor = myPropertiesAnchorizer.get(property);
        myStructureViewComponent.select(anchor, true);
        selectionChanged();
        return;
      }
    }
    else {
      for (TreeElement treeElement : element.getChildren()) {
        toCheck.push(treeElement);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:58,代码来源:ResourceBundleEditor.java

示例4: setStructureViewSelection

import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
private void setStructureViewSelection(@NotNull final String propertyName) {
  JTree tree = myStructureViewComponent.getTree();
  if (tree == null) {
    return;
  }

  Object root = tree.getModel().getRoot();
  if (AbstractTreeUi.isLoadingChildrenFor(root)) {
    mySelectionChangeAlarm.cancelAllRequests();
    mySelectionChangeAlarm.addRequest(new Runnable() {
      @Override
      public void run() {
        mySelectionChangeAlarm.cancelAllRequests();
        setStructureViewSelection(propertyName);
      }
    }, 500);
    return;
  }

  Stack<DefaultMutableTreeNode> toCheck = ContainerUtilRt.newStack();
  toCheck.push((DefaultMutableTreeNode)root);
  DefaultMutableTreeNode nodeToSelect = null;
  while (!toCheck.isEmpty()) {
    DefaultMutableTreeNode node = toCheck.pop();
    String value = getNodeValue(node);
    if (propertyName.equals(value)) {
      nodeToSelect = node;
      break;
    }
    else {
      for (int i = 0; i < node.getChildCount(); i++) {
        toCheck.push((DefaultMutableTreeNode)node.getChildAt(i));
      }
    }
  }
  if (nodeToSelect != null) {
    TreePath path = new TreePath(nodeToSelect.getPath());
    tree.setSelectionPath(path);
    tree.scrollPathToVisible(path);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:ResourceBundleEditor.java


注:本文中的com.intellij.util.containers.ContainerUtilRt.newStack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。