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


Java JSParameter类代码示例

本文整理汇总了Java中com.intellij.lang.javascript.psi.JSParameter的典型用法代码示例。如果您正苦于以下问题:Java JSParameter类的具体用法?Java JSParameter怎么用?Java JSParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JSParameter类属于com.intellij.lang.javascript.psi包,在下文中一共展示了JSParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEqualParameters

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
private static boolean isEqualParameters(Map<String, String> funcParameters, JSFunction function)
{
	JSParameter[] parameters = function.getParameterList().getParameters();
	if(parameters.length == 0)
	{
		return true;
	}
	if(parameters.length != funcParameters.size())
	{
		return false;
	}

	/*int i = 0;
	for(DotNetTypeRef expectedTypeRef : funcParameters.values())
	{
		JSParameter parameter = parameters[i++];

		if(!CSharpTypeUtil.isTypeEqual(parameter.toTypeRef(true), expectedTypeRef, parameter))
		{
			return false;
		}
	}   */
	return true;
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:25,代码来源:UnityScriptEventFunctionLineMarkerProvider.java

示例2: processDeclarations

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
@Override
@RequiredReadAction
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place)
{
	if(lastParent != null && lastParent.getParent() == this)
	{
		final JSParameter[] params = getParameterList().getParameters();
		for(JSParameter param : params)
		{
			if(!processor.execute(param, state))
			{
				return false;
			}
		}

		boolean b = JSResolveUtil.processDeclarationsInScope(this, processor, state, lastParent, place);
		if(b)
		{
			processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
		}
		return b;
	}

	return processor.execute(this, state);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:26,代码来源:JavaScriptLambdaExpressionImpl.java

示例3: updateUI

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
@Override
public void updateUI(final JSFunction p, final ParameterInfoUIContext context)
{
	final JSParameterList parameterList = p.getParameterList();
	final JSParameter[] params = parameterList != null ? parameterList.getParameters() : new JSParameter[0];
	final int currentParameterIndex = context.getCurrentParameterIndex() >= 0 ? context.getCurrentParameterIndex() : params.length;
	final JSParameter parameter = currentParameterIndex < params.length ? params[currentParameterIndex] : null;

	final SignatureInfo signatureInfo = buildSignature(params, false, currentParameterIndex);
	final String name = signatureInfo.text;

	final String currentParameterSignature = parameter != null ? getSignatureForParameter(parameter, false) : null;
	int highlightStart = parameter != null ? signatureInfo.selectedParameterStart : 0;
	int highlightEnd = parameter != null ? highlightStart + currentParameterSignature.length() : 0;
	context.setupUIComponentPresentation(name, highlightStart, highlightEnd, false, false, false, context.getDefaultParameterColor());
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:17,代码来源:JSParameterInfoHandler.java

示例4: process

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
private static void process(final JSNamedElement node, final ProblemsHolder holder)
{
	if(node.getContainingFile().getLanguage() != JavaScriptSupportLoader.ECMA_SCRIPT_L4)
	{
		return;
	}
	PsiElement nameIdentifier = node.getNameIdentifier();

	if(nameIdentifier != null &&
			JSPsiImplUtils.getTypeFromDeclaration(node) == null &&
			(!(node instanceof JSParameter) || !((JSParameter) node).isRest()))
	{
		holder.registerProblem(nameIdentifier, JavaScriptBundle.message(node instanceof JSFunction ? "js.untyped.function.problem" : "js.untyped" +
				".variable.problem", nameIdentifier.getText()), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AddTypeToDclFix());
	}
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:17,代码来源:JSUntypedDeclarationInspection.java

示例5: visitJSFunctionDeclaration

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
@Override public void visitJSFunctionDeclaration(JSFunction function) {
    super.visitJSFunctionDeclaration(function);
    final JSParameterList parameterList = function.getParameterList();
    if (parameterList == null) {
        return;
    }
    final JSParameter[] parameters = parameterList.getParameters();
    for (JSVariable variable : parameters) {
        final String name = variable.getName();
        if (name == null) {
            continue;
        }
        if (isValid(name)) {
            continue;
        }
        registerVariableError(variable);
    }
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:19,代码来源:ParameterNamingConventionJSInspection.java

示例6: checkCatchSection

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
private void checkCatchSection(JSCatchBlock section) {
    final JSParameter param = section.getParameter();
    final JSStatement block = section.getStatement();
    if (param == null || block == null) {
        return;
    }
    @NonNls final String paramName = param.getName();
    if ("ignore".equals(paramName) || "ignored".equals(paramName)) {
        return;
    }
    if (m_ignoreCatchBlocksWithComments) {
        final PsiElement[] children = block.getChildren();
        for (final PsiElement child : children) {
            if (child instanceof PsiComment) {
                return;
            }
        }
    }
    final CatchParameterUsedVisitor visitor =
            new CatchParameterUsedVisitor(param);
    block.accept(visitor);
    if (!visitor.isUsed()) {
        registerVariableError(param);
    }
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:26,代码来源:UnusedCatchParameterJSInspection.java

示例7: doSwap

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
public void doSwap(PsiElement source, Editor editor, AMDPsiUtil.Direction direction)
{
    PsiElement[] defines = getSourceAndDestination(source, direction);

    if(defines == null || defines.length == 0)
    {
        return;
    }

    // get the parameter element
    JSArgumentList list = (JSArgumentList) defines[0].getParent().getParent();
    DefineStatement items = new DefineResolver().getDefineStatementItemsFromArguments(list.getArguments(), null);

    int sourceIndex = PsiUtil.getIndexInParent(defines[0]);
    int destinationIndex = PsiUtil.getIndexInParent(defines[1]);
    JSParameter[] parameterList = items.getFunction().getParameters();

    if(sourceIndex >= parameterList.length || destinationIndex >= parameterList.length)
    {
        // we're moving into a plugin's position
        return;
    }

    PsiElement[] parameters = new PsiElement[] { parameterList[sourceIndex], parameterList[destinationIndex] };

    PsiElement[] elementsWithPositions = reorder(defines[0], defines[1]);
    reorder(parameters[0], parameters[1]);

    editor.getCaretModel().moveToOffset(elementsWithPositions[0].getTextOffset());
    editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:32,代码来源:ImportReorderer.java

示例8: MockJSFunction

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
public MockJSFunction(String[] parameters) {
    super(mock(ASTNode.class));

    this.parameters = new JSParameter[parameters.length];
    for(int i=0;i<parameters.length;i++)
    {
        this.parameters[i] = new MockJSParameter(parameters[i]);
    }
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:10,代码来源:MockJSFunction.java

示例9: MockJSFunctionExpression

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
public MockJSFunctionExpression(String[] parameters)
{
    super(mock(ASTNode.class));

    function = new MockJSFunction(parameters);

    this.parameters = new JSParameter[parameters.length];
    for(int i=0;i<parameters.length;i++)
    {
        this.parameters[i] = new MockJSParameter(parameters[i]);
    }
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:13,代码来源:MockJSFunctionExpression.java

示例10: createStub

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
@RequiredReadAction
@Override
public JSParameterStub createStub(@NotNull JSParameter psi, StubElement parentStub)
{
	String name = psi.getName();
	int flags = JSParameterStubImpl.buildFlags(psi);
	String typeString = psi.getTypeString();
	String initializerText = psi.getInitializerText();
	String qualifiedName = psi.getQualifiedName();
	return new JSParameterStubImpl(name, flags, typeString, initializerText, qualifiedName, parentStub, this);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:12,代码来源:JSParameterElementType.java

示例11: processDeclarations

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent,
		@NotNull PsiElement place)
{
	if(lastParent != null)
	{
		final JSParameter param = getParameter();
		if(param != null)
		{
			return processor.execute(param, state);
		}
	}

	return true;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:JSCatchBlockImpl.java

示例12: buildSignature

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
private static
@NotNull
SignatureInfo buildSignature(final JSParameter[] params, final boolean skipType, int selectedParameterIndex)
{
	SignatureInfo info = new SignatureInfo();
	if(params.length > 0)
	{
		StringBuilder result = new StringBuilder();
		for(int i = 0; i < params.length; ++i)
		{
			if(result.length() > 0)
			{
				result.append(", ");
			}
			if(selectedParameterIndex == i)
			{
				info.selectedParameterStart = result.length();
			}
			result.append(getSignatureForParameter(params[i], skipType));
		}

		info.text = result.toString();
	}
	else
	{
		info.text = CodeInsightBundle.message("parameter.info.no.parameters");
	}
	return info;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:30,代码来源:JSParameterInfoHandler.java

示例13: getSignatureForParameter

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
public static String getSignatureForParameter(final JSParameter p, boolean skipType)
{
	final String s = skipType ? null : p.getTypeString();

	if(s != null && s.length() > 0)
	{
		final boolean ecmal4 = p.getContainingFile().getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4;
		String result;

		if(ecmal4)
		{
			if(p.isRest())
			{
				result = "...";
			}
			else
			{
				result = p.getName() + ":" + s;
			}
		}
		else
		{
			result = "[" + s + "] " + p.getName();
		}
		final String initializerText = p.getInitializerText();
		if(initializerText != null)
		{
			result += " = " + initializerText;
		}
		return result;
	}
	return p.getName();
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:34,代码来源:JSParameterInfoHandler.java

示例14: buildParameterList

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
protected String buildParameterList(final JSParameterList parameterList, final T fun)
{
	if(parameterList != null)
	{
		for(JSParameter param : parameterList.getParameters())
		{
			final String s = param.getTypeString();
			if(s != null)
			{
				importType(s, fun);
			}
		}
	}
	return (parameterList != null ? parameterList.getText() : "()");
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:BaseCreateMethodsFix.java

示例15: visitJSFunctionDeclaration

import com.intellij.lang.javascript.psi.JSParameter; //导入依赖的package包/类
@Override public void visitJSFunctionDeclaration(@NotNull JSFunction function) {
    final JSParameterList parameterList = function.getParameterList();
    if (parameterList == null) {
        return;
    }
    final JSParameter[] parameters = parameterList.getParameters();
    if (parameters == null) {
        return;
    }
    final int numParameters = parameters.length;
    if (numParameters <= getLimit()) {
        return;
    }
    registerFunctionError(function);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:ParametersPerFunctionJSInspection.java


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