org.netbeans.spi.editor.hints.Severity Java Examples
The following examples show how to use
org.netbeans.spi.editor.hints.Severity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CdiEditorAnalysisFactory.java From netbeans with Apache License 2.0 | 6 votes |
private static ErrorDescription createNotification( Severity severity, Tree tree, CompilationInfo info, String description, Fix fix ) { List<Fix> fixes; if ( fix != null ){ fixes = Collections.singletonList( fix ); } else { fixes = Collections.<Fix>emptyList(); } if (tree != null){ List<Integer> position = getElementPosition(info, tree); if(position.get(1) > position.get(0)) { return ErrorDescriptionFactory.createErrorDescription( severity, description, fixes, info.getFileObject(), position.get(0), position.get(1)); } } return null; }
Example #2
Source File: ScopedBeanAnalyzer.java From netbeans with Apache License 2.0 | 6 votes |
private void checkFinal( Element element, WebBeansModel model, Result result ) { if ( !( element instanceof TypeElement )){ return; } Set<Modifier> modifiers = element.getModifiers(); if ( modifiers.contains( Modifier.FINAL) ){ result.addError( element, model, NbBundle.getMessage(ScopedBeanAnalyzer.class, "ERR_FinalScopedClass")); return; } List<ExecutableElement> methods = ElementFilter.methodsIn( element.getEnclosedElements()); for (ExecutableElement method : methods) { modifiers = method.getModifiers(); if (modifiers.contains(Modifier.FINAL)) { result.addNotification( Severity.WARNING, method, model, NbBundle.getMessage( ScopedBeanAnalyzer.class, "WARN_FinalScopedClassMethod")); } } }
Example #3
Source File: HintsUtils.java From netbeans with Apache License 2.0 | 6 votes |
public static ErrorDescription createProblem(Element subject, CompilationInfo cinfo, String description, Severity severity, List<Fix> fixes) { ErrorDescription err = null; List<Fix> fixList = fixes == null ? Collections.<Fix>emptyList() : fixes; // by default place error annotation on the element being checked Tree elementTree = cinfo.getTrees().getTree(subject); if (elementTree != null) { TextSpan underlineSpan = getUnderlineSpan(cinfo, elementTree); err = ErrorDescriptionFactory.createErrorDescription( severity, description, fixList, cinfo.getFileObject(), underlineSpan.getStartOffset(), underlineSpan.getEndOffset()); } else { // report problem } return err; }
Example #4
Source File: HintsPanelLogic.java From netbeans with Apache License 2.0 | 6 votes |
private void componentsSetEnabled( boolean enabled ) { if ( !enabled ) { customizerPanel.removeAll(); customizerPanel.getParent().invalidate(); ((JComponent)customizerPanel.getParent()).revalidate(); customizerPanel.getParent().repaint(); severityComboBox.setSelectedIndex(severity2index.get(Severity.VERIFIER)); tasklistCheckBox.setSelected(false); descriptionTextArea.setText(""); // NOI18N } severityComboBox.setEnabled(enabled); tasklistCheckBox.setEnabled(enabled); descriptionTextArea.setEnabled(enabled); }
Example #5
Source File: UtilityClass.java From netbeans with Apache License 2.0 | 6 votes |
@Hint(id="org.netbeans.modules.java.hints.UtilityClass_1", displayName="#MSG_UtilityClass", description="#HINT_UtilityClass", category="api", enabled=false, severity=Severity.VERIFIER, suppressWarnings="UtilityClassWithoutPrivateConstructor") @TriggerTreeKind(Kind.CLASS) public static ErrorDescription utilityClass(HintContext ctx) { CompilationInfo compilationInfo = ctx.getInfo(); TreePath treePath = ctx.getPath(); Element e = compilationInfo.getTrees().getElement(treePath); if (e == null) { return null; } if (!isUtilityClass(compilationInfo, e)) return null; for (ExecutableElement c : ElementFilter.constructorsIn(e.getEnclosedElements())) { if (!compilationInfo.getElementUtilities().isSynthetic(c)) { return null; } } return ErrorDescriptionFactory.forName(ctx, treePath, NbBundle.getMessage(UtilityClass.class, "MSG_UtilityClass"), new FixImpl(true, TreePathHandle.create(e, compilationInfo) ).toEditorFix()); }
Example #6
Source File: AnnotationHolderTest.java From netbeans with Apache License 2.0 | 6 votes |
public void test205675() throws Exception { doc.remove(0, doc.getLength()); doc.insertString(0, "a\nb\nc\nd\ne\n", null); ErrorDescription ed0 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "0", file, 0, 1); ErrorDescription ed1 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "1", file, 2, 3); ErrorDescription ed2 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "2", file, 4, 5); AnnotationHolder ah = AnnotationHolder.getInstance(file); ah.setErrorDescriptions("test", Arrays.asList(ed0, ed1, ed2)); assertEquals(Arrays.asList(ed0), ah.getErrorsGE(0)); assertEquals(Arrays.asList(ed1), ah.getErrorsGE(1)); assertEquals(Arrays.asList(ed1), ah.getErrorsGE(2)); assertEquals(Arrays.asList(ed2), ah.getErrorsGE(3)); assertEquals(Arrays.asList(ed2), ah.getErrorsGE(4)); assertEquals(Arrays.asList(), ah.getErrorsGE(5)); }
Example #7
Source File: Rule.java From netbeans with Apache License 2.0 | 6 votes |
public static ErrorDescription createProblem(Element subject, ProblemContext ctx, String description, Severity severity, List<Fix> fixes){ ErrorDescription err = null; List<Fix> fixList = fixes == null ? Collections.<Fix>emptyList() : fixes; // by default place error annotation on the element being checked Tree elementTree = ctx.getElementToAnnotate() == null ? ctx.getCompilationInfo().getTrees().getTree(subject) : ctx.getElementToAnnotate(); if (elementTree != null){ Utilities.TextSpan underlineSpan = Utilities.getUnderlineSpan( ctx.getCompilationInfo(), elementTree); err = ErrorDescriptionFactory.createErrorDescription( severity, description, fixList, ctx.getFileObject(), underlineSpan.getStartOffset(), underlineSpan.getEndOffset()); } return err; }
Example #8
Source File: WebBeansAnalysisTestResult.java From netbeans with Apache License 2.0 | 6 votes |
public void addNotification( Severity severity, VariableElement element, ExecutableElement method, WebBeansModel model, String message ) { int index = method.getParameters().indexOf( element ); ElementHandle<ExecutableElement> handle = ElementHandle.create(method); ExecutableElement origMethod = handle.resolve(getInfo()); VariableElement param = origMethod.getParameters().get(index); if ( severity == Severity.ERROR){ myErrors.put( param , message ); } else if ( severity == Severity.WARNING){ myWarnings.put( param , message ); } else { assert false; } }
Example #9
Source File: ManagedBeansAnalizer.java From netbeans with Apache License 2.0 | 6 votes |
private void checkCtor( TypeElement element, WebBeansModel model, Result result ) { List<ExecutableElement> ctors = ElementFilter.constructorsIn( element.getEnclosedElements()); for (ExecutableElement ctor : ctors) { Set<Modifier> modifiers = ctor.getModifiers(); if ( modifiers.contains( Modifier.PRIVATE )){ continue; } List<? extends VariableElement> parameters = ctor.getParameters(); if ( parameters.size() ==0 ){ return; } if ( AnnotationUtil.hasAnnotation(ctor, AnnotationUtil.INJECT_FQN, model.getCompilationController())) { return; } } // there is no non-private ctors without params or annotated with @Inject result.addNotification( Severity.WARNING, element, model, NbBundle.getMessage(ManagedBeansAnalizer.class, "WARN_QualifierNoCtorClass")); // NOI18N }
Example #10
Source File: HintContext.java From netbeans with Apache License 2.0 | 6 votes |
private HintContext(CompilationInfo info, HintsSettings settings, HintMetadata metadata, TreePath path, Map<String, TreePath> variables, Map<String, Collection<? extends TreePath>> multiVariables, Map<String, String> variableNames, Map<String, TypeMirror> constraints, Collection<? super MessageImpl> problems, boolean bulkMode, AtomicBoolean cancel, int caret) { this.info = info; this.settings = settings; this.preferences = metadata != null ? settings.getHintPreferences(metadata) : null; this.severity = preferences != null ? settings.getSeverity(metadata) : Severity.ERROR; this.metadata = metadata; this.path = path; variables = new HashMap<String, TreePath>(variables); variables.put("$_", path); this.variables = variables; this.multiVariables = multiVariables; this.variableNames = variableNames; this.messages = problems; this.constraints = constraints; this.bulkMode = bulkMode; this.cancel = cancel; this.caret = caret; }
Example #11
Source File: IntroduceHint.java From netbeans with Apache License 2.0 | 6 votes |
public static List<ErrorDescription> computeError(CompilationInfo info, int start, int end, Map<IntroduceKind, Fix> fixesMap, Map<IntroduceKind, String> errorMessage, AtomicBoolean cancel) { List<ErrorDescription> hints = new LinkedList<ErrorDescription>(); List<Fix> fixes = new LinkedList<Fix>(); addExpressionFixes(info, start, end, fixes, fixesMap, cancel); Fix introduceMethod = IntroduceMethodFix.computeIntroduceMethod(info, start, end, errorMessage, cancel); if (introduceMethod != null) { fixes.add(introduceMethod); if (fixesMap != null) { // TODO: replaces previous version of method fix, but retains it in fixes list ? fixesMap.put(IntroduceKind.CREATE_METHOD, introduceMethod); } } if (!fixes.isEmpty()) { int pos = CaretAwareJavaSourceTaskFactory.getLastPosition(info.getFileObject()); String displayName = NbBundle.getMessage(IntroduceHint.class, "HINT_Introduce"); hints.add(ErrorDescriptionFactory.createErrorDescription(Severity.HINT, displayName, fixes, info.getFileObject(), pos, pos)); } return hints; }
Example #12
Source File: DataTypeMismatchHighlightingTask.java From nb-springboot with Apache License 2.0 | 6 votes |
private void check(String type, String text, Document document, CfgElement elem, List<ErrorDescription> errors, ClassLoader cl, Severity severity) throws BadLocationException { if (canceled) { return; } if (text == null || text.isEmpty()) { return; } // non generic types try { if (!checkType(type, text, cl)) { ErrorDescription errDesc = ErrorDescriptionFactory.createErrorDescription( severity, String.format("Cannot parse '%s' as %s", text, type), document, document.createPosition(elem.getIdxStart()), document.createPosition(elem.getIdxEnd()) ); errors.add(errDesc); } } catch (IllegalArgumentException ex) { // problems instantiating type class, cannot decide, ignore } }
Example #13
Source File: EmptyStatements.java From netbeans with Apache License 2.0 | 6 votes |
@Hint(displayName = "#LBL_Empty_IF", description = "#DSC_Empty_IF", category = "empty", hintKind = Hint.Kind.INSPECTION, severity = Severity.VERIFIER, suppressWarnings = SUPPRESS_WARNINGS_KEY, id = "EmptyStatements_IF", enabled = false) @TriggerTreeKind(Tree.Kind.EMPTY_STATEMENT) public static ErrorDescription forIF(HintContext ctx) { final TreePath treePath = ctx.getPath(); Tree parent = treePath.getParentPath().getLeaf(); if (!EnumSet.of(Kind.IF).contains(parent.getKind())) { return null; } TreePath treePathForWarning = treePath; IfTree it = (IfTree) parent; if (it.getThenStatement() != null && it.getThenStatement().getKind() == Tree.Kind.EMPTY_STATEMENT) { treePathForWarning = treePath.getParentPath(); } if (it.getElseStatement() != null && it.getElseStatement().getKind() == Tree.Kind.EMPTY_STATEMENT) { treePathForWarning = treePath; } final List<Fix> fixes = new ArrayList<>(); fixes.add(FixFactory.createSuppressWarningsFix(ctx.getInfo(), treePathForWarning, SUPPRESS_WARNINGS_KEY)); return createErrorDescription(ctx, parent, fixes, parent.getKind()); }
Example #14
Source File: InjectionPointParameterAnalyzer.java From netbeans with Apache License 2.0 | 6 votes |
private void checkName( ExecutableElement element, VariableElement var, WebBeansModel model, Result result) { AnnotationMirror annotation = AnnotationUtil.getAnnotationMirror( var , AnnotationUtil.NAMED, model.getCompilationController()); if ( annotation!= null){ result.addNotification( Severity.WARNING , var, element , model, NbBundle.getMessage(InjectionPointAnalyzer.class, "WARN_NamedInjectionPoint")); // NOI18N if ( annotation.getElementValues().size() == 0 ){ result.addError(var, element, model, NbBundle.getMessage( InjectionPointParameterAnalyzer.class, "ERR_ParameterNamedInjectionPoint")); // NOI18N } } }
Example #15
Source File: AnnotationHolderTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testComputeHighlightsTwoLayers2() throws Exception { ErrorDescription ed1 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "1", file, 1, 7); ErrorDescription ed2 = ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "2", file, 3, 5); List<ErrorDescription> errors = Arrays.asList(ed1, ed2); final OffsetsBag bag = AnnotationHolder.computeHighlights(doc, errors); assertHighlights("",bag, new int[] {1, 7}, new AttributeSet[] {AnnotationHolder.getColoring(ERROR, doc)}); }
Example #16
Source File: Hinter.java From netbeans with Apache License 2.0 | 5 votes |
/** * Add an annotation-oriented warning hint following the standard pattern. * @param fix what to do for a fix (see e.g. {@link #findAndModifyDeclaration}); no change info * @see #addHint * @see #standardAnnotationDescription * @see #standardAnnotationFixDescription */ public void addStandardAnnotationHint(final Callable<Void> fix) { addHint(Severity.WARNING, standardAnnotationDescription(), new Fix() { public @Override String getText() { return standardAnnotationFixDescription(); } public @Override ChangeInfo implement() throws Exception { fix.call(); return null; } }); }
Example #17
Source File: Configuration.java From netbeans with Apache License 2.0 | 5 votes |
public Severity toEditorSeverity() { switch ( this ) { case ERROR: return Severity.ERROR; case WARNING: return Severity.VERIFIER; default: return null; } }
Example #18
Source File: JPAVerificationTaskProvider.java From netbeans with Apache License 2.0 | 5 votes |
private static String severityToTaskListString(Severity severity){ if (severity == Severity.ERROR){ return TASKLIST_ERROR; } return TASKLIST_WARNING; }
Example #19
Source File: ModelAnalyzer.java From netbeans with Apache License 2.0 | 5 votes |
public void addNotification( Severity severity, VariableElement element, ExecutableElement method, WebBeansModel model, String message ) { ErrorDescription description = CdiEditorAnalysisFactory. createNotification( severity, element,method, model, getInfo() , message); if ( description == null ){ return; } getProblems().add( description ); }
Example #20
Source File: ParseErrorAnnotation.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of ParseErrorAnnotation */ public ParseErrorAnnotation(Severity severity, FixData fixes, String description, Position lineStart, AnnotationHolder holder) { this.severity = severity; this.customType = null; this.fixes = fixes; this.description = description; this.shortDescription = description + NbBundle.getMessage(ParseErrorAnnotation.class, "LBL_shortcut_promotion"); //NOI18N this.lineStart = lineStart; this.holder = holder; if (!fixes.isComputed()) { fixes.addPropertyChangeListener(WeakListeners.propertyChange(this, fixes)); } }
Example #21
Source File: Hinter.java From netbeans with Apache License 2.0 | 5 votes |
/** * Add a hint. * @param severity whether to treat as a warning, etc. * @param description description of hint * @param fixes any fixes to offer * @see #addStandardAnnotationHint */ public void addHint(Severity severity, String description, Fix... fixes) { Integer line = null; try { lines.run(); line = lines.get().get(file.getPath()); } catch (Exception x) { LOG.log(Level.INFO, null, x); } if (line != null) { errors.add(ErrorDescriptionFactory.createErrorDescription(severity, description, Arrays.asList(fixes), doc, line)); } else { LOG.log(Level.WARNING, "no line found for {0}", file); } }
Example #22
Source File: ModelAnalyzer.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void addError( Element subject, String message ) { ErrorDescription description = CdiEditorAnalysisFactory. createNotification( Severity.ERROR, subject, getInfo() , message); if ( description == null ){ return; } getProblems().add( description ); }
Example #23
Source File: AnnotationHolderTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testComputeHighlightsTwoLayers5() throws Exception { ErrorDescription ed1 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "1", file, 3, 5); ErrorDescription ed2 = ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "2", file, 1, 7); List<ErrorDescription> errors = Arrays.asList(ed1, ed2); final OffsetsBag bag = AnnotationHolder.computeHighlights(doc, errors); assertHighlights("",bag, new int[] {1, /*2*/3, 3, 5, /*6*/5, 7}, new AttributeSet[] {AnnotationHolder.getColoring(WARNING, doc), AnnotationHolder.getColoring(ERROR, doc), AnnotationHolder.getColoring(WARNING, doc)}); }
Example #24
Source File: AnnotationHolderTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testComputeHighlightsOneLayer2() throws Exception { ErrorDescription ed1 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "1", file, 1, 7); ErrorDescription ed2 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "2", file, 5, 6); List<ErrorDescription> errors = Arrays.asList(ed1, ed2); final OffsetsBag bag = AnnotationHolder.computeHighlights(doc, errors); assertHighlights("",bag, new int[] {1, 7}, new AttributeSet[] {AnnotationHolder.getColoring(ERROR, doc)}); }
Example #25
Source File: ActionRegistrationHinter.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void process(final Context ctx) throws Exception { final FileObject file = ctx.file(); final Object instanceCreate = ctx.instanceAttribute(file); if (instanceCreate == null) { return; } if ("method:org.openide.awt.Actions.alwaysEnabled".equals(instanceCreate)) { ctx.addStandardAnnotationHint(new Callable<Void>() { public @Override Void call() throws Exception { if (!annotationsAvailable(ctx)) { return null; } ctx.findAndModifyDeclaration(file.getAttribute("literal:delegate"), new RegisterAction(ctx, false)); return null; } }); } else if ("method:org.openide.awt.Actions.checkbox".equals(instanceCreate)) { // #193279: no associated annotation available } else if ("method:org.openide.awt.Actions.callback".equals(instanceCreate) || "method:org.openide.awt.Actions.context".equals(instanceCreate)) { ctx.addHint(Severity.WARNING, ctx.standardAnnotationDescription()/* XXX no fixes yet */); } else if ("method:org.openide.windows.TopComponent.openAction".equals(instanceCreate)) { // XXX pending #191407: @OpenActionRegistration (w/ @ActionID and @ActionReference) // (could also do @Registration but would be a separate Hinter) // (@Description probably needed but harder since need to remove method overrides) } else if (file.getPath().startsWith("Actions/")) { // Old-style eager action of some variety. ctx.addStandardAnnotationHint(new Callable<Void>() { public @Override Void call() throws Exception { if (!annotationsAvailable(ctx)) { return null; } ctx.findAndModifyDeclaration(instanceCreate, new RegisterAction(ctx, true)); return null; } }); } }
Example #26
Source File: SyntaxErrorHighlightingTask.java From nb-springboot with Apache License 2.0 | 5 votes |
@Override protected void internalRun(CfgPropsParser.CfgPropsParserResult cfgResult, SchedulerEvent se, BaseDocument document, List<ErrorDescription> errors, Severity severity) { logger.fine("Highlighting syntax errors"); try { final InputBuffer ibuf = cfgResult.getParbResult().inputBuffer; final List<ParseError> parseErrors = cfgResult.getParbResult().parseErrors; for (ParseError error : parseErrors) { String message = error.getErrorMessage() != null ? error.getErrorMessage() : error instanceof InvalidInputError ? formatter.format((InvalidInputError) error) : error.getClass().getSimpleName(); ErrorDescription errDesc = ErrorDescriptionFactory.createErrorDescription( severity, message, document, document.createPosition(ibuf.getOriginalIndex(error.getStartIndex())), document.createPosition(ibuf.getOriginalIndex(error.getEndIndex())) ); errors.add(errDesc); if (canceled) { break; } } } catch (BadLocationException | ParseException ex) { Exceptions.printStackTrace(ex); } if (!errors.isEmpty()) { logger.log(Level.FINE, "Found {0} syntax errors", errors.size()); } }
Example #27
Source File: JavaxFacesBeanIsGonnaBeDeprecated.java From netbeans with Apache License 2.0 | 5 votes |
@TriggerTreeKind(Tree.Kind.CLASS) public static Collection<ErrorDescription> run(HintContext hintContext) { List<ErrorDescription> problems = new ArrayList<>(); final JsfHintsContext ctx = JsfHintsUtils.getOrCacheContext(hintContext); if (ctx.getJsfVersion() == null || !ctx.getJsfVersion().isAtLeast(JSFVersion.JSF_2_2)) { return problems; } CompilationInfo info = hintContext.getInfo(); for (TypeElement typeElement : info.getTopLevelElements()) { for (AnnotationMirror annotationMirror : typeElement.getAnnotationMirrors()) { if (annotationMirror.getAnnotationType().toString().startsWith(JAVAX_FACES_BEAN)) { // it's javax.faces.bean annotation Tree tree = info.getTrees().getTree(typeElement, annotationMirror); List<Fix> fixes = getFixesForType(info, typeElement, annotationMirror); problems.add(JsfHintsUtils.createProblem( tree, info, Bundle.JavaxFacesBeanIsGonnaBeDeprecated_display_name(), Severity.HINT, fixes)); } } } return problems; }
Example #28
Source File: InjectionPointParameterAnalyzer.java From netbeans with Apache License 2.0 | 5 votes |
private void checkResult( DependencyInjectionResult res , ExecutableElement method , VariableElement element, WebBeansModel model, Result result ) { if ( res instanceof DependencyInjectionResult.Error ){ ResultKind kind = res.getKind(); Severity severity = Severity.WARNING; if ( kind == DependencyInjectionResult.ResultKind.DEFINITION_ERROR){ severity = Severity.ERROR; } String message = ((DependencyInjectionResult.Error)res).getMessage(); result.addNotification(severity, element , method , model, message); } }
Example #29
Source File: AnnotationHolderTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testComputeHighlightsTwoLayers3() throws Exception { ErrorDescription ed1 = ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, "1", file, 3, 5); ErrorDescription ed2 = ErrorDescriptionFactory.createErrorDescription(Severity.WARNING, "2", file, 4, 7); List<ErrorDescription> errors = Arrays.asList(ed1, ed2); final OffsetsBag bag = AnnotationHolder.computeHighlights(doc, errors); assertHighlights("",bag, new int[] {3, 5, /*6*/5, 7}, new AttributeSet[] {AnnotationHolder.getColoring(ERROR, doc), AnnotationHolder.getColoring(WARNING, doc)}); }
Example #30
Source File: Tiny.java From netbeans with Apache License 2.0 | 5 votes |
@Hint(displayName = "#DN_org.netbeans.modules.java.hints.suggestions.Tiny.convertToDifferentBase", description = "#DESC_org.netbeans.modules.java.hints.suggestions.Tiny.convertToDifferentBase", category="suggestions", hintKind=Kind.ACTION, severity=Severity.HINT) @TriggerTreeKind({Tree.Kind.INT_LITERAL, Tree.Kind.LONG_LITERAL}) public static ErrorDescription convertToDifferentBase(HintContext ctx) { int start = (int) ctx.getInfo().getTrees().getSourcePositions().getStartPosition(ctx.getInfo().getCompilationUnit(), ctx.getPath().getLeaf()); int end = (int) ctx.getInfo().getTrees().getSourcePositions().getEndPosition(ctx.getInfo().getCompilationUnit(), ctx.getPath().getLeaf()); String code = ctx.getInfo().getText().substring(start, end); int currentRadix = 10; if (code.startsWith("0x") || code.startsWith("0X")) currentRadix = 16; else if (code.startsWith("0b") || code.startsWith("0B")) currentRadix = 2; else if (code.startsWith("0") || code.startsWith("0")) currentRadix = 8; List<Fix> fixes = new LinkedList<Fix>(); if (currentRadix != 16) { fixes.add(new ToDifferentRadixFixImpl(ctx.getInfo(), ctx.getPath(), "0x", 16).toEditorFix()); } if (currentRadix != 10) { fixes.add(new ToDifferentRadixFixImpl(ctx.getInfo(), ctx.getPath(), "", 10).toEditorFix()); } if (currentRadix != 8) { fixes.add(new ToDifferentRadixFixImpl(ctx.getInfo(), ctx.getPath(), "0", 8).toEditorFix()); } if (currentRadix != 2 && ctx.getInfo().getSourceVersion().compareTo(SourceVersion.RELEASE_7) >= 0) { fixes.add(new ToDifferentRadixFixImpl(ctx.getInfo(), ctx.getPath(), "0b", 2).toEditorFix()); } return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), NbBundle.getMessage(Tiny.class, "ERR_convertToDifferentBase"), fixes.toArray(new Fix[0])); }