本文整理汇总了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();
}
示例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();
}
示例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);
}
}
}
}
示例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);
}
}