Java Code Examples for com.intellij.psi.PsiElement

The following are top voted examples for showing how to use com.intellij.psi.PsiElement. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: TS-IJ   File: TSMethodCallCompletionContributor.java   View source code 7 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement caller = parameters.getPosition().getPrevSibling().getPrevSibling();
    String ns = TSUtil.getElementNamespace(caller);

    //All global functions
    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() == TSFunctionType.GLOBAL)
            continue;

        result.addElement(
                LookupElementBuilder.create(function.getFunctionName())
                        .withCaseSensitivity(false)
                        .withPresentableText(function.getNamespace() + "." + function.getFunctionName())
                        .withBoldness(ns != null && function.getNamespace().equalsIgnoreCase(ns))
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
Example 2
Project: yii2support   File: CompletionContributor.java   View source code 7 votes vote down vote up
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
    MethodReference reference = PsiTreeUtil.getParentOfType(position, MethodReference.class);
    if (reference != null && ArrayUtil.contains(reference.getName(), ViewsUtil.renderMethods)) {
        if (typeChar == '\'' || typeChar == '"') {
            if (position instanceof LeafPsiElement && position.getText().equals("$view")) {
                return true;
            }
            if (position.getNextSibling() instanceof ParameterList) {
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Project: ReactPropTypes-Plugin   File: CommonAction.java   View source code 7 votes vote down vote up
@NotNull
private List<PropTypeBean>  findPropsNameListWithIdentityReference(String identity, PsiElement psiElement){
  return PsiTreeUtil.findChildrenOfType(psiElement, LeafPsiElement.class)
          .stream()
          .filter(o -> o.getText().equals(identity))
          .filter(o -> o.getElementType().toString().equals("JS:IDENTIFIER"))
          .filter(o -> {
            if(o.getParent() instanceof JSReferenceExpressionImpl){
              JSReferenceExpressionImpl parent = (JSReferenceExpressionImpl) o.getParent();
              if(parent.getTreeNext()!=null && parent.getTreeNext().getElementType().toString().equals("JS:DOT")
                      &&parent.getTreeNext().getTreeNext()!=null){
                return true;
              }
            }
            return  false;
          })
          .map(o -> ((JSReferenceExpressionImpl)o.getParent()).getTreeNext().getTreeNext().getText())
          .distinct()
          .map(o -> new PropTypeBean(o,"any", false))
          .collect(Collectors.toList());
}
 
Example 4
Project: educational-plugin   File: StudyUtils.java   View source code 6 votes vote down vote up
public static void createFromTemplate(@NotNull Project project,
                                      @NotNull PsiDirectory taskDirectory,
                                      @NotNull String name,
                                      @Nullable IdeView view,
                                      boolean open) {
  FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate(name);
  if (template == null) {
    LOG.info("Template " + name + " wasn't found");
    return;
  }
  try {
    final PsiElement file = FileTemplateUtil.createFromTemplate(template, name, null, taskDirectory);
    if (view != null && open) {
      EditorHelper.openInEditor(file, false);
      view.selectElement(file);
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
 
Example 5
Project: manifold-ij   File: ExtensionClassAnnotator.java   View source code 6 votes vote down vote up
@Override
public void annotate( PsiElement element, AnnotationHolder holder )
{
  if( DumbService.getInstance( element.getProject() ).isDumb() )
  {
    // skip processing during index rebuild
    return;
  }

  PsiClass psiExtensionClass = findExtensionClass( element );

  if( psiExtensionClass != null )
  {
    // The enclosing class a @Extension class, verify usage of @This etc.

    verifyPackage( element, holder );
    verifyExtensionInterfaces( element, holder );
    verifyExtensionMethods( element, holder );
  }
  else
  {
    // The enclosing class is *not* an extension class; usage of @This or @Extension on methods are errors

    errrantThisOrExtension( element, holder );
  }
}
 
Example 6
Project: manifold-ij   File: RenameResourceElementProcessor.java   View source code 6 votes vote down vote up
static Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> findJavaUsages( PsiElement element, List<PsiElement> javaElems )
{
  if( !(element instanceof PsiNamedElement) || javaElems.isEmpty() )
  {
    return Collections.emptyMap();
  }

  Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> allUsages = new HashMap<>();
  for( PsiElement javaElem : javaElems )
  {
    if( javaElem == null )
    {
      continue;
    }

    List<UsageInfo> usages = findUsages( javaElem, element );
    if( !usages.isEmpty() )
    {
      FeaturePath path = javaElem.getUserData( KEY_FEATURE_PATH );
      allUsages.put( new Pair<>( path, javaElem ), usages );
    }
  }

  return allUsages;
}
 
Example 7
Project: idea-php-dotenv-plugin   File: DuplicateKeyInspection.java   View source code 6 votes vote down vote up
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
    DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor();
    file.acceptChildren(visitor);

    ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);

    Map<String, PsiElement> existingKeys = new HashMap<>();
    Set<PsiElement> markedElements = new HashSet<>();
    for(KeyValuePsiElement keyValue : visitor.getCollectedItems()) {
        if(existingKeys.containsKey(keyValue.getKey())) {
            problemsHolder.registerProblem(keyValue.getElement(), "Duplicate key");

            PsiElement markedElement = existingKeys.get(keyValue.getKey());
            if(!markedElements.contains(markedElement)) {
                problemsHolder.registerProblem(markedElement, "Duplicate key");
                markedElements.add(markedElement);
            }
        } else {
            existingKeys.put(keyValue.getKey(), keyValue.getElement());
        }
    }

    return problemsHolder;
}
 
Example 8
Project: manifold-ij   File: ExtensionClassAnnotator.java   View source code 6 votes vote down vote up
private void errrantThisOrExtension( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiModifierList )
  {
    PsiModifierList mods = (PsiModifierList)element;
    PsiAnnotation annotation;
    if( (annotation = mods.findAnnotation( Extension.class.getName() )) != null ||
        (annotation = mods.findAnnotation( This.class.getName() )) != null)
    {
      TextRange range = new TextRange( annotation.getTextRange().getStartOffset(),
                                       annotation.getTextRange().getEndOffset() );
      //noinspection ConstantConditions
      holder.createErrorAnnotation( range, ExtIssueMsg.MSG_NOT_IN_EXTENSION_CLASS.get( ClassUtil.extractClassName( annotation.getQualifiedName() ) ) );
    }
  }
}
 
Example 9
Project: reasonml-idea-plugin   File: DescriptionProvider.java   View source code 6 votes vote down vote up
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    if (location == UsageViewNodeTextLocation.INSTANCE && element instanceof PsiNamedElement) {
        return getElementDescription(element, UsageViewShortNameLocation.INSTANCE);
    }

    if (location == UsageViewShortNameLocation.INSTANCE || location == UsageViewLongNameLocation.INSTANCE) {
        if (element instanceof PsiNamedElement) {
            return ((PsiNamedElement) element).getName();
        }
    }

    if (location == UsageViewTypeLocation.INSTANCE) {
        if (element instanceof PsiModuleName) {
            return "module";
        } else if (element instanceof PsiTypeName) {
            return "type";
        } else if (element instanceof PsiVarName) {
            return "let";
        }
    }

    return element.toString();
}
 
Example 10
Project: EmojiPrefix   File: EmojiResourceCompletionContributor.java   View source code 6 votes vote down vote up
public EmojiResourceCompletionContributor() {
	extend(CompletionType.BASIC, PlatformPatterns.psiElement(PsiElement.class), new CompletionProvider<CompletionParameters>() {
		@Override
		protected void addCompletions(@NotNull CompletionParameters completionParameters,
									  ProcessingContext processingContext,
									  @NotNull CompletionResultSet completionResultSet) {
			Document document = completionParameters.getEditor().getDocument();
			int lineStart = document.getLineStartOffset(document.getLineNumber(completionParameters.getOffset()));
			String lineText = document.getText(new TextRange(lineStart, completionParameters.getOffset()));
			if (includeCount(lineText) == 1) {
				for (Map.Entry<String, Icon> iconEntry : EmojiUtil.getEmojiMap().entrySet()) {
					completionResultSet.addElement(LookupElementBuilder.create(iconEntry.getKey(), ":" + iconEntry.getKey() + ":")
							.withIcon(iconEntry.getValue())
							.withInsertHandler((insertionContext, lookupElement) -> {
								int startOffset = insertionContext.getStartOffset();
								Document insertDocument = insertionContext.getDocument();
								if (startOffset > 0 && insertDocument.getCharsSequence().charAt(startOffset - 1) == ':') {
									insertDocument.deleteString(startOffset - 1, startOffset);
								}
							}));
				}
			}
		}
	});
}
 
Example 11
Project: yii2support   File: PsiUtil.java   View source code 6 votes vote down vote up
public static void deleteFunctionParam(PsiElement element) {
    PsiElement next = element.getNextSibling();
    if (next != null && next.getText().equals(",")) {
        next.delete();
    } else {
        PsiElement prev = element.getPrevSibling();
        if (prev != null && prev instanceof PsiWhiteSpace) {
            prev.delete();
            prev = element.getPrevSibling();
        }
        if (prev != null && prev.getText().equals(",")) {
            prev.delete();
        }
    }
    element.delete();
}
 
Example 12
Project: hybris-integration-intellij-idea-plugin   File: ImpexHeaderItemTypeAttributeNameCompletionProvider.java   View source code 6 votes vote down vote up
@Override
public void addCompletions(
    @NotNull final CompletionParameters parameters,
    final ProcessingContext context,
    @NotNull final CompletionResultSet result
) {
    Validate.notNull(parameters);
    Validate.notNull(result);

    final Project project = this.getProject(parameters);
    if (null == project) {
        return;
    }

    final PsiElement psiElementUnderCaret = parameters.getPosition();
    final ImpexHeaderTypeName headerTypeName = this.getHeaderTypeNamePsiElementOfAttribute(psiElementUnderCaret);

    if (headerTypeName != null) {
        fillDomAttributesCompletions(project, headerTypeName, result);
    }
}
 
Example 13
Project: intellij-spring-assistant   File: PropertiesDocumentationProvider.java   View source code 6 votes vote down vote up
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
  if (element instanceof DocumentationProxyElement) {
    DocumentationProxyElement proxyElement = DocumentationProxyElement.class.cast(element);
    MetadataNode target = proxyElement.target;
    boolean requestedForTargetValue = proxyElement.requestedForTargetValue;
    String value = proxyElement.value;

    // Only group & leaf are expected to have documentation
    if (target != null && (target.isGroup() || target.isLeaf())) {
      if (requestedForTargetValue) {
        assert target.getProperty() != null;
        return target.getProperty().getDocumentationForValue(target, value);
      } else if (target.isGroup()) {
        assert target.getGroup() != null;
        return target.getGroup().getDocumentation(target);
      } else {
        assert target.getProperty() != null;
        return target.getProperty().getDocumentationForKey(target);
      }
    }
  }
  return super.generateDoc(element, originalElement);
}
 
Example 14
Project: idea-php-behat-plugin   File: BehatLightCodeInsightFixtureTestCase.java   View source code 6 votes vote down vote up
public void assertLineMarker(@NotNull PsiElement psiElement, @NotNull LineMarker.Assert assertMatch) {

        final List<PsiElement> elements = collectPsiElementsRecursive(psiElement);

        for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.INSTANCE.allForLanguage(psiElement.getLanguage())) {
            Collection<LineMarkerInfo> lineMarkerInfos = new ArrayList<LineMarkerInfo>();
            lineMarkerProvider.collectSlowLineMarkers(elements, lineMarkerInfos);

            if(lineMarkerInfos.size() == 0) {
                continue;
            }

            for (LineMarkerInfo lineMarkerInfo : lineMarkerInfos) {
                if(assertMatch.match(lineMarkerInfo)) {
                    return;
                }
            }
        }

        fail(String.format("Fail that '%s' matches on of '%s' PsiElements", assertMatch.getClass(), elements.size()));
    }
 
Example 15
Project: bamboo-soy   File: SoyDocumentationProviderTest.java   View source code 5 votes vote down vote up
private void doTest(String expectedQuickNavigateInfo) {
  String filename = getTestName(false) + ".soy";
  myFixture.configureByFile(filename);
  PsiElement element = myFixture.getElementAtCaret();
  String info = (new SoyDocumentationProvider()).getQuickNavigateInfo(element, null);
  assertEquals(expectedQuickNavigateInfo, info);
}
 
Example 16
Project: educational-plugin   File: StudyMoveDelegate.java   View source code 5 votes vote down vote up
@Override
public boolean canMove(PsiElement[] elements, @Nullable PsiElement targetContainer) {
  if (elements.length == 1) {
    Project project = elements[0].getProject();
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null || !EduNames.STUDY.equals(course.getCourseMode())) {
      return false;
    }
    return !StudyUtils.isRenameableOrMoveable(project, course, elements[0]);
  }
  return false;
}
 
Example 17
Project: reasonml-idea-plugin   File: ModulePath.java   View source code 5 votes vote down vote up
public ModulePath(List<PsiElement> elements) {
    m_names = new String[elements.size()];
    for (int i = 0; i < elements.size(); i++) {
        PsiElement element = elements.get(i);
        m_names[i] = element instanceof FileBase ? ((FileBase) element).asModuleName() : ((PsiNamedElement) element).getName();
    }
}
 
Example 18
Project: jgiven-intellij-plugin   File: MyLineMarkerInfo.java   View source code 5 votes vote down vote up
@Override
public boolean canMergeWith(@NotNull MergeableLineMarkerInfo<?> info) {
    if (!(info instanceof MyLineMarkerInfo)) return false;
    PsiElement otherElement = info.getElement();
    PsiElement myElement = getElement();
    return otherElement != null && myElement != null;
}
 
Example 19
Project: yii2support   File: CompletionProvider.java   View source code 5 votes vote down vote up
@NotNull
private String getValue(PsiElement expression) {
    if (expression instanceof StringLiteralExpression) {
        String value = ((StringLiteralExpression) expression).getContents();
        return value.substring(0, value.indexOf("IntellijIdeaRulezzz "));
    }

    return "";
}
 
Example 20
Project: yii2support   File: ViewsUtil.java   View source code 5 votes vote down vote up
public static PsiDirectory getRootDirectory(PsiElement element) {
    final PsiFile file = element.getContainingFile();

    if (file.getUserData(VIEWS_DIRECTORY) != null) {
        Long modified = file.getUserData(VIEWS_DIRECTORY_MODIFIED);
        if (modified != null && modified == file.getModificationStamp()) {
            return file.getUserData(VIEWS_DIRECTORY);
        }
    }

    return findDirectory(element);
}
 
Example 21
Project: educational-plugin   File: CCTaskMoveHandlerDelegate.java   View source code 5 votes vote down vote up
@Override
public boolean tryToMove(PsiElement element,
                         Project project,
                         DataContext dataContext,
                         @Nullable PsiReference reference,
                         Editor editor) {
  return CCUtils.isCourseCreator(project);
}
 
Example 22
Project: manifold-ij   File: RenameResourceElementProcessor.java   View source code 5 votes vote down vote up
@Nullable
@Override
public PsiElement substituteElementToRename( PsiElement elem, @Nullable Editor editor )
{
  PsiElement[] element = new PsiElement[]{elem};
  findJavaElements( element );
  return element[0];
}
 
Example 23
Project: hybris-integration-intellij-idea-plugin   File: ImpexColumnBreadcrumbsProvider.java   View source code 5 votes vote down vote up
private static PsiElement adjustWhiteSpaceAndSeparator(PsiElement psi) {
    if (psi instanceof PsiWhiteSpace) {
        //white space should be adjusted to left
        PsiElement prev = PsiTreeUtil.skipSiblingsBackward(psi, PsiWhiteSpace.class);
        if (prev != null) {
            psi = prev;
        }
    } else if (psi.getNode().getElementType() == ImpexTypes.PARAMETERS_SEPARATOR && psi.getNextSibling() != null) {
        //separator is always belongs to the *next* parameter, so adjusting to right
        psi = psi.getNextSibling();
    }
    return psi;
}
 
Example 24
Project: TS-IJ   File: TSPsiImplUtil.java   View source code 5 votes vote down vote up
public static PsiElement getNameNode(TSCallExpr call) {
    PsiElement nameElement = null;

    if (call.isParentCall()) {
        //Third
        nameElement = call.getFirstChild();
        if (nameElement != null) {
            nameElement = nameElement.getNextSibling();
        }
        if (nameElement != null) {
            nameElement = nameElement.getNextSibling();
        }
    } else {
        if (call.getFunctionType() == TSFunctionType.GLOBAL) {
            //First element is the function name
            nameElement = call.getFirstChild();
        } else {
            //Third
            nameElement = call.getFirstChild();
            if (nameElement != null) {
                nameElement = nameElement.getNextSibling();
            }
            if (nameElement != null) {
                nameElement = nameElement.getNextSibling();
            }
        }
    }
    if (nameElement == null) {
        return null;
    }
    return nameElement;
}
 
Example 25
Project: laravel-insight   File: PsiElementUtilTest.java   View source code 5 votes vote down vote up
@NotNull
private static PsiElement getStringLiteral(
    @NotNull final PsiElement fileSample,
    final String variableName
) {
    return valueOf((PhpExpression) ((AssignmentExpression) getElementByName(fileSample, variableName).getParent()).getValue());
}
 
Example 26
Project: yii2support   File: ActiveFormCompletionContributor.java   View source code 5 votes vote down vote up
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
    if ((typeChar == '\'' || typeChar == '"') && position.getParent() instanceof MethodReference) {
        return true;
    }

    return false;
}
 
Example 27
Project: yii2support   File: FieldAttributesCompletionProvider.java   View source code 5 votes vote down vote up
@Override

    protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
        MethodReference methodRef = ClassUtils.getMethodRef(completionParameters.getPosition(), 10);
        PsiElement position = completionParameters.getPosition();
        if (methodRef != null) {
            Method method = (Method) methodRef.resolve();
            int paramPosition = ClassUtils.indexForElementInParameterList(completionParameters.getPosition());
            // attribute plus model parameters
            if (method != null && paramPosition > 0 && method.getParameters().length > paramPosition) {
                if (method.getParameters()[paramPosition].getName().equals("attribute") &&
                        method.getParameters()[paramPosition - 1].getName().equals("model")) {
                    PsiElement element = methodRef.getParameters()[paramPosition - 1];
                    if (element instanceof Variable) {
                        PhpClass classByVariable = ClassUtils.getClassByVariable((Variable) element);
                        if (classByVariable != null &&
                                ClassUtils.isClassInherit(classByVariable, "yii\\base\\Model", PhpIndex.getInstance(position.getProject()) )) {
                            Collection<Field> classFields = ClassUtils.getClassFields(classByVariable);
                            PhpExpression position2 = (PhpExpression) completionParameters.getPosition().getParent();
                            for (Field field : classFields) {
                                LookupElementBuilder lookupBuilder = buildLookup(field, position2);
                                completionResultSet.addElement(lookupBuilder);
                            }
                        }
                    }

                }
            }
        }
    }
 
Example 28
Project: hybris-integration-intellij-idea-plugin   File: HybrisEnumItemReferenceProvider.java   View source code 5 votes vote down vote up
@Override
@NotNull
public final PsiReference[] getReferencesByElement(
    @NotNull final PsiElement element,
    @NotNull final ProcessingContext context
) {

    final HybrisEnumItemReference reference
        = new HybrisEnumItemReference(element, true);
    final List<PsiReference> results = new ArrayList<>();
    results.add(reference);
    return results.toArray(new PsiReference[results.size()]);
}
 
Example 29
Project: magento2-phpstorm-plugin   File: EventIndex.java   View source code 5 votes vote down vote up
public Collection<PsiElement> getEventElements(final String name, final GlobalSearchScope scope) {
    Collection<PsiElement> result = new ArrayList<>();

    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(EventNameIndex.KEY, name, scope);

    for (VirtualFile virtualFile : virtualFiles) {
        XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(virtualFile);
        Collection<XmlAttributeValue> valueElements = XmlPsiTreeUtil
                .findAttributeValueElements(xmlFile, "event", "name", name);
        result.addAll(valueElements);
    }
    return result;
}
 
Example 30
Project: intellij-postfix-templates   File: CustomPostfixTemplateProvider.java   View source code 5 votes vote down vote up
/**
 * Loads the postfix templates from the given virtual file and returns them.
 *
 * @param vFile virtual templates file
 * @return set of postfix templates
 */
@SuppressWarnings("WeakerAccess")
public Set<PostfixTemplate> loadTemplatesFrom(@NotNull VirtualFile vFile) {
	Set<PostfixTemplate> templates = new OrderedSet<>();

	ApplicationManager.getApplication().runReadAction(() -> {
		Project project = ProjectManager.getInstance().getOpenProjects()[0];

		CptFile cptFile = (CptFile) PsiManager.getInstance(project).findFile(vFile);
		if (cptFile != null) {
			CptTemplate[] cptTemplates = PsiTreeUtil.getChildrenOfType(cptFile, CptTemplate.class);
			if (cptTemplates != null) {
				for (CptTemplate cptTemplate : cptTemplates) {
					for (CptMapping mapping : cptTemplate.getMappings().getMappingList()) {
						StringBuilder sb = new StringBuilder();
						for (PsiElement element : mapping.getReplacement().getChildren()) {
							sb.append(element.getText());
						}

						templates.add(createTemplate(mapping.getMatchingClass(), mapping.getConditionClass(), cptTemplate.getTemplateName(), cptTemplate.getTemplateDescription(), sb.toString()));
					}
				}
			}
		}
	});

	return combineTemplatesWithSameName(templates);
}
 
Example 31
Project: idea-php-dotenv-plugin   File: RubyEnvironmentCallsVisitor.java   View source code 5 votes vote down vote up
@Override
public void visitElement(PsiElement element) {
    if(element instanceof RArrayIndexing) {
        this.visitFunction((RArrayIndexing) element);
    }

    super.visitElement(element);
}
 
Example 32
Project: greycat-idea-plugin   File: GCMUtil.java   View source code 5 votes vote down vote up
public static List<GCMTypeDeclaration> findProperties(Project project, final String key) {
    final List<GCMTypeDeclaration> result = new ArrayList<GCMTypeDeclaration>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, GCMLanguageType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        GCMFile simpleFile = (GCMFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            simpleFile.acceptChildren(new PsiElementVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    if (element instanceof GCMDeclaration) {
                        GCMDeclaration declaration = (GCMDeclaration) element;
                        if (declaration.getClassDeclaration() != null && declaration.getClassDeclaration().getTypeDeclaration() != null) {
                            if (key.equals(declaration.getClassDeclaration().getTypeDeclaration().getName())) {
                                result.add(declaration.getClassDeclaration().getTypeDeclaration());
                            }
                        }
                        if (declaration.getCustomTypeDeclaration() != null && declaration.getCustomTypeDeclaration().getIdent() != null) {
                            if (key.equals(declaration.getCustomTypeDeclaration().getIdent())) {
                                //result.add(declaration.getCustomTypeDeclaration().getIdent().getText());
                            }
                        }
                    }
                    super.visitElement(element);
                }
            });
        }
    }
    return result;
}
 
Example 33
Project: jgiven-intellij-plugin   File: JGivenUseScopeEnlarger.java   View source code 5 votes vote down vote up
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
    return scenarioStateAnnotationProvider.isJGivenScenarioState(element)
            ? GlobalSearchScope.everythingScope(element.getProject())
            : null;
}
 
Example 34
Project: hybris-integration-intellij-idea-plugin   File: ImpexFindUsagesProvider.java   View source code 5 votes vote down vote up
@NotNull
@Override
public String getType(@NotNull final PsiElement element) {
    if (isMacroNameDeclaration(element) || isMacroUsage(element)) {
        return "macros";
    }
    return "unknown";
}
 
Example 35
Project: idea-php-typo3-plugin   File: IconAnnotator.java   View source code 5 votes vote down vote up
private void annotateIcon(PsiElement psiElement, AnnotationHolder annotationHolder, String value) {
    if (IconIndex.getAllAvailableIcons(psiElement.getProject()).contains(value)) {
        annotationHolder.createInfoAnnotation(psiElement, null);
    } else {
        annotationHolder.createWarningAnnotation(psiElement, "Unresolved icon - this may also occur if the icon is defined in your extension, but not in the global icon registry.");
    }
}
 
Example 36
Project: TS-IJ   File: TSPsiImplUtil.java   View source code 5 votes vote down vote up
public static String getFunctionName(TSCallExpr call) {
    PsiElement nameNode = getNameNode(call);
    if (nameNode == null) {
        return null;
    }
    return nameNode.getText();
}
 
Example 37
Project: TS-IJ   File: TSObjectAnnotator.java   View source code 5 votes vote down vote up
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    if (element instanceof TSLiteralExpr) {
        boolean valid = false;
        TSLiteralReference ref = (TSLiteralReference)element.getReference();
        if (ref != null) {
            valid = ref.multiResolve(false).length > 0;
        }

        if (valid) {
            createSuccessAnnotation(element, holder, TSSyntaxHighlighter.OBJECT_NAME);
        }
    }
}
 
Example 38
Project: ReactPropTypes-Plugin   File: PsiElementHelper.java   View source code 5 votes vote down vote up
public static PsiElement getRealFirstChild (ES6Class es6Class){
    PsiElement[] children = es6Class.getChildren();
    if(children.length>2){
       if((children[2] instanceof JSFunction)|| children[2] instanceof JSVarStatementBase){
           return children[2];
       }
    }
    if(children.length>3){
        if((children[3] instanceof JSFunction)|| children[3] instanceof JSVarStatementBase){
            return children[3];
        }
    }
    return null;
}
 
Example 39
Project: intellij-csv-validator   File: CsvUnquoteAllIntentionAction.java   View source code 5 votes vote down vote up
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @Nullable PsiElement element) {
    if (!super.isAvailable(project, editor, element)) {
        return false;
    }
    
    return !CsvIntentionHelper.getAllElements(element.getContainingFile()).stream()
                    .anyMatch(psiElement -> CsvIntentionHelper.getElementType(psiElement) == TokenType.BAD_CHARACTER);
}
 
Example 40
Project: Android_Lint_SRP_Practice_Example   File: PsiClassStructureDetector.java   View source code 5 votes vote down vote up
public void report(String nodeName, String source, PsiElement element) {
    System.out.println();
    System.out.println("Node=" + nodeName);
    System.out.println("NodeImpl=" + element.getClass().getSimpleName());
    System.out.println("Source=>>>" + source + "<<<");
    System.out.println("parent=" + parseParent(element));
    System.out.println("children=" + parseChildren(element));
}