Search in sources :

Example 36 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class DeprecatedMethodsMigrator method analyze.

@Override
public List<Problem> analyze(File file) {
    List<Problem> problems = new ArrayList<>();
    String fileExtension = new Path(file.getAbsolutePath()).getFileExtension();
    for (JSONArray deprecatedMethodsArray : _deprecatedMethods) {
        for (int j = 0; j < deprecatedMethodsArray.length(); j++) {
            _tempMethod = deprecatedMethodsArray.getJSONObject(j);
            List<SearchResult> searchResults = searchFile(file, createFileChecker(type, file, fileExtension));
            if (searchResults != null) {
                for (SearchResult searchResult : searchResults) {
                    int makerType = Problem.MARKER_ERROR;
                    if (_tempMethod.getString("deprecatedVersion").equals("7.0")) {
                        makerType = Problem.MARKER_WARNING;
                    }
                    problems.add(new Problem(_tempMethod.getString("javadoc"), _tempMethod.getString("javadoc"), fileExtension, "", file, searchResult.startLine, searchResult.startOffset, searchResult.endOffset, _tempMethod.getString("javadoc"), searchResult.autoCorrectContext, Problem.STATUS_NOT_RESOLVED, Problem.DEFAULT_MARKER_ID, makerType));
                }
            }
        }
    }
    return problems;
}
Also used : Path(org.eclipse.core.runtime.Path) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) Problem(com.liferay.blade.api.Problem) SearchResult(com.liferay.blade.api.SearchResult)

Example 37 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class FileProblemsUtil method newFileProblemsListFrom.

public static FileProblems[] newFileProblemsListFrom(Problem[] problems) {
    Map<File, FileProblems> fileProblemsMap = new HashMap<>();
    for (Problem problem : problems) {
        FileProblems fileProblem = fileProblemsMap.get(problem.getFile());
        if (fileProblem == null) {
            fileProblem = new FileProblems();
        }
        fileProblem.addProblem(problem);
        fileProblem.setFile(problem.getFile());
        fileProblemsMap.put(problem.getFile(), fileProblem);
    }
    return fileProblemsMap.values().toArray(new FileProblems[0]);
}
Also used : HashMap(java.util.HashMap) Problem(com.liferay.blade.api.Problem) File(java.io.File)

Example 38 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class FindBreakingChangesPage method _updateForm.

private void _updateForm(SelectionChangedEvent event) {
    final ISelection selection = event.getSelection();
    final Problem problem = MigrationUtil.getProblemFromSelection(selection);
    if (problem != null) {
        if (CoreUtil.isNullOrEmpty(problem.html)) {
            _browser.setText(_generateFormText(problem));
        } else {
            _browser.setText(problem.html);
        }
    } else {
        _browser.setUrl("about:blank");
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) Problem(com.liferay.blade.api.Problem)

Example 39 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class FindBreakingChangesPage method doubleClick.

@Override
public void doubleClick(DoubleClickEvent event) {
    if (event.getSelection() instanceof IStructuredSelection) {
        final IStructuredSelection ss = (IStructuredSelection) event.getSelection();
        Object element = ss.getFirstElement();
        if (element instanceof Problem) {
            MigrationUtil.openEditor((Problem) element);
        } else if (element instanceof FileProblems) {
            MigrationUtil.openEditor((FileProblems) element);
        }
    }
}
Also used : FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) Problem(com.liferay.blade.api.Problem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 40 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class MigrationProblemPreferencePage method _updateForm.

private void _updateForm(SelectionChangedEvent event) {
    final ISelection selection = event.getSelection();
    final Problem problem = MigrationUtil.getProblemFromSelection(selection);
    if (problem != null) {
        if (CoreUtil.isNullOrEmpty(problem.html)) {
            _browser.setText(_generateFormText(problem));
        } else {
            _browser.setText(problem.html);
        }
    } else {
        _browser.setUrl("about:blank");
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) Problem(com.liferay.blade.api.Problem)

Aggregations

Problem (com.liferay.blade.api.Problem)92 Test (org.junit.Test)58 File (java.io.File)42 FileMigrator (com.liferay.blade.api.FileMigrator)31 Migration (com.liferay.blade.api.Migration)29 NullProgressMonitor (com.liferay.blade.util.NullProgressMonitor)26 ArrayList (java.util.ArrayList)16 FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)9 IOException (java.io.IOException)9 ServiceReference (org.osgi.framework.ServiceReference)9 AutoMigrator (com.liferay.blade.api.AutoMigrator)8 IFile (org.eclipse.core.resources.IFile)8 List (java.util.List)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 AutoMigrateException (com.liferay.blade.api.AutoMigrateException)5 SearchResult (com.liferay.blade.api.SearchResult)5 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)5 MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)5 HashSet (java.util.HashSet)5 CoreException (org.eclipse.core.runtime.CoreException)5