use of org.talend.core.model.process.Problem.ProblemStatus in project tdi-studio-se by Talend.
the class Problems method computeCompilationUnit.
@SuppressWarnings("restriction")
private static List<Problem> computeCompilationUnit(IFile file, ProblemType type, Item item) throws CoreException {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
// FIXME, only for standard job first, also for JobLaunchShortcut.launch
if (itemType == null || !itemType.equals(ERepositoryObjectType.PROCESS)) {
return Collections.emptyList();
}
List<Problem> compilProblems = new ArrayList<Problem>();
final ICompilationUnit unit = JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(new FileEditorInput(file), false);
if (unit != null) {
CompilationUnit ast = unit.reconcile(ASTProvider.SHARED_AST_LEVEL, ICompilationUnit.FORCE_PROBLEM_DETECTION, null, null);
IProblem[] problems = ast.getProblems();
if (problems != null) {
for (IProblem p : problems) {
String[] arguments = p.getArguments();
int id = p.getID();
String message = p.getMessage();
int sourceLineNumber = p.getSourceLineNumber();
int sourceStart = p.getSourceStart();
int sourceEnd = p.getSourceEnd();
String uniName = null;
IPath location = file.getLocation();
if (location != null) {
String path = location.toString();
uniName = setErrorMark(path, sourceLineNumber);
}
ProblemStatus status = ProblemStatus.WARNING;
if (p.isError()) {
status = ProblemStatus.ERROR;
}
TalendProblem tp = new TalendProblem(status, item, null, message, sourceLineNumber, uniName, sourceStart, sourceEnd, type);
compilProblems.add(tp);
}
}
}
return compilProblems;
}
use of org.talend.core.model.process.Problem.ProblemStatus in project tdi-studio-se by Talend.
the class Problems method addRoutineFile.
/**
*
* ggu Comment method "addRoutineFile".
*
*
*/
public static List<Information> addRoutineFile(IFile file, ProblemType type, String label, String version, boolean... fromJob) {
if (file == null || !file.exists()) {
return Collections.emptyList();
}
String uniName = null;
List<Information> informations = new ArrayList<Information>();
try {
IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
Problems.clearAllComliationError(label);
for (IMarker marker : markers) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
String message = (String) marker.getAttribute(IMarker.MESSAGE);
Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
if (lineNr != null && message != null && severity != null && start != null && end != null) {
Information information = PropertiesFactory.eINSTANCE.createInformation();
information.setText(message);
informations.add(information);
ProblemStatus status = null;
switch(severity) {
case IMarker.SEVERITY_ERROR:
status = ProblemStatus.ERROR;
information.setLevel(InformationLevel.ERROR_LITERAL);
IPath location = file.getLocation();
if (location != null) {
String path = location.toString();
uniName = setErrorMark(path, lineNr);
}
break;
case IMarker.SEVERITY_WARNING:
status = ProblemStatus.WARNING;
information.setLevel(InformationLevel.WARN_LITERAL);
break;
case IMarker.SEVERITY_INFO:
status = ProblemStatus.INFO;
information.setLevel(InformationLevel.INFO_LITERAL);
break;
default:
break;
}
if (status != null) {
if (status != ProblemStatus.ERROR) {
continue;
}
if ("".equals(uniName) || uniName == null) {
//$NON-NLS-1$
//$NON-NLS-1$
uniName = "uniName";
}
add(status, marker, label, message, lineNr, uniName, start, end, type, version);
}
}
}
if (fromJob.length > 0 && fromJob[0]) {
addErrorMark();
}
} catch (org.eclipse.core.runtime.CoreException e) {
ExceptionHandler.process(e);
}
return informations;
}
use of org.talend.core.model.process.Problem.ProblemStatus in project tdi-studio-se by Talend.
the class Problems method addJobRoutineFile.
public static List<Information> addJobRoutineFile(IFile file, ProblemType type, Item item, boolean... fromJob) {
if (file == null || !file.exists()) {
return Collections.emptyList();
}
String uniName = null;
List<Information> informations = new ArrayList<Information>();
try {
Set<IMarker> fullMarker = new HashSet<IMarker>();
IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
if (markers != null) {
fullMarker.addAll(Arrays.asList(markers));
}
// remove old
Problems.clearAllComliationError(item.getProperty().getLabel());
for (IMarker marker : fullMarker) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
String message = (String) marker.getAttribute(IMarker.MESSAGE);
Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
if (lineNr != null && message != null && severity != null && start != null && end != null) {
Information information = PropertiesFactory.eINSTANCE.createInformation();
information.setText(message);
informations.add(information);
ProblemStatus status = null;
switch(severity) {
case IMarker.SEVERITY_ERROR:
status = ProblemStatus.ERROR;
information.setLevel(InformationLevel.ERROR_LITERAL);
IPath location = file.getLocation();
if (location != null) {
String path = location.toString();
uniName = setErrorMark(path, lineNr);
}
break;
case IMarker.SEVERITY_WARNING:
status = ProblemStatus.WARNING;
information.setLevel(InformationLevel.WARN_LITERAL);
break;
case IMarker.SEVERITY_INFO:
status = ProblemStatus.INFO;
information.setLevel(InformationLevel.INFO_LITERAL);
break;
default:
break;
}
if (status != null) {
if (status != ProblemStatus.ERROR) {
continue;
}
if ("".equals(uniName) || uniName == null) {
//$NON-NLS-1$
//$NON-NLS-1$
uniName = "uniName";
}
add(status, marker, item, message, lineNr, uniName, start, end, type);
}
}
}
// TalendProcessJavaProject.buildModules for buildWholeCodeProject (about line 324)
if (!buildWholeProject) {
addAll(computeCompilationUnit(file, type, item));
}
if (fromJob.length > 0 && fromJob[0]) {
addErrorMark();
}
} catch (org.eclipse.core.runtime.CoreException e) {
ExceptionHandler.process(e);
}
return informations;
}
use of org.talend.core.model.process.Problem.ProblemStatus in project tdi-studio-se by Talend.
the class ProblemsManager method checkProblemsForTableEntry.
public boolean checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData, boolean checkLookupProblem) {
if (!mapperManager.isCheckSyntaxEnabled()) {
return false;
}
if (forceRefreshData) {
mapperManager.getAbstractMapComponent().restoreMapperModelFromInternalData();
checkProblems();
}
String expression = tableEntry.getExpression();
List<Problem> problems = null;
if (expression == null || EMPTY_STRING.equals(expression.trim())) {
problems = null;
} else {
// System.out.println("check=" + expression);
if (codeLanguage == ECodeLanguage.PERL) {
problems = codeChecker.checkProblemsForExpression(expression);
} else if (codeLanguage == ECodeLanguage.JAVA) {
PROBLEM_KEY_FIELD problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN;
String entryName = tableEntry.getName();
if (tableEntry instanceof FilterTableEntry || tableEntry instanceof ExpressionFilterEntry) {
problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.FILTER;
entryName = null;
}
problems = checkJavaProblemsForEntry(problemKeyField, tableEntry.getParent().getName(), entryName, forceRefreshData);
}
if (problems != null) {
for (Iterator iter = problems.iterator(); iter.hasNext(); ) {
Problem problem = (Problem) iter.next();
ProblemStatus status = problem.getStatus();
if (status != ProblemStatus.ERROR) {
iter.remove();
}
}
} else {
problems = null;
}
}
if (problems != null) {
if (problems.size() == 0) {
tableEntry.setProblems(null);
} else {
hasProblems = true;
tableEntry.setProblems(problems);
}
} else {
tableEntry.setProblems(problems);
}
// check problem for M/R process , only needed if modify lookup expressions
if (checkLookupProblem) {
checkLookupExpressionProblem();
}
// no need to update again
TableViewerCreator tableViewerCreator = mapperManager.retrieveTableViewerCreator(tableEntry);
DataMapTableView retrieveDataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreator);
return problems != null;
}
Aggregations