本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.ArrayCreationExpression类的典型用法代码示例。如果您正苦于以下问题:Java ArrayCreationExpression类的具体用法?Java ArrayCreationExpression怎么用?Java ArrayCreationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayCreationExpression类属于com.jetbrains.php.lang.psi.elements包,在下文中一共展示了ArrayCreationExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resolve
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Nullable
@Override
public PsiElement resolve() {
PsiElement possibleArrayCreation = myElement.getParent().getParent().getParent();
if (possibleArrayCreation instanceof ArrayCreationExpression) {
ArrayCreationExpression arrayCreation = (ArrayCreationExpression)possibleArrayCreation;
PsiDirectory dir = myElement.getContainingFile().getContainingDirectory();
PhpClass phpClass = ObjectFactoryUtils.findClassByArrayCreation(arrayCreation, dir);
if (phpClass != null) {
PsiElement field = ClassUtils.findWritableField(phpClass, myElement.getText());
return field;
}
}
return null;
}
开发者ID:nvlad,项目名称:yii2support,代码行数:18,代码来源:ObjectFactoryReference.java
示例2: resolve
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Nullable
@Override
public PsiElement resolve() {
BxCore bitrix = new BxCore(getElement().getProject());
String inclusionType = null;
for (ArrayHashElement arElement : ((ArrayCreationExpression) getElement().getParent().getParent().getParent()).getHashElements()) {
if (arElement.getKey() instanceof StringLiteralExpression && ((StringLiteralExpression) arElement.getKey()).getContents().equals("AREA_FILE_SHOW") && arElement.getValue() instanceof StringLiteralExpression)
inclusionType = ((StringLiteralExpression) arElement.getValue()).getContents();
}
if (inclusionType != null) {
VirtualFile componentTemplateFile = bitrix.getPageIncludeFile(
getElement(),
inclusionType.equals("page") ? "index" : "sect"
);
if (componentTemplateFile != null)
return getElement().getManager().findFile(componentTemplateFile);
}
return null;
}
开发者ID:vizh,项目名称:bxfs,代码行数:24,代码来源:BxComponentIncludeReference.java
示例3: isModuleKeyInFlatArray
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
public static boolean isModuleKeyInFlatArray(@NotNull StringLiteralExpression psiElement, @NotNull String key) {
PsiElement arrayKey = psiElement.getParent();
if(arrayKey != null && arrayKey.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashElement = arrayKey.getParent();
if(hashElement instanceof ArrayHashElement) {
PsiElement arrayCreation = hashElement.getParent();
if(arrayCreation instanceof ArrayCreationExpression) {
PsiElement arrayValue = arrayCreation.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashArray = arrayValue.getParent();
if(hashArray instanceof ArrayHashElement) {
PhpPsiElement keyString = ((ArrayHashElement) hashArray).getKey();
if(keyString instanceof StringLiteralExpression) {
String contents = ((StringLiteralExpression) keyString).getContents();
if(key.equals(contents)) {
return true;
}
}
}
}
}
}
}
return false;
}
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:27,代码来源:PhpMetadataUtil.java
示例4: isExtendKey
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
public static boolean isExtendKey(@NotNull StringLiteralExpression parent) {
ArrayCreationExpression arrayCreation = PhpElementsUtil.getCompletableArrayCreationElement(parent);
if(arrayCreation == null) {
return false;
}
PsiElement arrayValue = arrayCreation.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashArray = arrayValue.getParent();
if(hashArray instanceof ArrayHashElement) {
PhpPsiElement key = ((ArrayHashElement) hashArray).getKey();
if(key instanceof StringLiteralExpression && "extend".equals(((StringLiteralExpression) key).getContents())) {
return true;
}
}
}
return false;
}
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:21,代码来源:PhpMetadataUtil.java
示例5: getArrayKeyValueMapProxy
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
/**
* GetArrayKeyValueMap adds null Value; proxy until fixed external
*/
@NotNull
private static Map<String, String> getArrayKeyValueMapProxy(@NotNull ArrayCreationExpression arrayCreationExpression) {
Map<String, String> map = new HashMap<String, String>();
for (Map.Entry<String, String> entry : PhpElementsUtil.getArrayKeyValueMap(arrayCreationExpression).entrySet()) {
String value = entry.getValue();
String key = entry.getKey();
if(key != null && StringUtils.isNotBlank(key) && value != null && StringUtils.isNotBlank(value)) {
map.put(entry.getKey(), entry.getValue());
}
}
return map;
}
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:19,代码来源:MetadataUtil.java
示例6: visitMetadataKey
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
private static void visitMetadataKey(@NotNull PsiFile psiFile, @NotNull String key, @NotNull MetadataKeyVisitor visitor) {
PsiElement childOfType = PsiTreeUtil.getChildOfType(psiFile, GroupStatement.class);
if(childOfType == null) {
return;
}
for (Statement statement : PsiTreeUtil.getChildrenOfTypeAsList(childOfType, Statement.class)) {
PsiElement assignmentExpr = statement.getFirstPsiChild();
if(assignmentExpr instanceof AssignmentExpressionImpl) {
PhpPsiElement variable = ((AssignmentExpressionImpl) assignmentExpr).getVariable();
if(variable != null && "aModule".equals(variable.getName())) {
PhpPsiElement value = ((AssignmentExpressionImpl) assignmentExpr).getValue();
if(value instanceof ArrayCreationExpression) {
PhpPsiElement arrayCreationKeyMap = PhpElementsUtil.getArrayValue((ArrayCreationExpression) value, key);
if(arrayCreationKeyMap instanceof ArrayCreationExpression) {
visitor.visit((ArrayCreationExpression) arrayCreationKeyMap);
}
}
}
}
}
}
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:25,代码来源:MetadataUtil.java
示例7: matches
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Override
public boolean matches(@NotNull LanguageMatcherParameter parameter) {
PsiElement parent = parameter.getElement().getParent();
if(!(parent instanceof StringLiteralExpression)) {
return false;
}
PsiElement arrayValue = parent.getParent();
if(arrayValue == null || arrayValue.getNode().getElementType() != PhpElementTypes.ARRAY_VALUE) {
return false;
}
PsiElement arrayCreation = arrayValue.getParent();
if(!(arrayCreation instanceof ArrayCreationExpression)) {
return false;
}
PsiElement phpReturn = arrayCreation.getParent();
if(!(phpReturn instanceof PhpReturn)) {
return false;
}
return PhpMatcherUtil.isMachingReturnArray(parameter.getSignatures(), phpReturn);
}
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:26,代码来源:ReturnArraySignatureRegistrarMatcher.java
示例8: collectConfigKeys
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
public static void collectConfigKeys(ArrayCreationExpression creationExpression, ArrayKeyVisitor arrayKeyVisitor, List<String> context) {
for(ArrayHashElement hashElement: PsiTreeUtil.getChildrenOfTypeAsList(creationExpression, ArrayHashElement.class)) {
PsiElement arrayKey = hashElement.getKey();
PsiElement arrayValue = hashElement.getValue();
if(arrayKey instanceof StringLiteralExpression) {
List<String> myContext = new ArrayList<>(context);
myContext.add(((StringLiteralExpression) arrayKey).getContents());
String keyName = StringUtils.join(myContext, ".");
if(arrayValue instanceof ArrayCreationExpression) {
arrayKeyVisitor.visit(keyName, arrayKey, true);
collectConfigKeys((ArrayCreationExpression) arrayValue, arrayKeyVisitor, myContext);
} else {
arrayKeyVisitor.visit(keyName, arrayKey, false);
}
}
}
}
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:25,代码来源:ArrayReturnPsiRecursiveVisitor.java
示例9: getArrayParameterDirectiveForElementType
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
/**
* "@foobar(['<caret>'])"
*
* whereas "foobar" is registered a directive
*/
public static PsiElementPattern.Capture<PsiElement> getArrayParameterDirectiveForElementType(@NotNull IElementType... elementType) {
return PlatformPatterns.psiElement()
.withParent(
PlatformPatterns.psiElement(StringLiteralExpression.class)
.withParent(
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE).withParent(
PlatformPatterns.psiElement(ArrayCreationExpression.class)
.withParent(ParameterList.class)
)
)
.with(
new MyDirectiveInjectionElementPatternCondition(elementType)
)
)
.withLanguage(PhpLanguage.INSTANCE);
}
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:22,代码来源:BladePattern.java
示例10: invokeAutoPopup
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
if ((typeChar == '\'' || typeChar == '"') && position.getParent() instanceof ArrayCreationExpression) {
return true;
}
return false;
}
开发者ID:nvlad,项目名称:yii2support,代码行数:9,代码来源:ValidationCompletionContributor.java
示例11: ElementPattern
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
private static ElementPattern<PsiElement> ElementPattern() {
return PlatformPatterns.psiElement()
.withParent(PlatformPatterns.psiElement(StringLiteralExpression.class)
.withParent(PlatformPatterns.or(
PlatformPatterns.psiElement().withParent(ArrayCreationExpression.class),
Patterns.withHashKey()
.withParent(PlatformPatterns.psiElement().withParent(ArrayCreationExpression.class))
)));
}
开发者ID:nvlad,项目名称:yii2support,代码行数:12,代码来源:ValidationCompletionContributor.java
示例12: applyFix
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement item = descriptor.getPsiElement();
PsiElement context = item.getContext();
if (context instanceof ArrayCreationExpression) {
ArrayCreationExpression params = (ArrayCreationExpression) item.getParent();
PsiUtil.deleteArrayElement(item);
if (!params.getHashElements().iterator().hasNext()) {
if (params.getPrevSibling() instanceof PsiWhiteSpace) {
params.getPrevSibling().delete();
}
params.getPrevSibling().delete();
params.delete();
}
}
if (context instanceof ParameterList && context.getParent() instanceof FunctionReference) {
FunctionReference functionReference = (FunctionReference) context.getParent();
if (functionReference.getName() != null && functionReference.getName().equals("compact")) {
PsiUtil.deleteFunctionParam(item);
if (functionReference.getParameters().length == 0) {
PsiUtil.deleteFunctionParam(functionReference);
}
}
}
}
开发者ID:nvlad,项目名称:yii2support,代码行数:30,代码来源:UnusedParameterLocalQuickFix.java
示例13: ElementPattern
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
private static ElementPattern<PsiElement> ElementPattern() {
return PlatformPatterns.psiElement()
.withParent(PlatformPatterns.or(
PlatformPatterns.psiElement().withParent(ArrayCreationExpression.class),
Patterns.withHashKey()
.withParent(PlatformPatterns.psiElement().withParent(ArrayCreationExpression.class))
));
}
开发者ID:nvlad,项目名称:yii2support,代码行数:9,代码来源:ObjectFactoryReferenceContributor.java
示例14: getArrayKeys
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@NotNull
public static Collection<String> getArrayKeys(ArrayCreationExpression array) {
final HashSet<String> result = new HashSet<>();
Iterable<ArrayHashElement> items = array.getHashElements();
for (ArrayHashElement item : items) {
if (item.getKey() != null && item.getKey() instanceof StringLiteralExpression) {
result.add(((StringLiteralExpression) item.getKey()).getContents());
}
}
return result;
}
开发者ID:nvlad,项目名称:yii2support,代码行数:15,代码来源:PhpUtil.java
示例15: deleteArrayElement
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
public static void deleteArrayElement(PsiElement element) {
PsiElement next = element.getNextSibling();
String endArray = ((ArrayCreationExpression) element.getParent()).isShortSyntax() ? "]" : ")";
if (next instanceof PsiWhiteSpace && next.getNextSibling().getText() != null) {
if (next.getNextSibling().getText().equals(endArray)) {
next = next.getNextSibling();
}
}
if (next.getText().equals(endArray)) {
Boolean deleteComma = false;
if (element.getPrevSibling() instanceof PsiWhiteSpace) {
deleteComma = !element.getPrevSibling().getText().contains("\n");
element.getPrevSibling().delete();
}
if (deleteComma && element.getPrevSibling().getText().equals(",")) {
element.getPrevSibling().delete();
}
}
if (next.getText().equals(",")) {
if (next.getNextSibling() instanceof PsiWhiteSpace) {
next.getNextSibling().delete();
}
next.delete();
}
element.delete();
}
开发者ID:nvlad,项目名称:yii2support,代码行数:28,代码来源:PsiUtil.java
示例16: getValueIndexInArray
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
public static int getValueIndexInArray(PsiElement arrayValue, ArrayCreationExpression array) {
for (int i = 0; i < array.getChildren().length; i++) {
if (array.getChildren()[i] == arrayValue) {
return i;
}
}
return -1;
}
开发者ID:nvlad,项目名称:yii2support,代码行数:9,代码来源:PsiUtil.java
示例17: getArrayCreation
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
public static ArrayCreationExpression getArrayCreation(PsiElement element) {
int limit = 10;
PsiElement curElement = element;
while (limit > 0) {
if (curElement instanceof ArrayCreationExpression) {
return (ArrayCreationExpression) curElement;
} else {
curElement = curElement.getParent();
}
limit--;
}
return null;
}
开发者ID:nvlad,项目名称:yii2support,代码行数:14,代码来源:PsiUtil.java
示例18: applyFix
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement expression = descriptor.getPsiElement();
if (null != expression && expression.getParent() instanceof ArrayCreationExpression) {
final ArrayCreationExpression container = (ArrayCreationExpression) expression.getParent();
final PsiElement closingBracket = container.getLastChild();
if (null == closingBracket) {
return;
}
for (String translation : missing) {
/* reach or create a comma */
PsiElement last = closingBracket.getPrevSibling();
if (last instanceof PsiWhiteSpace) {
last = last.getPrevSibling();
}
if (null != last && PhpTokenTypes.opCOMMA != last.getNode().getElementType()) {
last.getParent().addAfter(PhpPsiElementFactory.createComma(project), last);
last = last.getNextSibling();
}
/* add a new translation */
final String escaped = PhpStringUtil.escapeText(translation, true, '\n', '\t');
final String pairPattern = "array('%s%' => '%s%')".replace("%s%", escaped).replace("%s%", escaped);
final ArrayCreationExpression array = PhpPsiElementFactory.createFromText(project, ArrayCreationExpression.class, pairPattern);
final PhpPsiElement pair = null == array ? null : array.getHashElements().iterator().next();
final PsiWhiteSpace space = PhpPsiElementFactory.createFromText(project, PsiWhiteSpace.class, " ");
if (null == last || null == pair || null == space) {
continue;
}
last.getParent().addAfter(pair, last);
last.getParent().addAfter(space, last);
}
}
}
开发者ID:kalessil,项目名称:yii2inspections,代码行数:36,代码来源:MissingTranslationsInspector.java
示例19: visitElement
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Override
public void visitElement(PsiElement element) {
if (PlatformPatterns.psiElement(StringLiteralExpression.class).withParent(
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY).withParent(
PlatformPatterns.psiElement(ArrayHashElement.class).withParent(
PlatformPatterns.psiElement(ArrayCreationExpression.class).withParent(
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE).withParent(
PlatformPatterns.psiElement(ArrayHashElement.class).withFirstChild(
PlatformPatterns.or(
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY).withText("'psr-4'"),
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY).withText("\"psr-4\"")
)
)
)
)
)
)
).accepts(element)) {
if (ns == null) {
ns = new ArrayList<>();
}
String contents = ((StringLiteralExpression) element).getContents();
if (contents.contains("\\")) {
contents = contents.replace("\\\\", "\\");
}
if (contents.endsWith("\\")) {
ns.add(contents);
}
ns.add((contents + "\\"));
}
super.visitElement(element);
}
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:38,代码来源:ExtensionUtility.java
示例20: from
import com.jetbrains.php.lang.psi.elements.ArrayCreationExpression; //导入依赖的package包/类
@Nullable
public static ArrayAdapter from(@Nullable final PhpTypedElement element) {
if (!(element instanceof ArrayCreationExpression)) {
return null;
}
final PhpPsiElement[] arrayElements = PsiTreeUtil.getChildrenOfType((PsiElement) element, PhpPsiElement.class);
if (arrayElements == null) {
return null;
}
return new ArrayAdapter(new ArrayList<>(Arrays.asList(arrayElements)));
}
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:15,代码来源:ArrayAdapter.java
注:本文中的com.jetbrains.php.lang.psi.elements.ArrayCreationExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论