Skip to content

Commit

Permalink
Merge pull request apache#3324 from junichi11/netbeans-6217-convert-v…
Browse files Browse the repository at this point in the history
…isibility-suggestion

[NETBEANS-6217] Allow Convert Visibility Suggestion to be disabled
  • Loading branch information
tmysik authored Nov 19, 2021
2 parents 0f96463 + cdad76e commit eabd814
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@
<file name="org-netbeans-modules-php-editor-verification-BracesHint$IfBracesHint.instance"/>
<file name="org-netbeans-modules-php-editor-verification-BracesHint$WhileBracesHint.instance"/>
</folder>
<file name="org-netbeans-modules-php-editor-verification-ConvertVisibilitySuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-EmptyStatementHint.instance"/>
<file name="org-netbeans-modules-php-editor-verification-ErrorControlOperatorHint.instance"/>
<file name="org-netbeans-modules-php-editor-verification-ImmutableVariablesHint.instance"/>
Expand Down Expand Up @@ -406,7 +407,6 @@
<file name="org-netbeans-modules-php-editor-verification-ArrowFunctionSuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-AssignVariableSuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-CombinedAssignmentOperatorSuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-ConvertVisibilitySuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-DeclareStrictTypesSuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-IdenticalComparisonSuggestion.instance"/>
<file name="org-netbeans-modules-php-editor-verification-InitializeFieldSuggestion.instance"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.netbeans.modules.csl.api.EditList;
import org.netbeans.modules.csl.api.Hint;
import org.netbeans.modules.csl.api.HintFix;
import org.netbeans.modules.csl.api.HintSeverity;
import org.netbeans.modules.csl.api.OffsetRange;
import org.netbeans.modules.csl.spi.support.CancelSupport;
import org.netbeans.modules.php.editor.api.PhpModifiers;
Expand All @@ -49,7 +50,7 @@
/**
* Convert the visibility of a property, a method, or a constant.
*/
public class ConvertVisibilitySuggestion extends SuggestionRule {
public class ConvertVisibilitySuggestion extends HintRule {

private static final String HINT_ID = "Convert.Visibility.Suggestion"; // NOI18N
private static final Logger LOGGER = Logger.getLogger(ConvertVisibilitySuggestion.class.getName());
Expand Down Expand Up @@ -81,9 +82,8 @@ public void invoke(PHPRuleContext context, List<Hint> result) {
return;
}
final BaseDocument doc = context.doc;
int caretOffset = getCaretOffset();
OffsetRange lineBounds = VerificationUtils.createLineBounds(caretOffset, doc);
if (lineBounds.containsInclusive(caretOffset)) {
OffsetRange lineBounds = VerificationUtils.createLineBounds(context.caretOffset, doc);
if (lineBounds.containsInclusive(context.caretOffset)) {
FileObject fileObject = phpParseResult.getSnapshot().getSource().getFileObject();
if (fileObject != null) {
CheckVisitor checkVisitor = new CheckVisitor(fileObject, this, context.doc, lineBounds);
Expand All @@ -96,6 +96,16 @@ public void invoke(PHPRuleContext context, List<Hint> result) {
}
}

@Override
public HintSeverity getDefaultSeverity() {
return HintSeverity.CURRENT_LINE_WARNING;
}

@Override
public boolean getDefaultEnabled() {
return false;
}

private static final class CheckVisitor extends DefaultVisitor {

private final FileObject fileObject;
Expand Down
Loading

0 comments on commit eabd814

Please sign in to comment.