Java Code Examples for com.intellij.util.ArrayUtil#getLastElement()
The following examples show how to use
com.intellij.util.ArrayUtil#getLastElement() .
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: CS0231.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction @Nullable @Override public HighlightInfoFactory checkImpl(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull DotNetParameter dotNetParameter) { if(!dotNetParameter.hasModifier(CSharpModifier.PARAMS)) { return null; } DotNetParameterList parent = (DotNetParameterList) dotNetParameter.getParent(); DotNetParameter[] parameters = parent.getParameters(); if(ArrayUtil.getLastElement(parameters) != dotNetParameter) { return newBuilder(dotNetParameter); } return null; }
Example 2
Source File: UsageNodeTreeBuilderTest.java From consulo with Apache License 2.0 | 6 votes |
public void testFilesWithTheSameNameButDifferentPathsEndUpInDifferentGroups() throws IOException { File ioDir = FileUtil.createTempDirectory("t", null, false); VirtualFile dir = null; try { dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioDir); PsiFile f1 = getPsiManager().findFile(VfsTestUtil.createFile(dir, "/x/X.java", "class X{}")); PsiFile f2 = getPsiManager().findFile(VfsTestUtil.createFile(dir, "/y/X.java", "class X{}")); PsiElement class1 = ArrayUtil.getLastElement(f1.getChildren()); PsiElement class2 = ArrayUtil.getLastElement(f2.getChildren()); FileGroupingRule fileGroupingRule = new FileGroupingRule(getProject()); UsageGroup group1 = fileGroupingRule.getParentGroupFor(new UsageInfo2UsageAdapter(new UsageInfo(class1)), UsageTarget.EMPTY_ARRAY); UsageGroup group2 = fileGroupingRule.getParentGroupFor(new UsageInfo2UsageAdapter(new UsageInfo(class2)), UsageTarget.EMPTY_ARRAY); int compareTo = group1.compareTo(group2); assertTrue(String.valueOf(compareTo), compareTo < 0); } finally { if (dir != null) { VfsTestUtil.deleteFile(dir); } FileUtil.delete(ioDir); } }
Example 3
Source File: MethodParameterResolveContext.java From consulo-csharp with Apache License 2.0 | 5 votes |
public MethodParameterResolveContext(DotNetParameterListOwner parameterListOwner, PsiElement scope, boolean resolveFromParent) { myScope = scope; myResolveFromParent = resolveFromParent; myParameters = parameterListOwner.getParameters(); myParamsParameter = ArrayUtil.getLastElement(myParameters); if(myParamsParameter != null && !myParamsParameter.hasModifier(CSharpModifier.PARAMS)) { myParamsParameter = null; } myInnerParamsParameterTypeRefValue = NotNullLazyValue.createValue(() -> myParamsParameter == null ? DotNetTypeRef.ERROR_TYPE : CSharpResolveUtil.resolveIterableType(myScope, getParamsParameterTypeRef())); myParamsParameterTypeRefValue = NotNullLazyValue.createValue(() -> myParamsParameter == null ? DotNetTypeRef.ERROR_TYPE : myParamsParameter.toTypeRef(true)); }
Example 4
Source File: AddUsingUtil.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction private static PsiElement getElementForBeforeAdd(@Nonnull PsiFile file) { if(file instanceof CSharpFile) { CSharpUsingListChild[] usingStatements = ((CSharpFile) file).getUsingStatements(); if(usingStatements.length > 0) { return ArrayUtil.getLastElement(usingStatements); } } return file; }
Example 5
Source File: MessageBusImpl.java From consulo with Apache License 2.0 | 5 votes |
/** * calculates {@link #myOrder} for the given child bus */ @Nonnull private int[] nextOrder() { MessageBusImpl lastChild = ContainerUtil.getLastItem(myChildBuses); int lastChildIndex = lastChild == null ? 0 : ArrayUtil.getLastElement(lastChild.myOrder, 0); if (lastChildIndex == Integer.MAX_VALUE) { LOG.error("Too many child buses"); } return ArrayUtil.append(myOrder, lastChildIndex + 1); }
Example 6
Source File: MuleElementDefinitionService.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
@NotNull private List<MuleModuleDefinition> getModuleDefinitions(Project project, GlobalSearchScope searchScope) { final List<MuleModuleDefinition> result = new ArrayList<>(); final Collection<VirtualFile> files = FileTypeIndex.getFiles(XmlFileType.INSTANCE, searchScope); for (VirtualFile file : files) { final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file); if (xmlFile != null && isMuleSchema(xmlFile)) { // System.out.println("xmlFile = " + xmlFile.getName()); final PsiElement[] children = xmlFile.getChildren(); final XmlTag rootTag = ((XmlDocument) children[0]).getRootTag(); if (rootTag != null) { final String namespace = getNamespace(rootTag); final String name = ArrayUtil.getLastElement(namespace.split("/")); // System.out.println("namespace = " + namespace); // System.out.println("name = " + name); final XmlTag[] elements = rootTag.findSubTags("element", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA); final List<MuleElementDefinition> definitions = new ArrayList<>(); for (XmlTag element : elements) { final String elementName = element.getAttributeValue("name"); // System.out.println("name = " + elementName); final MuleElementType muleElementType = MuleSchemaUtils.getMuleElementTypeFromElement(element); if (muleElementType != null) { String description = ""; final XmlTag annotation = ArrayUtil.getFirstElement(element.findSubTags("annotation", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA)); if (annotation != null) { final XmlTag documentation = ArrayUtil.getFirstElement(annotation.findSubTags("documentation", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA)); if (documentation != null) { description = documentation.getValue().getText(); } } definitions.add(new MuleElementDefinition(element, elementName, description, muleElementType)); // System.out.println("muleElementType = " + muleElementType); // System.out.println("description = " + description); } } result.add(new MuleModuleDefinition(name, StringUtil.capitalize(name), namespace, xmlFile, definitions)); } } } return result; }
Example 7
Source File: CreateUnresolvedElementFix.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Nonnull public PsiElement getElementForAfterAdd(@Nonnull DotNetNamedElement[] elements, @Nonnull CSharpBodyWithBraces targetForGenerate) { return ArrayUtil.getLastElement(elements); }