Java Code Examples for com.intellij.lang.javascript.JSTokenTypes#IDENTIFIER

The following examples show how to use com.intellij.lang.javascript.JSTokenTypes#IDENTIFIER . 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: DojoUnresolvedVariableInspection.java    From needsmoredojo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSuppressedFor(@NotNull PsiElement element) {
    Project project = element.getProject();
    DojoSettings settings = ServiceManager.getService(project, DojoSettings.class);
    if(!settings.isNeedsMoreDojoEnabled())
    {
        return super.isSuppressedFor(element);
    }

    if(element instanceof LeafPsiElement)
    {
        LeafPsiElement leafPsiElement = (LeafPsiElement) element;
        if(leafPsiElement.getElementType() == JSTokenTypes.IDENTIFIER &&
                leafPsiElement.getParent() != null &&
                leafPsiElement.getParent().getFirstChild() instanceof JSThisExpression)
        {
            return AttachPointResolver.getGotoDeclarationTargets(element, 0, null).length > 0 || super.isSuppressedFor(element);
        }
    }
    return super.isSuppressedFor(element);
}
 
Example 2
Source File: UnityScriptEventFunctionLineMarkerProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@Nonnull PsiElement element)
{
	if(element.getNode().getElementType() == JSTokenTypes.IDENTIFIER && element.getParent() instanceof JSReferenceExpression && element.getParent().getParent() instanceof JSFunction)
	{
		UnityFunctionManager functionManager = UnityFunctionManager.getInstance();
		Map<String, UnityFunctionManager.FunctionInfo> map = functionManager.getFunctionsByType().get(Unity3dTypes.UnityEngine.MonoBehaviour);
		if(map == null)
		{
			return null;
		}
		UnityFunctionManager.FunctionInfo functionInfo = map.get(element.getText());
		if(functionInfo == null)
		{
			return null;
		}
		Unity3dModuleExtension extension = ModuleUtilCore.getExtension(element, Unity3dModuleExtension.class);
		if(extension == null)
		{
			return null;
		}
		JSFunction jsFunction = (JSFunction) element.getParent().getParent();
		if(jsFunction.getParent() instanceof JSFile)
		{
			if(!isEqualParameters(functionInfo.getParameters(), jsFunction))
			{
				return null;
			}

			return new LineMarkerInfo<>(element, element.getTextRange(), Unity3dIcons.EventMethod, Pass.LINE_MARKERS, new ConstantFunction<>(functionInfo.getDescription()), null,
					GutterIconRenderer.Alignment.LEFT);
		}
	}
	return null;
}
 
Example 3
Source File: RequirejsProjectComponent.java    From WebStormRequireJsPlugin with MIT License 5 votes vote down vote up
public void parseMainJsFile(TreeElement node) {

        TreeElement firstChild = node.getFirstChildNode();
        if (firstChild != null) {
            parseMainJsFile(firstChild);
        }

        TreeElement nextNode = node.getTreeNext();
        if (nextNode != null) {
            parseMainJsFile(nextNode);
        }

        if (node.getElementType() == JSTokenTypes.IDENTIFIER) {
            if (node.getText().equals("requirejs") || node.getText().equals("require")) {
                TreeElement treeParent = node.getTreeParent();

                if (null != treeParent) {
                    ASTNode firstTreeChild = treeParent.findChildByType(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
                    TreeElement nextTreeElement = treeParent.getTreeNext();
                    if (null != firstTreeChild) {
                        parseRequirejsConfig((TreeElement) firstTreeChild
                            .getFirstChildNode()
                        );
                    } else if (null != nextTreeElement && nextTreeElement.getElementType() == JSTokenTypes.DOT) {
                        nextTreeElement = nextTreeElement.getTreeNext();
                        if (null != nextTreeElement && nextTreeElement.getText().equals("config")) {
                            treeParent = nextTreeElement.getTreeParent();
                            findAndParseConfig(treeParent);
                        }
                    } else {
                        findAndParseConfig(treeParent);
                    }
                }
            }
        }
    }