Java Code Examples for org.eclipse.lsp4j.DiagnosticSeverity#Warning

The following examples show how to use org.eclipse.lsp4j.DiagnosticSeverity#Warning . 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: XMLValidationSettings.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns the <code>noGrammar</code> severity according the given settings and
 * {@link DiagnosticSeverity#Hint} otherwise.
 * 
 * @param settings the settings
 * @return the <code>noGrammar</code> severity according the given settings and
 *         {@link DiagnosticSeverity#Hint} otherwise.
 */
public static DiagnosticSeverity getNoGrammarSeverity(ContentModelSettings settings) {
	DiagnosticSeverity defaultSeverity = DiagnosticSeverity.Hint;
	if (settings == null || settings.getValidation() == null) {
		return defaultSeverity;
	}
	XMLValidationSettings problems = settings.getValidation();
	String noGrammar = problems.getNoGrammar();
	if ("ignore".equalsIgnoreCase(noGrammar)) {
		// Ignore "noGrammar", return null.
		return null;
	} else if ("info".equalsIgnoreCase(noGrammar)) {
		return DiagnosticSeverity.Information;
	} else if ("warning".equalsIgnoreCase(noGrammar)) {
		return DiagnosticSeverity.Warning;
	} else if ("error".equalsIgnoreCase(noGrammar)) {
		return DiagnosticSeverity.Error;
	}
	return defaultSeverity;
}
 
Example 2
Source File: AbstractLSPErrorReporter.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the LSP diagnostic severity according the SAX severity.
 * 
 * @param severity the SAX severity
 * @return the LSP diagnostic severity according the SAX severity.
 */
private static DiagnosticSeverity toLSPSeverity(int severity) {
	switch (severity) {
	case SEVERITY_WARNING:
		return DiagnosticSeverity.Warning;
	default:
		return DiagnosticSeverity.Error;
	}
}
 
Example 3
Source File: RdfLintLanguageServer.java    From rdflint with MIT License 5 votes vote down vote up
private DiagnosticSeverity convertLintProblemLevel2DiagnosticSeverity(ErrorLevel lv) {
  DiagnosticSeverity severity;
  switch (lv) {
    case ERROR:
      severity = DiagnosticSeverity.Error;
      break;
    case WARN:
      severity = DiagnosticSeverity.Warning;
      break;
    default:
      severity = DiagnosticSeverity.Information;
  }
  return severity;
}
 
Example 4
Source File: DiagnosticIssueConverter.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Convert the {@link Severity} to a lsp {@link DiagnosticSeverity}.
 *
 * Defaults to severity {@link DiagnosticSeverity#Hint}.
 */
protected DiagnosticSeverity toSeverity(Severity severity) {
	switch (severity) {
	case ERROR:
		return DiagnosticSeverity.Error;
	case IGNORE:
		return DiagnosticSeverity.Hint;
	case INFO:
		return DiagnosticSeverity.Information;
	case WARNING:
		return DiagnosticSeverity.Warning;
	default:
		return DiagnosticSeverity.Hint;
	}
}
 
Example 5
Source File: BaseDiagnosticsHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static DiagnosticSeverity convertSeverity(IProblem problem) {
	if (problem.isError()) {
		return DiagnosticSeverity.Error;
	}
	if (problem.isWarning() && (problem.getID() != IProblem.Task)) {
		return DiagnosticSeverity.Warning;
	}
	return DiagnosticSeverity.Information;
}
 
Example 6
Source File: WorkspaceDiagnosticsHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param attribute
 * @return
 */
private static DiagnosticSeverity convertSeverity(int severity) {
	if (severity == IMarker.SEVERITY_ERROR) {
		return DiagnosticSeverity.Error;
	}
	if (severity == IMarker.SEVERITY_WARNING) {
		return DiagnosticSeverity.Warning;
	}
	return DiagnosticSeverity.Information;
}
 
Example 7
Source File: LanguageServerCompilerUtils.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a compiler problem to a language server severity.
 */
public static DiagnosticSeverity getDiagnosticSeverityFromCompilerProblem(ICompilerProblem problem)
{
    if (problem instanceof SyntaxFallbackProblem)
    {
        return DiagnosticSeverity.Information;
    }
    if (problem instanceof UnusedImportProblem || problem instanceof DisabledConfigConditionBlockProblem)
    {
        return DiagnosticSeverity.Hint;
    }

    CompilerProblemCategorizer categorizer = new CompilerProblemCategorizer(null);
    CompilerProblemSeverity severity = categorizer.getProblemSeverity(problem);
    switch (severity)
    {
        case ERROR:
        {
            return DiagnosticSeverity.Error;
        }
        case WARNING:
        {
            return DiagnosticSeverity.Warning;
        }
        default:
        {
            return DiagnosticSeverity.Information;
        }
    }
}
 
Example 8
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Convert the severity to a lsp {@link DiagnosticSeverity}.
 *
 * Defaults to severity {@link DiagnosticSeverity#Hint hint}.
 */
protected DiagnosticSeverity toDiagnosticSeverity(Severity severity) {
	switch (severity) {
	case ERROR:
		return DiagnosticSeverity.Error;
	case IGNORE:
		return DiagnosticSeverity.Hint;
	case INFO:
		return DiagnosticSeverity.Information;
	case WARNING:
		return DiagnosticSeverity.Warning;
	default:
		return DiagnosticSeverity.Hint;
	}
}
 
Example 9
Source File: SelectFunction.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
    @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) // TODO refactor
    protected void parseAndValidate() {
        // Find starting index
        int selectClauselastIndex = getSelectClause().getLastTknIndex();

        int startIndex = getSelectClause().getFirstTknIndex() + 1;
        if (getSelectClause().isAll() || getSelectClause().isDistinct()) {
            startIndex++;
        }

        // check for previous table elements and reset the startIndex
        int nSelectColumns = getSelectClause().getSelectColumns().length;
        if (nSelectColumns > 0) {
            startIndex = getSelectClause().getSelectColumns()[nSelectColumns - 1].getLastTknIndex() + 1;
        }

        int currentTknIndex = startIndex;
        boolean columnEnded = startIndex > selectClauselastIndex;

        while (!columnEnded) {
            // LOOKING FOR : Table1 AS t1
            Token tkn = this.getTokens().get(currentTknIndex);
            if (currentTknIndex > selectClauselastIndex) {
                columnEnded = true;
                setLastTknIndex(selectClauselastIndex - 1);
            } else {
                if (tkn.kind == SQLParserConstants.ID) {
                    this.functionNameToken = tkn;
                    if (getFirstTknIndex() == 0) {
                        setFirstTknIndex(getTokenIndex(tkn));
                    }
                    currentTknIndex++;
                }
                // Check for alias (AS) token
                if (currentTknIndex < selectClauselastIndex) {
                    tkn = this.getTokens().get(currentTknIndex);
                    if (tkn.kind == SQLParserConstants.LPAREN) {
//                      int nParamTkns = handleFunctionParameters(tkn, currentTknIndex, selectClauselastIndex);
                        // Parse until we find a RPAREN or we hit the selectClauselastIndex
                        List<Token> functionParameterTkns = getBracketedTokens(getTokens(), currentTknIndex,
                                SQLParserConstants.LPAREN, SQLParserConstants.RPAREN);
                        // 1) check last index so it isn't past the SELECT clause
                        int nTkns = functionParameterTkns.size();
                        if (getTokenIndex(functionParameterTkns.get(nTkns - 1)) < selectClauselastIndex) {
                            // now count the parameters
                            for (Token paramTkn : functionParameterTkns) {
                                if (paramTkn.kind == SQLParserConstants.ID) {
                                    if (FunctionHelper.getInstance().isFunctionName(paramTkn.image)) {
                                        Position startPosition = new Position(paramTkn.beginLine, paramTkn.beginColumn);
                                        Position endPosition = new Position(paramTkn.endLine, paramTkn.endColumn + 1);
                                        DdlAnalyzerException exception = new DdlAnalyzerException(
                                                DiagnosticSeverity.Warning, "NESTED Functions are not yet supported",
                                                new Range(startPosition, endPosition));

                                        this.analyzer.addException(exception);
                                    } else {
                                        this.parameters.add(paramTkn.image);
                                    }
                                } else if (paramTkn.kind == SQLParserConstants.UNSIGNEDINTEGER) {
                                    this.parameters.add(paramTkn.image);
                                }
                            }
                        }
                        currentTknIndex = currentTknIndex + nTkns; // nParamTkns; // RPARENS token
                        tkn = this.getTokens().get(currentTknIndex);
                    }
                    if (tkn.kind == SQLParserConstants.AS) {
                        currentTknIndex++;
                        tkn = this.getTokens().get(currentTknIndex);
                        if (getTokenIndex(tkn) <= selectClauselastIndex) {
                            setAliasNameToken(tkn);
                        }
                        if (currentTknIndex < selectClauselastIndex) {
                            currentTknIndex++;
                            tkn = this.getTokens().get(currentTknIndex);
                            if (tkn.kind == SQLParserConstants.COMMA) {
                                // Since there is a comma, another TableSymbol is expected
                                setLastTknIndex(getTokenIndex(tkn));
                                columnEnded = true;
                            } else {
                                setLastTknIndex(currentTknIndex - 1);
                                columnEnded = true;
                            }
                        } else {
                            setLastTknIndex(getTokenIndex(tkn));
                            columnEnded = true;
                        }
                    } else if (tkn.kind == SQLParserConstants.COMMA) {
                        // Since there is a comma, another TableSymbol is expected
                        setLastTknIndex(getTokenIndex(tkn));
                        columnEnded = true;
                    }
                } else {
                    setLastTknIndex(getTokenIndex(tkn));
                    columnEnded = true;
                }
            }
            currentTknIndex++;
        }
    }