本文整理汇总了Java中com.intellij.lang.javascript.psi.JSProperty.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JSProperty.getValue方法的具体用法?Java JSProperty.getValue怎么用?Java JSProperty.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.javascript.psi.JSProperty
的用法示例。
在下文中一共展示了JSProperty.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleInsert
import com.intellij.lang.javascript.psi.JSProperty; //导入方法依赖的package包/类
@Override
public void handleInsert(InsertionContext context)
{
// Remove the text the user typed.
context
.getDocument()
.deleteString(context.getStartOffset(), context.getTailOffset());
context.commitDocument();
// Grab the deepest property available for insertion... hø hø hø!
JSProperty targetProperty = getTargetProperty(context.getFile());
// Generate the remaining jsNotation.
String quote = JSCodeStyleSettings.getQuote(targetProperty);
String jsNotation = setting.toRelativeJsNotation(targetProperty, quote);
// Create a new file to initiate all lexers, parsers grumpkins and snarks...
PsiFile psiContainer = PsiFileFactory
.getInstance(context.getProject())
.createFileFromText(targetProperty.getLanguage(), jsNotation);
JSExpression value = targetProperty.getValue();
if (value == null)
{
return;
}
PsiElement[] childrenForInsertion = psiContainer.getChildren();
// Insert in reverse order. Probably an easier way, but this works just fine...
ArrayUtils.reverse(childrenForInsertion);
// Grab all created elements in the temporary file and insert them into the document.
for (PsiElement completion : childrenForInsertion)
{
value.addAfter(completion, value.getFirstChild());
}
PsiElement formattedValue = CodeStyleManager
.getInstance(context.getProject())
.reformat(value);
value.replace(formattedValue);
List<LookupElement> subCompletions = setting.getSubCompletionVariants();
// User does not need to edit bools or enums with single value.
if (setting.getType().equals("Boolean") || subCompletions.size() == 1)
{
return;
}
context.commitDocument();
moveCursor(context);
if (subCompletions.size() > 1)
{
AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor());
}
}
示例2: inspectProperty
import com.intellij.lang.javascript.psi.JSProperty; //导入方法依赖的package包/类
private void inspectProperty(JSProperty node)
{
String namespace = node.getQualifiedName();
done.add(namespace);
Setting setting = CompletionPreloader
.getCompletions()
.getSetting(namespace);
JSExpression nodeValue = node.getValue();
if (setting == null || nodeValue == null)
{
return;
}
String value;
// We don't want the quotes included.
try
{
JSLiteralExpression literalExpression = (JSLiteralExpression)nodeValue;
value = (String)literalExpression.getValue();
}
catch (Exception e)
{
value = nodeValue.getText();
}
String defaultValue = setting.getDefaultValue();
if (value == null)
{
return;
}
// Can't get hold of CodeStyleManager here because not dispatch. Manual labor ahead.
List<String> valueCandidates = generateCandidates(value);
List<String> defaultValueCandidates = generateCandidates(defaultValue);
Boolean someSortOfMatch = false;
for (String valueCandidate : valueCandidates)
{
if (defaultValueCandidates.contains(valueCandidate))
{
someSortOfMatch = true;
break;
}
}
if (!someSortOfMatch)
{
return;
}
holder.registerProblem(node, "Value equals default-value", new QuickFix());
}
示例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;
}