Skip to content

Commit

Permalink
Merge pull request #182 from Haehnchen/feature/only-private-property
Browse files Browse the repository at this point in the history
hide non public properties on DocBlock attribute list completion #139
  • Loading branch information
Haehnchen authored May 29, 2020
2 parents 0977fe2 + eb00658 commit a299719
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi
/**
* "@Foo(<caret>)" provides attribute so field properties of annotation
*/
private class PhpDocAttributeList extends CompletionProvider<CompletionParameters> {
private static class PhpDocAttributeList extends CompletionProvider<CompletionParameters> {

@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
Expand All @@ -177,7 +177,9 @@ protected void addCompletions(@NotNull CompletionParameters completionParameters
}

for(Field field: phpClass.getFields()) {
attachLookupElement(completionResultSet, field);
if (field.getModifier().isPublic()) {
attachLookupElement(completionResultSet, field);
}
}

// extension point for virtual properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ public void testDocTagCompletionInClassScope() {
);
}

public void testCompletionForProperty() {
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
"/**" +
"* @\\My\\Annotations\\All(\"a\",<caret>)" +
"*/" +
"class Foo {}",
"strategy"
);

assertCompletionNotContains(PhpFileType.INSTANCE, "<?php\n" +
"/**" +
"* @\\My\\Annotations\\All(\"a\",<caret>)" +
"*/" +
"class Foo {}",
"myPrivate"
);
}

public void testDocTagCompletionInClassPropertyScope() {
assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
"class Foo {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class All
* @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "UUID", "CUSTOM"})
*/
public $strategy = 'AUTO';

/**
* @var string
*/
private $myPrivate;
}

/**
Expand Down

0 comments on commit a299719

Please sign in to comment.