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


Java JSProperty.getName方法代码示例

本文整理汇总了Java中com.intellij.lang.javascript.psi.JSProperty.getName方法的典型用法代码示例。如果您正苦于以下问题:Java JSProperty.getName方法的具体用法?Java JSProperty.getName怎么用?Java JSProperty.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.javascript.psi.JSProperty的用法示例。


在下文中一共展示了JSProperty.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseValue

import com.intellij.lang.javascript.psi.JSProperty; //导入方法依赖的package包/类
@RequiredReadAction
@Override
@SuppressWarnings("unchecked")
public Map parseValue(@NotNull Class type, @NotNull Type genericType, @NotNull PsiElement value) throws JomBadValueExpressionException
{
	if(!(value instanceof JSObjectLiteralExpression))
	{
		throw new JomBadValueExpressionException();
	}

	Pair<Class, Type> valueType = JomCollectionValue.findValueTypeInsideGeneric(genericType, 1); // K, V

	JSProperty[] properties = ((JSObjectLiteralExpression) value).getProperties();

	Map map = new LinkedHashMap(properties.length);

	for(JSProperty property : properties)
	{
		String name = property.getName();
		if(name == null)
		{
			continue;
		}

		try
		{
			Object object = JomValueConverter.convertToObject(valueType.getFirst(), valueType.getSecond(), property.getValue());
			map.put(name, object);
		}
		catch(JomBadValueExpressionException e)
		{
			// we dont interest in bad value
		}
	}

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

示例2: visitJSObjectLiteralExpression

import com.intellij.lang.javascript.psi.JSProperty; //导入方法依赖的package包/类
@Override public void visitJSObjectLiteralExpression(JSObjectLiteralExpression jsObjectLiteralExpression) {
    super.visitJSObjectLiteralExpression(jsObjectLiteralExpression);
    final JSProperty[] properties = jsObjectLiteralExpression.getProperties();
    final boolean[] matched = new boolean[properties.length];
    Arrays.fill(matched, false);
    for (int i = 0; i < properties.length; i++) {
        if (matched[i]) {
            continue;
        }
        final JSProperty property1 = properties[i];
        for (int j = i + 1; j < properties.length; j++) {
            if (matched[j]) {
                continue;
            }
            final JSProperty property2 = properties[j];
            final String property1Name = property1.getName();
            final String property2Name = property2.getName();
            if(property1Name !=null && property2Name!=null &&
                    property1Name.equals(property2Name))
            {
                registerError(property2.getFirstChild());
                if (!matched[i]) {
                    registerError(property1.getFirstChild());
                }
                matched[i] = true;
                matched[j] = true;
            }
        }
    }

}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:32,代码来源:DuplicatePropertyOnObjectJSInspection.java

示例3: findTemplateFromDeclare

import com.intellij.lang.javascript.psi.JSProperty; //导入方法依赖的package包/类
@Nullable
public PsiFile findTemplateFromDeclare(@Nullable DeclareStatementItems statement)
{
    if(statement == null)
    {
        return null;
    }

    for(JSProperty property : statement.getMethodsToConvert())
    {
        // just continue if this property is invalid for some reason
        if(property == null || property.getName() == null || property.getValue() == null)
        {
            continue;
        }

        /**
         * have to account for these scenarios
         * templateString: <reference to an imported template>
         * templateString: 'inline template'
         * templateString: 'inline template ' +
         *                  ' spanning multiple lines '
         */
        if(property.getName().equals("templateString"))
        {
            String template = property.getValue().getText();

            if(property.getValue() instanceof JSLiteralExpression || property.getValue() instanceof JSBinaryExpression)
            {
                return property.getContainingFile();
            }
            else
            {
                // find the parameter and define that matches the template parameter
                PsiElement relevantDefine = AMDPsiUtil.getDefineForVariable(file, template);

                if(relevantDefine == null)
                {
                    // we couldn't find the module that templateString reference for whatever reason
                    // (it could be an invalid reference to a module)
                    return null;
                }

                String templatePath = relevantDefine.getText().substring(relevantDefine.getText().lastIndexOf('!') + 1);
                // now open the file and find the reference in it
                VirtualFile htmlFile = SourcesLocator.getAMDImportFile(relevantDefine.getProject(), templatePath, relevantDefine.getContainingFile().getContainingDirectory());

                // if we can't resolve it return null for now TODO
                if(htmlFile == null)
                {
                    return null;
                }

                PsiFile templateFile = PsiManager.getInstance(file.getProject()).findFile(htmlFile);
                return templateFile;
            }
        }
    }

    return null;
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:62,代码来源:TemplatedWidgetUtil.java

示例4: findPropertyDescriptorImpl

import com.intellij.lang.javascript.psi.JSProperty; //导入方法依赖的package包/类
@Nullable
@RequiredReadAction
private static JsonPropertyDescriptor findPropertyDescriptorImpl(@NotNull JSProperty jsProperty)
{
	JsonObjectDescriptor rootDescriptor = JsonFileDescriptorProviders.getRootDescriptor(jsProperty.getContainingFile());
	if(rootDescriptor == null)
	{
		return null;
	}

	Collection<JSProperty> jsProperties = buildPropertiesAsTree(jsProperty, rootDescriptor);
	if(jsProperties.isEmpty())
	{
		return null;
	}

	JsonPropertyDescriptor currentProperty = null;
	JsonObjectDescriptor currentObject = rootDescriptor;
	for(JSProperty property : jsProperties)
	{
		String name = property.getName();
		if(name == null)
		{
			return null;
		}

		currentProperty = currentObject.getProperty(name);
		if(currentProperty == null)
		{
			return null;
		}

		Object value = currentProperty.getValue();
		if(value instanceof JsonObjectDescriptor)
		{
			currentObject = (JsonObjectDescriptor) value;
		}
		else if(value instanceof NativeArray)
		{
			Object componentType = ((NativeArray) value).getComponentType();
			if(componentType instanceof JsonObjectDescriptor)
			{
				currentObject = (JsonObjectDescriptor) componentType;
			}
		}
		else
		{
			break;
		}
	}

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


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