diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java index 82130b5d0b54..fa3fef8e0fea 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java @@ -385,6 +385,11 @@ public CodeCompletionResult complete(CodeCompletionContext completionContext) { autoCompleteTypeNames(completionResult, request, null, true); autoCompleteConstants(completionResult, request); autoCompleteKeywords(completionResult, request, PHP_CLASS_CONST_KEYWORDS); + // NETBEANS-1855 + if (!request.prefix.contains("\\")) { // NOI18N + // e.g. const CONSTANT = \^Foo\Bar::CONSTANT; + autoCompleteClassConstants(completionResult, request); + } break; case HTML: case OPEN_TAG: @@ -1155,6 +1160,14 @@ private void autoCompleteClassMembers( final PHPCompletionResult completionResult, PHPCompletionItem.CompletionRequest request, boolean staticContext) { + autoCompleteClassMembers(completionResult, request, staticContext, false); + } + + private void autoCompleteClassMembers( + final PHPCompletionResult completionResult, + PHPCompletionItem.CompletionRequest request, + boolean staticContext, + boolean completeAccessPrefix) { if (CancelSupport.getDefault().isCancelled()) { return; } @@ -1209,13 +1222,23 @@ private void autoCompleteClassMembers( Collection types = ModelUtils.resolveTypeAfterReferenceToken(model, tokenSequence, request.anchor, specialVariable); if (types != null) { TypeElement enclosingType = getEnclosingType(request, types); + if (completeAccessPrefix) { + // NETBEANS-1855 + types = ModelUtils.resolveType(model, request.anchor); + } Set duplicateElementCheck = new HashSet<>(); for (TypeScope typeScope : types) { if (CancelSupport.getDefault().isCancelled()) { return; } - final StaticOrInstanceMembersFilter staticFlagFilter = - new StaticOrInstanceMembersFilter(staticContext, instanceContext, selfContext, staticLateBindingContext); + final ElementFilter staticFlagFilter = !completeAccessPrefix + ? new StaticOrInstanceMembersFilter(staticContext, instanceContext, selfContext, staticLateBindingContext) + : new ElementFilter() { // NETBEANS-1855 + @Override + public boolean isAccepted(PhpElement element) { + return true; + } + }; final ElementFilter methodsFilter = ElementFilter.allOf( ElementFilter.forKind(PhpElementKind.METHOD), @@ -1249,7 +1272,7 @@ private void autoCompleteClassMembers( if (duplicateElementCheck.add(phpElement)) { if (methodsFilter.isAccepted(phpElement)) { MethodElement method = (MethodElement) phpElement; - List items = PHPCompletionItem.MethodElementItem.getItems(method, request); + List items = PHPCompletionItem.MethodElementItem.getItems(method, request, completeAccessPrefix); for (MethodElementItem methodItem : items) { if (CancelSupport.getDefault().isCancelled()) { return; @@ -1258,11 +1281,11 @@ private void autoCompleteClassMembers( } } else if (fieldsFilter.isAccepted(phpElement)) { FieldElement field = (FieldElement) phpElement; - FieldItem fieldItem = PHPCompletionItem.FieldItem.getItem(field, request); + FieldItem fieldItem = PHPCompletionItem.FieldItem.getItem(field, request, false, completeAccessPrefix); completionResult.add(fieldItem); - } else if (staticContext && constantsFilter.isAccepted(phpElement)) { + } else if ((staticContext || completeAccessPrefix) && constantsFilter.isAccepted(phpElement)) { TypeConstantElement constant = (TypeConstantElement) phpElement; - TypeConstantItem constantItem = PHPCompletionItem.TypeConstantItem.getItem(constant, request); + TypeConstantItem constantItem = PHPCompletionItem.TypeConstantItem.getItem(constant, request, completeAccessPrefix); completionResult.add(constantItem); } } @@ -1299,6 +1322,38 @@ private static boolean isDynamicAccess(CharSequence varName) { return false; } + private void autoCompleteClassConstants(final PHPCompletionResult completionResult, final PHPCompletionItem.CompletionRequest request) { + // NETBANS-1855 + // complete access prefix i.e. add "self::" to the top of constant names + if (CancelSupport.getDefault().isCancelled()) { + return; + } + final ElementFilter constantsFilter = ElementFilter.allOf( + ElementFilter.forKind(PhpElementKind.TYPE_CONSTANT), + ElementFilter.forName(NameKind.caseInsensitivePrefix(request.prefix)), + ElementFilter.forInstanceOf(TypeConstantElement.class) + ); + Model model = request.result.getModel(); + Collection types = ModelUtils.resolveType(model, request.anchor); + TypeElement enclosingType = getEnclosingType(request, types); + for (TypeScope typeScope : types) { + if (CancelSupport.getDefault().isCancelled()) { + return; + } + for (final PhpElement phpElement : request.index.getAccessibleTypeMembers(typeScope, enclosingType)) { + if (CancelSupport.getDefault().isCancelled()) { + return; + } + if (constantsFilter.isAccepted(phpElement)) { + TypeConstantElement constant = (TypeConstantElement) phpElement; + TypeConstantItem constantItem = PHPCompletionItem.TypeConstantItem.getItem(constant, request, true); + completionResult.add(constantItem); + } + } + } + + } + private void autoCompleteClassFields(final PHPCompletionResult completionResult, final PHPCompletionItem.CompletionRequest request) { if (CancelSupport.getDefault().isCancelled()) { return; @@ -1331,6 +1386,7 @@ private void autoCompleteClassFields(final PHPCompletionResult completionResult, } } + @CheckForNull private TypeElement getEnclosingType(CompletionRequest request, Collection types) { final EnclosingType enclosingType = findEnclosingType(request.info, lexerToASTOffset(request.result, request.anchor)); final String enclosingTypeName = enclosingType != null ? enclosingType.extractTypeName() : null; @@ -1493,6 +1549,8 @@ private void autoCompleteExpression(final PHPCompletionResult completionResult, completionResult.add(new PHPCompletionItem.ClassScopeKeywordItem(typeName, keyword, request)); } } + // NETBEANS-1855 + autoCompleteClassMembers(completionResult, request, false, true); } } } diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java index f7a738799098..5e17054f5286 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java @@ -42,6 +42,7 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.api.annotations.common.StaticResource; import org.netbeans.api.editor.EditorRegistry; import org.netbeans.api.editor.completion.Completion; import org.netbeans.api.lexer.Token; @@ -122,6 +123,7 @@ */ public abstract class PHPCompletionItem implements CompletionProposal { + @StaticResource private static final String PHP_KEYWORD_ICON = "org/netbeans/modules/php/editor/resources/php16Key.png"; //NOI18N protected static final ImageIcon KEYWORD_ICON = new ImageIcon(ImageUtilities.loadImage(PHP_KEYWORD_ICON)); final CompletionRequest request; @@ -487,20 +489,44 @@ public boolean isSmart() { public static class MethodElementItem extends FunctionElementItem { + private final boolean completeAccessPrefix; + /** * @return more than one instance in case if optional parameters exists */ static List getItems(final MethodElement methodElement, CompletionRequest request) { + return getItems(methodElement, request, false); + } + + /** + * @return more than one instance in case if optional parameters exists + */ + static List getItems(final MethodElement methodElement, CompletionRequest request, boolean completeAccessPrefix) { final List retval = new ArrayList<>(); List items = FunctionElementItem.getItems(methodElement, request); for (FunctionElementItem functionElementItem : items) { - retval.add(new MethodElementItem(functionElementItem)); + retval.add(new MethodElementItem(functionElementItem, completeAccessPrefix)); } return retval; } MethodElementItem(FunctionElementItem function) { + this(function, false); + } + + MethodElementItem(FunctionElementItem function, boolean completeAccessPrefix) { super(function.getBaseFunctionElement(), function.request, function.parameters); + this.completeAccessPrefix = completeAccessPrefix; + } + + @Override + public String getCustomInsertTemplate() { + String prefix = ""; // NOI18N + if (completeAccessPrefix) { + Set modifiers = getModifiers(); + prefix = modifiers.contains(Modifier.STATIC) ? "self::" : "$this->"; // NOI18N + } + return prefix + super.getCustomInsertTemplate(); } } @@ -822,18 +848,24 @@ protected String getTypeName() { static class FieldItem extends BasicFieldItem { private final boolean forceDollared; + private final boolean completeAccessPrefix; public static FieldItem getItem(FieldElement field, CompletionRequest request) { return getItem(field, request, false); } public static FieldItem getItem(FieldElement field, CompletionRequest request, boolean forceDollared) { - return new FieldItem(field, request, forceDollared); + return new FieldItem(field, request, forceDollared, false); + } + + public static FieldItem getItem(FieldElement field, CompletionRequest request, boolean forceDollared, boolean completeAccessPrefix) { + return new FieldItem(field, request, forceDollared, completeAccessPrefix); } - private FieldItem(FieldElement field, CompletionRequest request, boolean forceDollared) { + private FieldItem(FieldElement field, CompletionRequest request, boolean forceDollared, boolean completeAccessPrefix) { super(field, null, request); this.forceDollared = forceDollared; + this.completeAccessPrefix = completeAccessPrefix; } FieldElement getField() { @@ -861,16 +893,33 @@ protected String getTypeName() { } return typeName; } + + @Override + public String getCustomInsertTemplate() { + if (completeAccessPrefix) { + Set modifiers = getModifiers(); + String prefix = modifiers.contains(Modifier.STATIC) ? "self::" : "$this->"; // NOI18N + return prefix + getName(); + } + return super.getCustomInsertTemplate(); + } } static class TypeConstantItem extends PHPCompletionItem { + private final boolean completeAccessPrefix; + public static TypeConstantItem getItem(TypeConstantElement constant, CompletionRequest request) { - return new TypeConstantItem(constant, request); + return getItem(constant, request, false); } - private TypeConstantItem(TypeConstantElement constant, CompletionRequest request) { + public static TypeConstantItem getItem(TypeConstantElement constant, CompletionRequest request, boolean completeAccessPrefix) { + return new TypeConstantItem(constant, request, completeAccessPrefix); + } + + private TypeConstantItem(TypeConstantElement constant, CompletionRequest request, boolean completeAccessPrefix) { super(constant, request); + this.completeAccessPrefix = completeAccessPrefix; } TypeConstantElement getConstant() { @@ -922,6 +971,14 @@ public String getRhsHtml(HtmlFormatter formatter) { } return super.getRhsHtml(formatter); } + + @Override + public String getCustomInsertTemplate() { + if (completeAccessPrefix) { + return "self::" + getName(); // NOI18N + } + return super.getCustomInsertTemplate(); + } } public static class MethodDeclarationItem extends MethodElementItem { diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/model/ModelUtils.java b/php/php.editor/src/org/netbeans/modules/php/editor/model/ModelUtils.java index d79558fc3339..ba45cf38ef72 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/model/ModelUtils.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/model/ModelUtils.java @@ -236,6 +236,16 @@ public static Collection resolveType(Model model, Assignmen return retval; } + @NonNull + public static Collection resolveType(Model model, int offset) { + VariableScope variableScope = model.getVariableScope(offset); + TypeScope typeScope = getTypeScope(variableScope); + if (typeScope != null) { + return Collections.singletonList(typeScope); + } + return Collections.emptyList(); + } + @NonNull public static Collection resolveTypeAfterReferenceToken(Model model, TokenSequence tokenSequence, int offset, boolean specialVariable) { diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_01.completion index faa22bc1fd55..42fd822cfa2c 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_01.completion @@ -4,7 +4,11 @@ echo "class property: |$this->name\n"; PACKAGE ANS [PUBLIC] null PACKAGE CNS [PUBLIC] null CLASS Book [PUBLIC] issue153707.php +METHOD getName() [PUBLIC] Book +METHOD setName($name) [PUBLIC] Book VARIABLE ? $name [PUBLIC] issue153707.php +VARIABLE ? name [PUBLIC] Book +CONSTANT TEST 'Simon' [PUBLIC] Book KEYWORD Book $this-> null KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_02.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_02.completion index 3e4804a30ed9..1bbab6233dcc 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_02.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/_base/issue153707.php.testIssue153707_02.completion @@ -2,6 +2,7 @@ Code completion result for source line: echo "class property: $|this->name\n"; (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) VARIABLE ? $name [PUBLIC] issue153707.php +VARIABLE ? name [PUBLIC] Book KEYWORD Book $this-> null ------------------------------------ VARIABLE $GLOBALS PHP Platform diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php new file mode 100644 index 000000000000..09a9a2248d3f --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php @@ -0,0 +1,145 @@ + null +KEYWORD parent:: null +KEYWORD self:: null +KEYWORD static:: null +------------------------------------ +VARIABLE $GLOBALS PHP Platform +VARIABLE $HTTP_RAW_POST_DATA PHP Platform +VARIABLE $_COOKIE PHP Platform +VARIABLE $_ENV PHP Platform +VARIABLE $_FILES PHP Platform +VARIABLE $_GET PHP Platform +VARIABLE $_POST PHP Platform +VARIABLE $_REQUEST PHP Platform +VARIABLE $_SERVER PHP Platform +VARIABLE $_SESSION PHP Platform +VARIABLE $argc PHP Platform +VARIABLE $argv PHP Platform +VARIABLE $http_response_header PHP Platform +VARIABLE $php_errormsg PHP Platform +KEYWORD abstract null +KEYWORD and null +KEYWORD array null +KEYWORD as null +KEYWORD break null +KEYWORD case null +KEYWORD catch null +KEYWORD class null +KEYWORD clone null +KEYWORD const null +KEYWORD continue null +KEYWORD declare null +KEYWORD default null +KEYWORD die() Language Construct +KEYWORD do null +KEYWORD echo ''; Language Construct +KEYWORD else null +KEYWORD elseif null +KEYWORD empty() Language Construct +KEYWORD enddeclare null +KEYWORD endfor null +KEYWORD endforeach null +KEYWORD endif null +KEYWORD endswitch null +KEYWORD endwhile null +KEYWORD eval() Language Construct +KEYWORD exit() Language Construct +KEYWORD extends null +KEYWORD final null +KEYWORD finally null +KEYWORD fn null +KEYWORD for null +KEYWORD foreach null +KEYWORD function null +KEYWORD global null +KEYWORD goto null +KEYWORD if null +KEYWORD implements null +KEYWORD include ''; Language Construct +KEYWORD include_once ''; Language Construct +KEYWORD instanceof null +KEYWORD interface null +KEYWORD isset() Language Construct +KEYWORD list() Language Construct +KEYWORD namespace null +KEYWORD new null +KEYWORD or null +KEYWORD print ''; Language Construct +KEYWORD private null +KEYWORD protected null +KEYWORD public null +KEYWORD require ''; Language Construct +KEYWORD require_once ''; Language Construct +KEYWORD return ; Language Construct +KEYWORD static null +KEYWORD switch null +KEYWORD throw null +KEYWORD try null +KEYWORD unset() Language Construct +KEYWORD use null +KEYWORD var null +KEYWORD while null +KEYWORD xor null +KEYWORD yield null +KEYWORD yield from null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefixInTrait_02.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefixInTrait_02.completion new file mode 100644 index 000000000000..5e35c3fd68cc --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefixInTrait_02.completion @@ -0,0 +1,26 @@ +Code completion result for source line: +$|p; // trait 2 +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +VARIABLE ? $param [PUBLIC] nb1855.php +VARIABLE ? $privateTraitStaticProperty [PRIVATE, Trait1855 +VARIABLE ? $protectedTraitStaticPropert [PROTECTE Trait1855 +VARIABLE ? $publicStaticTraitProperty [STATIC] Trait1855 +VARIABLE ? privateTraitProperty [PRIVATE] Trait1855 +VARIABLE ? protectedTraitProperty [PROTECTE Trait1855 +VARIABLE ? publicTraitProperty [PUBLIC] Trait1855 +KEYWORD Trait1855 $this-> null +------------------------------------ +VARIABLE $GLOBALS PHP Platform +VARIABLE $HTTP_RAW_POST_DATA PHP Platform +VARIABLE $_COOKIE PHP Platform +VARIABLE $_ENV PHP Platform +VARIABLE $_FILES PHP Platform +VARIABLE $_GET PHP Platform +VARIABLE $_POST PHP Platform +VARIABLE $_REQUEST PHP Platform +VARIABLE $_SERVER PHP Platform +VARIABLE $_SESSION PHP Platform +VARIABLE $argc PHP Platform +VARIABLE $argv PHP Platform +VARIABLE $http_response_header PHP Platform +VARIABLE $php_errormsg PHP Platform diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefixInTrait_03.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefixInTrait_03.completion new file mode 100644 index 000000000000..6c4b62b4d589 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefixInTrait_03.completion @@ -0,0 +1,9 @@ +Code completion result for source line: +protected|TraitMethod($param); // trait 3 +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD protectedTraitMethod($param) [PROTECTE Trait1855 +METHOD protectedTraitStaticMethod($pa [PROTECTE Trait1855 +VARIABLE ? $protectedTraitStaticPropert [PROTECTE Trait1855 +VARIABLE ? protectedTraitProperty [PROTECTE Trait1855 +------------------------------------ +KEYWORD protected null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_01.completion new file mode 100644 index 000000000000..5dae1bd99cdd --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_01.completion @@ -0,0 +1,128 @@ +Code completion result for source line: +| // test1 +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +CLASS Class1855 [PUBLIC] nb1855.php +CLASS ParentClass [PUBLIC] nb1855.php +METHOD privateMethod($param) [PRIVATE] Class1855 +METHOD privateStaticMethod($param, $p [PRIVATE, Class1855 +METHOD privateTraitMethod($param) [PRIVATE] Trait1855 +METHOD privateTraitStaticMethod($para [PRIVATE, Trait1855 +METHOD protectedMethod($param) [PROTECTE Class1855 +METHOD protectedParentMethod($param) [PROTECTE ParentClass +METHOD protectedParentStaticMethod($p [PROTECTE ParentClass +METHOD protectedStaticMethod($param, [PROTECTE Class1855 +METHOD protectedTraitMethod($param) [PROTECTE Trait1855 +METHOD protectedTraitStaticMethod($pa [PROTECTE Trait1855 +METHOD publicMethod($param) [PUBLIC] Class1855 +METHOD publicParentMethod($param) [PUBLIC] ParentClass +METHOD publicParentStaticMethod($para [STATIC] ParentClass +METHOD publicStaticMethod($param, $pa [STATIC] Class1855 +METHOD publicTraitMethod($param) [PUBLIC] Trait1855 +METHOD publicTraitStaticMethod($param [STATIC] Trait1855 +METHOD test() [PUBLIC] Class1855 +VARIABLE ? $privateStaticProperty [PRIVATE, Class1855 +VARIABLE ? $privateTraitStaticProperty [PRIVATE, Trait1855 +VARIABLE ? $protectedParentStaticProper [PROTECTE ParentClass +VARIABLE ? $protectedStaticProperty [PROTECTE Class1855 +VARIABLE ? $protectedTraitStaticPropert [PROTECTE Trait1855 +VARIABLE ? $publicStaticParentProperty [STATIC] ParentClass +VARIABLE ? $publicStaticProperty [STATIC] Class1855 +VARIABLE ? $publicStaticTraitProperty [STATIC] Trait1855 +VARIABLE ? privateProperty [PRIVATE] Class1855 +VARIABLE ? privateTraitProperty [PRIVATE] Trait1855 +VARIABLE ? protectedParentProperty [PROTECTE ParentClass +VARIABLE ? protectedProperty [PROTECTE Class1855 +VARIABLE ? protectedTraitProperty [PROTECTE Trait1855 +VARIABLE ? publicParentProperty [PUBLIC] ParentClass +VARIABLE ? publicProperty [PUBLIC] Class1855 +VARIABLE ? publicTraitProperty [PUBLIC] Trait1855 +CONSTANT PRIVATE_CONSTANT "private cons [PRIVATE] Class1855 +CONSTANT PROTECTED_CONSTANT "protected [PROTECTE Class1855 +CONSTANT PROTECTED_PARENT_CONSTANT "pro [PROTECTE ParentClass +CONSTANT PUBLIC_CONSTANT "pubic constan [PUBLIC] Class1855 +CONSTANT PUBLIC_PARENT_CONSTANT "pubic [PUBLIC] ParentClass +CONSTANT TEST2 ? [PUBLIC] Class1855 +KEYWORD Class1855 $this-> null +KEYWORD parent:: null +KEYWORD self:: null +KEYWORD static:: null +------------------------------------ +VARIABLE $GLOBALS PHP Platform +VARIABLE $HTTP_RAW_POST_DATA PHP Platform +VARIABLE $_COOKIE PHP Platform +VARIABLE $_ENV PHP Platform +VARIABLE $_FILES PHP Platform +VARIABLE $_GET PHP Platform +VARIABLE $_POST PHP Platform +VARIABLE $_REQUEST PHP Platform +VARIABLE $_SERVER PHP Platform +VARIABLE $_SESSION PHP Platform +VARIABLE $argc PHP Platform +VARIABLE $argv PHP Platform +VARIABLE $http_response_header PHP Platform +VARIABLE $php_errormsg PHP Platform +KEYWORD abstract null +KEYWORD and null +KEYWORD array null +KEYWORD as null +KEYWORD break null +KEYWORD case null +KEYWORD catch null +KEYWORD class null +KEYWORD clone null +KEYWORD const null +KEYWORD continue null +KEYWORD declare null +KEYWORD default null +KEYWORD die() Language Construct +KEYWORD do null +KEYWORD echo ''; Language Construct +KEYWORD else null +KEYWORD elseif null +KEYWORD empty() Language Construct +KEYWORD enddeclare null +KEYWORD endfor null +KEYWORD endforeach null +KEYWORD endif null +KEYWORD endswitch null +KEYWORD endwhile null +KEYWORD eval() Language Construct +KEYWORD exit() Language Construct +KEYWORD extends null +KEYWORD final null +KEYWORD finally null +KEYWORD fn null +KEYWORD for null +KEYWORD foreach null +KEYWORD function null +KEYWORD global null +KEYWORD goto null +KEYWORD if null +KEYWORD implements null +KEYWORD include ''; Language Construct +KEYWORD include_once ''; Language Construct +KEYWORD instanceof null +KEYWORD interface null +KEYWORD isset() Language Construct +KEYWORD list() Language Construct +KEYWORD namespace null +KEYWORD new null +KEYWORD or null +KEYWORD print ''; Language Construct +KEYWORD private null +KEYWORD protected null +KEYWORD public null +KEYWORD require ''; Language Construct +KEYWORD require_once ''; Language Construct +KEYWORD return ; Language Construct +KEYWORD static null +KEYWORD switch null +KEYWORD throw null +KEYWORD try null +KEYWORD unset() Language Construct +KEYWORD use null +KEYWORD var null +KEYWORD while null +KEYWORD xor null +KEYWORD yield null +KEYWORD yield from null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_02.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_02.completion new file mode 100644 index 000000000000..45605038ceae --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_02.completion @@ -0,0 +1,35 @@ +Code completion result for source line: +$| // test2 +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +VARIABLE ? $privateStaticProperty [PRIVATE, Class1855 +VARIABLE ? $privateTraitStaticProperty [PRIVATE, Trait1855 +VARIABLE ? $protectedParentStaticProper [PROTECTE ParentClass +VARIABLE ? $protectedStaticProperty [PROTECTE Class1855 +VARIABLE ? $protectedTraitStaticPropert [PROTECTE Trait1855 +VARIABLE ? $publicStaticParentProperty [STATIC] ParentClass +VARIABLE ? $publicStaticProperty [STATIC] Class1855 +VARIABLE ? $publicStaticTraitProperty [STATIC] Trait1855 +VARIABLE ? privateProperty [PRIVATE] Class1855 +VARIABLE ? privateTraitProperty [PRIVATE] Trait1855 +VARIABLE ? protectedParentProperty [PROTECTE ParentClass +VARIABLE ? protectedProperty [PROTECTE Class1855 +VARIABLE ? protectedTraitProperty [PROTECTE Trait1855 +VARIABLE ? publicParentProperty [PUBLIC] ParentClass +VARIABLE ? publicProperty [PUBLIC] Class1855 +VARIABLE ? publicTraitProperty [PUBLIC] Trait1855 +KEYWORD Class1855 $this-> null +------------------------------------ +VARIABLE $GLOBALS PHP Platform +VARIABLE $HTTP_RAW_POST_DATA PHP Platform +VARIABLE $_COOKIE PHP Platform +VARIABLE $_ENV PHP Platform +VARIABLE $_FILES PHP Platform +VARIABLE $_GET PHP Platform +VARIABLE $_POST PHP Platform +VARIABLE $_REQUEST PHP Platform +VARIABLE $_SERVER PHP Platform +VARIABLE $_SESSION PHP Platform +VARIABLE $argc PHP Platform +VARIABLE $argv PHP Platform +VARIABLE $http_response_header PHP Platform +VARIABLE $php_errormsg PHP Platform diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_03.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_03.completion new file mode 100644 index 000000000000..55b15a3b3250 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb1855/nb1855.php.testCompleteAccessPrefix_03.completion @@ -0,0 +1,15 @@ +Code completion result for source line: +pri| // test3 +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD privateMethod($param) [PRIVATE] Class1855 +METHOD privateStaticMethod($param, $p [PRIVATE, Class1855 +METHOD privateTraitMethod($param) [PRIVATE] Trait1855 +METHOD privateTraitStaticMethod($para [PRIVATE, Trait1855 +VARIABLE ? $privateStaticProperty [PRIVATE, Class1855 +VARIABLE ? $privateTraitStaticProperty [PRIVATE, Trait1855 +VARIABLE ? privateProperty [PRIVATE] Class1855 +VARIABLE ? privateTraitProperty [PRIVATE] Trait1855 +CONSTANT PRIVATE_CONSTANT "private cons [PRIVATE] Class1855 +------------------------------------ +KEYWORD print ''; Language Construct +KEYWORD private null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/anonymousClass03.php.testAnonymousClass03a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/anonymousClass03.php.testAnonymousClass03a.completion index 29fb907b8422..57e62424d3d7 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/anonymousClass03.php.testAnonymousClass03a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/anonymousClass03.php.testAnonymousClass03a.completion @@ -1,6 +1,8 @@ Code completion result for source line: return new class($|this->prop) extends Outer { (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +VARIABLE ? prop [PRIVATE] \My\Outer +VARIABLE ? prop2 [PROTECTE \My\Outer KEYWORD Outer $this-> null ------------------------------------ VARIABLE $GLOBALS PHP Platform diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_21b.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_21b.completion index ddf5f2cf1de7..a31f02705cfd 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_21b.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_21b.completion @@ -2,6 +2,9 @@ Code completion result for source line: $af = fn(): ?ArrowFunctions => |$this; (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) CLASS ArrowFunctions [PUBLIC] arrowFunctions.php +METHOD getNumber() [PUBLIC] ArrowFunctions +METHOD new() [STATIC] ArrowFunctions +METHOD test() [PUBLIC] ArrowFunctions VARIABLE ? $af [PUBLIC] arrowFunctions.php VARIABLE int $test [PUBLIC] arrowFunctions.php CONSTANT CONSTANT_INT 1000 [PUBLIC] arrowFunctions.php diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_24b.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_24b.completion index cc801e89e1e6..576e0e91690a 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_24b.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_24b.completion @@ -2,6 +2,9 @@ Code completion result for source line: $af = static fn() => |isset($this); // static (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) CLASS ArrowFunctions [PUBLIC] arrowFunctions.php +METHOD getNumber() [PUBLIC] ArrowFunctions +METHOD new() [STATIC] ArrowFunctions +METHOD test() [PUBLIC] ArrowFunctions VARIABLE ? $af [PUBLIC] arrowFunctions.php VARIABLE int $test [PUBLIC] arrowFunctions.php CONSTANT CONSTANT_INT 1000 [PUBLIC] arrowFunctions.php diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethod/arrowFunctionsInMethod.php.testArrowFunctionsInMethod_01a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethod/arrowFunctionsInMethod.php.testArrowFunctionsInMethod_01a.completion index 9eac00590e7e..7e479e964777 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethod/arrowFunctionsInMethod.php.testArrowFunctionsInMethod_01a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethod/arrowFunctionsInMethod.php.testArrowFunctionsInMethod_01a.completion @@ -2,6 +2,8 @@ Code completion result for source line: $fn = fn() => |$af->getNumber() + $number + $this->getNumber(); (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) CLASS ArrowFunctions [PUBLIC] arrowFunctionsInMethod.php +METHOD getNumber() [PUBLIC] ArrowFunctions +METHOD test(ArrowFunctions $af, int $ [PUBLIC] ArrowFunctions VARIABLE ? $fn [PUBLIC] arrowFunctionsInMethod.php VARIABLE ArrowFunctions $af [PUBLIC] arrowFunctionsInMethod.php VARIABLE int $number [PUBLIC] arrowFunctionsInMethod.php diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_01a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_01a.completion index 9328ba8a60aa..d7d1d03e6949 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_01a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_01a.completion @@ -2,6 +2,8 @@ Code completion result for source line: $fn = fn(int $test) => $af->getNumber() + | + $this->getNumber(); (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) CLASS ArrowFunctions [PUBLIC] arrowFunctionsInMethodWithError.php +METHOD getNumber() [PUBLIC] ArrowFunctions +METHOD test(ArrowFunctions $af, int $ [PUBLIC] ArrowFunctions VARIABLE ? $fn [PUBLIC] arrowFunctionsInMethodWithError.php VARIABLE ArrowFunctions $af [PUBLIC] arrowFunctionsInMethodWithError.php VARIABLE int $number [PUBLIC] arrowFunctionsInMethodWithError.php diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_02a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_02a.completion index d14f7cd24c3e..66067087a57e 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_02a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctionsInMethodWithError/arrowFunctionsInMethodWithError.php.testArrowFunctionsInMethodWithError_02a.completion @@ -2,6 +2,8 @@ Code completion result for source line: $fn = fn(ArrowFunctions $object) => $af->getNumber() + |; (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) CLASS ArrowFunctions [PUBLIC] arrowFunctionsInMethodWithError.php +METHOD getNumber() [PUBLIC] ArrowFunctions +METHOD test(ArrowFunctions $af, int $ [PUBLIC] ArrowFunctions VARIABLE ? $fn [PUBLIC] arrowFunctionsInMethodWithError.php VARIABLE ArrowFunctions $af [PUBLIC] arrowFunctionsInMethodWithError.php VARIABLE ArrowFunctions $object [PUBLIC] arrowFunctionsInMethodWithError.php diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_00.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_00.completion index 32a74fc4a9b7..53d7777d89ec 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_00.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_00.completion @@ -6,6 +6,12 @@ PACKAGE Foo [PUBLIC] null CLASS BarUnpackClass [PUBLIC] Bar CLASS UnpackChildClass [PUBLIC] Foo CLASS UnpackClass [PUBLIC] Foo +CONSTANT CONSTANT ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT1 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT2 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT3 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT4 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT5 ? [PUBLIC] \Foo\UnpackClass CONSTANT F_CONST "test" [PUBLIC] Foo KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_01.completion index ae2626d10418..feae9c84a120 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_01.completion @@ -6,6 +6,12 @@ PACKAGE Foo [PUBLIC] null CLASS BarUnpackClass [PUBLIC] Bar CLASS UnpackChildClass [PUBLIC] Foo CLASS UnpackClass [PUBLIC] Foo +CONSTANT CONSTANT ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT1 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT2 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT3 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT4 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT5 ? [PUBLIC] \Foo\UnpackClass CONSTANT F_CONST "test" [PUBLIC] Foo KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_04.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_04.completion index 7c6f414f8c0e..d452e36ce388 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_04.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_04.completion @@ -6,6 +6,12 @@ PACKAGE Foo [PUBLIC] null CLASS BarUnpackClass [PUBLIC] Bar CLASS UnpackChildClass [PUBLIC] Foo CLASS UnpackClass [PUBLIC] Foo +CONSTANT CONSTANT ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT1 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT2 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT3 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT4 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT5 ? [PUBLIC] \Foo\UnpackClass CONSTANT F_CONST "test" [PUBLIC] Foo KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_07.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_07.completion index 0c043030aec7..cb5ea8cdeeaa 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_07.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_07.completion @@ -6,6 +6,13 @@ PACKAGE Foo [PUBLIC] null CLASS BarUnpackClass [PUBLIC] Bar CLASS UnpackChildClass [PUBLIC] Foo CLASS UnpackClass [PUBLIC] Foo +CONSTANT CHILD_CONSTANT ? [PUBLIC] \Foo\UnpackChildClass +CONSTANT CONSTANT ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT1 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT2 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT3 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT4 ? [PUBLIC] \Foo\UnpackClass +CONSTANT CONSTANT5 ? [PUBLIC] \Foo\UnpackClass CONSTANT F_CONST "test" [PUBLIC] Foo KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_11.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_11.completion index 4358ac568f71..a8f2e9ce17a2 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_11.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testSpreadOperatorInClassConst/spreadOperatorInClassConst.php.testSpreadOperatorInClassConst_11.completion @@ -6,6 +6,10 @@ PACKAGE Foo [PUBLIC] null CLASS BarUnpackClass [PUBLIC] Bar CLASS UnpackChildClass [PUBLIC] Foo CLASS UnpackClass [PUBLIC] Foo +CONSTANT CONST1 ? [PRIVATE] \Bar\BarUnpackClass +CONSTANT CONST2 ? [PRIVATE] \Bar\BarUnpackClass +CONSTANT CONST3 ? [PRIVATE] \Bar\BarUnpackClass +CONSTANT CONST4 ? [PRIVATE] \Bar\BarUnpackClass CONSTANT F_CONST "test" [PUBLIC] Foo KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/tests247082/issue247082.php.testForKeywords.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/tests247082/issue247082.php.testForKeywords.completion index 408116d4e65b..fbcd3bbc8b07 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/tests247082/issue247082.php.testForKeywords.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/tests247082/issue247082.php.testForKeywords.completion @@ -3,7 +3,29 @@ echo |self::MY_CONST . PHP_EOL; (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) CLASS A [PUBLIC] issue247082.php CLASS ParentA [PUBLIC] issue247082.php +METHOD filter(array $values) [PUBLIC] A +METHOD myPrivateTestInstance() [PRIVATE] A +METHOD myPrivateTestStatic() [PRIVATE, A +METHOD myProtectedTestInstance() [PROTECTE A +METHOD myProtectedTestStatic() [PROTECTE A +METHOD myTestInstance() [PUBLIC] A +METHOD myTestStatic() [STATIC] A +METHOD parentProtectedTestInstance() [PROTECTE ParentA +METHOD parentProtectedTestStatic() [PROTECTE ParentA +METHOD parentTestInstance() [PUBLIC] ParentA +METHOD parentTestStatic() [STATIC] ParentA +METHOD test() [PUBLIC] A +VARIABLE ? $myFieldStatic [STATIC] A +VARIABLE ? $myPrivateFieldStatic [PRIVATE, A +VARIABLE ? $myProtectedFieldStatic [PROTECTE A +VARIABLE ? $parentFieldStatic [STATIC] ParentA +VARIABLE ? $parentProtectedFieldStatic [PROTECTE ParentA VARIABLE ? $val [PUBLIC] issue247082.php +VARIABLE ? myFieldInstance [PUBLIC] A +VARIABLE ? myPrivateFieldInstance [PRIVATE] A +VARIABLE ? myProtectedFieldInstance [PROTECTE A +CONSTANT MY_CONST 'MY_CONST' [PUBLIC] A +CONSTANT PARENT_CONST 'PARENT_CONST' [PUBLIC] ParentA KEYWORD A $this-> null KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/tests257088/issue257088.php.testClassKeywords.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/tests257088/issue257088.php.testClassKeywords.completion index 879f30f94ee8..de02e4d69079 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/tests257088/issue257088.php.testClassKeywords.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/tests257088/issue257088.php.testClassKeywords.completion @@ -1,6 +1,7 @@ Code completion result for source line: |;// HERE (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD publicMethod() [PUBLIC] MyTrait KEYWORD MyTrait $this-> null KEYWORD parent:: null KEYWORD self:: null diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionNb1855Test.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionNb1855Test.java new file mode 100644 index 000000000000..2e9b54019e25 --- /dev/null +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionNb1855Test.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.php.editor.completion; + +import java.io.File; +import java.util.Collections; +import java.util.Map; +import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.modules.php.project.api.PhpSourcePath; +import org.netbeans.spi.java.classpath.support.ClassPathSupport; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + + +public class PHPCodeCompletionNb1855Test extends PHPCodeCompletionTestBase { + + public PHPCodeCompletionNb1855Test(String testName) { + super(testName); + } + + public void testCompleteAccessPrefix_01() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " ^ // test1", false); + } + + public void testCompleteAccessPrefix_02() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " $^ // test2", false); + } + + public void testCompleteAccessPrefix_03() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " pri^ // test3", false); + } + + public void testCompleteAccessPrefixInClassConst_01() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " public const TEST1 = ^;", false); + } + + public void testCompleteAccessPrefixInClassConst_02() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " public const TEST2 = pri^;", false); + } + + public void testCompleteAccessPrefixInTrait_01() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " ^ // trait 1", false); + } + + public void testCompleteAccessPrefixInTrait_02() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " $^p; // trait 2", false); + } + + public void testCompleteAccessPrefixInTrait_03() throws Exception { + checkCompletion("testfiles/completion/lib/nb1855/nb1855.php", " protected^TraitMethod($param); // trait 3", false); + } + + @Override + protected Map createClassPathsForTest() { + return Collections.singletonMap( + PhpSourcePath.SOURCE_CP, + ClassPathSupport.createClassPath(new FileObject[] { + FileUtil.toFileObject(new File(getDataDir(), "/testfiles/completion/lib/nb1855")) + }) + ); + } +} diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionTest.java index 53e16ea6f772..e89e06884b86 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionTest.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionTest.java @@ -781,6 +781,7 @@ public void testClassConstructorOptionalParam_01() throws Exception { } public void testIssue153707_01() throws Exception { + // FIXME: maybe, should add only variables and $this-> checkCompletion("testfiles/completion/lib/_base/issue153707.php", "class property: ^", false); }