[Pydev-cvs] org.python.pydev/src/org/python/pydev/builder/pylint PyLintPrefPage.java, 1.18, 1.19 Py
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:33
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/builder/pylint Modified Files: PyLintPrefPage.java PyLintVisitor.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: PyLintVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint/PyLintVisitor.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** PyLintVisitor.java 21 May 2008 01:38:09 -0000 1.41 --- PyLintVisitor.java 28 Sep 2008 12:45:49 -0000 1.42 *************** *** 94,133 **** try { if(canPassPyLint()){ ! ! IOConsoleOutputStream out=null; ! try { ! MessageConsole console = getConsole(); ! if(console != null){ ! out = console.newOutputStream(); ! } ! } catch (MalformedURLException e3) { ! throw new RuntimeException(e3); ! } ! passPyLint(resource, out); ! ! new Job("Adding markers"){ ! ! protected IStatus run(IProgressMonitor monitor) { ! ! ArrayList<MarkerInfo> lst = new ArrayList<PydevMarkerUtils.MarkerInfo>(); ! ! for (Iterator<Object[]> iter = markers.iterator(); iter.hasNext();) { ! Object[] el = iter.next(); ! ! String tok = (String) el[0]; ! int priority = ((Integer)el[1]).intValue(); ! String id = (String) el[2]; ! int line = ((Integer)el[3]).intValue(); ! ! lst.add(new PydevMarkerUtils.MarkerInfo(document, "ID:" + id + " " + tok, PYLINT_PROBLEM_MARKER, priority, false, false, line, 0, line, 0, null)); ! } ! ! PydevMarkerUtils.replaceMarkers(lst, resource, PYLINT_PROBLEM_MARKER); ! ! return PydevPlugin.makeStatus(Status.OK, "", null); ! } ! }.schedule(); } --- 94,133 ---- try { if(canPassPyLint()){ ! ! IOConsoleOutputStream out=null; ! try { ! MessageConsole console = getConsole(); ! if(console != null){ ! out = console.newOutputStream(); ! } ! } catch (MalformedURLException e3) { ! throw new RuntimeException(e3); ! } ! passPyLint(resource, out); ! ! new Job("Adding markers"){ ! ! protected IStatus run(IProgressMonitor monitor) { ! ! ArrayList<MarkerInfo> lst = new ArrayList<PydevMarkerUtils.MarkerInfo>(); ! ! for (Iterator<Object[]> iter = markers.iterator(); iter.hasNext();) { ! Object[] el = iter.next(); ! ! String tok = (String) el[0]; ! int priority = ((Integer)el[1]).intValue(); ! String id = (String) el[2]; ! int line = ((Integer)el[3]).intValue(); ! ! lst.add(new PydevMarkerUtils.MarkerInfo(document, "ID:" + id + " " + tok, PYLINT_PROBLEM_MARKER, priority, false, false, line, 0, line, 0, null)); ! } ! ! PydevMarkerUtils.replaceMarkers(lst, resource, PYLINT_PROBLEM_MARKER); ! ! return PydevPlugin.makeStatus(Status.OK, "", null); ! } ! }.schedule(); } *************** *** 148,162 **** } ! private MessageConsole getConsole() throws MalformedURLException { ! if(PyLintPrefPage.useConsole()){ ! if (fConsole == null){ ! fConsole = new MessageConsole("", PydevPlugin.getImageCache().getDescriptor(UIConstants.PY_ICON)); ! ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{fConsole}); ! } ! }else{ ! return null; ! } ! return fConsole; ! } --- 148,162 ---- } ! private MessageConsole getConsole() throws MalformedURLException { ! if(PyLintPrefPage.useConsole()){ ! if (fConsole == null){ ! fConsole = new MessageConsole("", PydevPlugin.getImageCache().getDescriptor(UIConstants.PY_ICON)); ! ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{fConsole}); ! } ! }else{ ! return null; ! } ! return fConsole; ! } *************** *** 198,209 **** String scriptToExe = REF.getFileAbsolutePath(script); ! String[] paramsToExe = list.toArray(new String[0]); ! write("Pylint: Executing command line:'", out, scriptToExe, paramsToExe, "'"); ! ! Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutputFromPythonScript(scriptToExe, paramsToExe, arg.getParentFile(), project); ! write("Pylint: The stdout of the command line is: "+outTup.o1, out); ! write("Pylint: The stderr of the command line is: "+outTup.o2, out); ! ! String output = outTup.o1; StringTokenizer tokenizer = new StringTokenizer(output, "\r\n"); --- 198,209 ---- String scriptToExe = REF.getFileAbsolutePath(script); ! String[] paramsToExe = list.toArray(new String[0]); ! write("Pylint: Executing command line:'", out, scriptToExe, paramsToExe, "'"); ! ! Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutputFromPythonScript(scriptToExe, paramsToExe, arg.getParentFile(), project); ! write("Pylint: The stdout of the command line is: "+outTup.o1, out); ! write("Pylint: The stderr of the command line is: "+outTup.o2, out); ! ! String output = outTup.o1; StringTokenizer tokenizer = new StringTokenizer(output, "\r\n"); *************** *** 228,233 **** } if(outTup.o2.indexOf("Traceback (most recent call last):") != -1){ ! PydevPlugin.log(new RuntimeException("PyLint ERROR: \n"+outTup.o2)); ! return; } while(tokenizer.hasMoreTokens()){ --- 228,233 ---- } if(outTup.o2.indexOf("Traceback (most recent call last):") != -1){ ! PydevPlugin.log(new RuntimeException("PyLint ERROR: \n"+outTup.o2)); ! return; } while(tokenizer.hasMoreTokens()){ *************** *** 244,275 **** if(indexOfDoublePoints != -1){ ! if(tok.startsWith("C")&& useC){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = cSeverity; ! } ! else if(tok.startsWith("R") && useR ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = rSeverity; ! } ! else if(tok.startsWith("W") && useW ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = wSeverity; ! } ! else if(tok.startsWith("E") && useE ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = eSeverity; ! } ! else if(tok.startsWith("F") && useF ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = fSeverity; ! }else{ ! continue; ! } ! }else{ continue; --- 244,275 ---- if(indexOfDoublePoints != -1){ ! if(tok.startsWith("C")&& useC){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = cSeverity; ! } ! else if(tok.startsWith("R") && useR ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = rSeverity; ! } ! else if(tok.startsWith("W") && useW ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = wSeverity; ! } ! else if(tok.startsWith("E") && useE ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = eSeverity; ! } ! else if(tok.startsWith("F") && useF ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = fSeverity; ! }else{ ! continue; ! } ! }else{ continue; *************** *** 329,333 **** public void visitChangedResource(IResource resource, IDocument document, IProgressMonitor monitor) { if(document == null){ ! return; } if(PyLintPrefPage.usePyLint() == false){ --- 329,333 ---- public void visitChangedResource(IResource resource, IDocument document, IProgressMonitor monitor) { if(document == null){ ! return; } if(PyLintPrefPage.usePyLint() == false){ *************** *** 362,389 **** public static void write(String cmdLineToExe, IOConsoleOutputStream out, Object ... args) { ! try { ! if(fConsole != null && out != null){ ! synchronized(fConsole){ ! if(args != null){ ! for (Object arg : args) { ! if(arg instanceof String){ ! cmdLineToExe += " "+arg; ! }else if(arg instanceof String[]){ String[] strings = (String[]) arg; for (String string : strings) { cmdLineToExe += " "+string; } ! } } ! } ! out.write(cmdLineToExe); ! } ! } ! } catch (IOException e) { ! PydevPlugin.log(e); ! } ! } ! /** * @see org.python.pydev.builder.PyDevBuilderVisitor#visitRemovedResource(org.eclipse.core.resources.IResource, org.eclipse.jface.text.IDocument) */ --- 362,389 ---- public static void write(String cmdLineToExe, IOConsoleOutputStream out, Object ... args) { ! try { ! if(fConsole != null && out != null){ ! synchronized(fConsole){ ! if(args != null){ ! for (Object arg : args) { ! if(arg instanceof String){ ! cmdLineToExe += " "+arg; ! }else if(arg instanceof String[]){ String[] strings = (String[]) arg; for (String string : strings) { cmdLineToExe += " "+string; } ! } } ! } ! out.write(cmdLineToExe); ! } ! } ! } catch (IOException e) { ! PydevPlugin.log(e); ! } ! } ! /** * @see org.python.pydev.builder.PyDevBuilderVisitor#visitRemovedResource(org.eclipse.core.resources.IResource, org.eclipse.jface.text.IDocument) */ Index: PyLintPrefPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint/PyLintPrefPage.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyLintPrefPage.java 23 Jun 2007 12:07:09 -0000 1.18 --- PyLintPrefPage.java 28 Sep 2008 12:45:49 -0000 1.19 *************** *** 34,49 **** public class PyLintPrefPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { ! public static final String PYLINT_FILE_LOCATION = "PYLINT_FILE_LOCATION"; ! public static final String USE_PYLINT = "USE_PYLINT"; ! public static final boolean DEFAULT_USE_PYLINT = false; ! ! public static final int SEVERITY_IGNORE = -1; ! ! public static final int COLS = 4; ! ! ! public static final String[][] LABEL_AND_VALUE = new String[][]{ {"Error" , String.valueOf(IMarker.SEVERITY_ERROR)}, {"Warning", String.valueOf(IMarker.SEVERITY_WARNING)}, --- 34,49 ---- public class PyLintPrefPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { ! public static final String PYLINT_FILE_LOCATION = "PYLINT_FILE_LOCATION"; ! public static final String USE_PYLINT = "USE_PYLINT"; ! public static final boolean DEFAULT_USE_PYLINT = false; ! ! public static final int SEVERITY_IGNORE = -1; ! ! public static final int COLS = 4; ! ! ! public static final String[][] LABEL_AND_VALUE = new String[][]{ {"Error" , String.valueOf(IMarker.SEVERITY_ERROR)}, {"Warning", String.valueOf(IMarker.SEVERITY_WARNING)}, *************** *** 53,276 **** ! ! // errors ! public static final String SEVERITY_ERRORS = "SEVERITY_ERRORS"; ! ! public static final int DEFAULT_SEVERITY_ERRORS = IMarker.SEVERITY_ERROR; ! ! //warnings ! public static final String SEVERITY_WARNINGS = "SEVERITY_WARNINGS"; ! ! public static final int DEFAULT_SEVERITY_WARNINGS = IMarker.SEVERITY_WARNING; ! //fatal ! public static final String SEVERITY_FATAL = "SEVERITY_FATAL"; ! ! public static final int DEFAULT_SEVERITY_FATAL = IMarker.SEVERITY_ERROR; ! ! //coding std ! public static final String SEVERITY_CODING_STANDARD = "SEVERITY_CODING_STANDARD"; ! ! public static final int DEFAULT_SEVERITY_CODING_STANDARD = SEVERITY_IGNORE; ! ! //refactor ! public static final String SEVERITY_REFACTOR = "SEVERITY_REFACTOR"; ! ! public static final int DEFAULT_SEVERITY_REFACTOR = SEVERITY_IGNORE; ! ! //console ! public static final String USE_CONSOLE = "USE_CONSOLE"; ! public static final boolean DEFAULT_USE_CONSOLE = true; ! ! //args ! public static final String PYLINT_ARGS = "PYLINT_ARGS"; ! public static final String DEFAULT_PYLINT_ARGS = ""; ! ! //delta ! public static final String MAX_PYLINT_DELTA = "MAX_PYLINT_DELTA"; ! public static final int DEFAULT_MAX_PYLINT_DELTA = 4; ! public PyLintPrefPage() { ! super(FLAT); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Pylint"); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() ! */ ! protected void createFieldEditors() { ! final Composite p = getFieldEditorParent(); ! addField(new BooleanFieldEditor(USE_PYLINT, "Use pylint?", p)); ! addField(new BooleanFieldEditor(USE_CONSOLE, "Redirect Pylint output to console?", p)); ! addField(new IntegerFieldEditor(MAX_PYLINT_DELTA, "Max simultaneous processes for PyLint?", p)); ! FileFieldEditor fileField = new FileFieldEditor(PYLINT_FILE_LOCATION, "Location of pylint (lint.py):", true, p); ! addField(fileField); ! addField(new RadioGroupFieldEditor(SEVERITY_FATAL, "FATAL Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_ERRORS, "ERRORS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_WARNINGS, "WARNINGS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_CODING_STANDARD, "CONVENTIONS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_REFACTOR, "REFACTOR Severity", COLS, LABEL_AND_VALUE, p, true)); ! CustomizableFieldEditor stringFieldEditor = new CustomizableFieldEditor(PYLINT_ARGS, "Arguments to pass to pylint (customize its output).\n" ! + "The --include-ids=y is always included and does not appear here..", p); ! addField(stringFieldEditor); ! String w = ""; ! Button button = new Button(p, SWT.NONE); ! button.addSelectionListener(new SelectionListener(){ ! public void widgetSelected(SelectionEvent e) { ! final String w = "\n\nTo ignore some warning on a line in a file, you can put the comment: \n" + ! "#IGNORE:ID, so that the id is the warning that you want to ignore. \n" + ! "E.g.: if you have the code:\n\n" + ! "from foo import * #IGNORE:W0401\n\n" + ! "The wildcard import will be ignored.\n\n" + ! "NOTE:for warnings to appear in the problems view, you have\n" + ! "to set your filter to accept the org.python.pydev.pylintproblem type!\n\n" + ! "NOTE2: Make sure that your file is a valid module in the PYTHONPATH, because\n" + ! "pylint doesn't analyze the file itself, but the module itself (you should\n" + ! "be able to import it from python without giving the file path)."; ! ! MessageDialog.openInformation(p.getShell(), "Help", w); ! } ! public void widgetDefaultSelected(SelectionEvent e) { ! } ! ! }); ! button.setText("Click for help (ignoring errors and troubleshooting)"); ! GridData d = new GridData(); ! d.horizontalAlignment = GridData.FILL; ! d.grabExcessHorizontalSpace = true; ! button.setLayoutData(d); ! ! FieldEditor fe = new LabelFieldEditor("Help", w, p); ! addField(fe); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! /** ! * @return ! */ ! public static String getPyLintLocation() { ! return PydevPrefs.getPreferences().getString(PYLINT_FILE_LOCATION); ! } ! private static boolean communicatedOnce = false; ! /** ! * should we use py lint? ! * ! * @return ! */ ! public static boolean usePyLint() { ! boolean b = PydevPrefs.getPreferences().getBoolean(USE_PYLINT); ! if (!isPylintConfigured(PyLintPrefPage.getPyLintLocation())) { ! if (b && !communicatedOnce) { ! communicatedOnce = true; ! PydevPlugin.log("Unable to use pylint because it is not properly configured."); ! } ! return false; ! } ! return b; ! } ! /** ! * Checks if location of pylint is properly configured. ! */ ! public static boolean isPylintConfigured(String pylintLocation) { ! File pylint = new File(pylintLocation); ! if (!pylint.exists() && pylint.isFile()) { ! return false; ! } ! return true; ! } ! public static boolean useErrors() { ! return eSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useWarnings() { ! return wSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useFatal() { ! return fSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useCodingStandard() { ! return cSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useRefactorTips() { ! return rSeverity() != SEVERITY_IGNORE; ! } ! ! ! public static boolean useConsole() { ! return PydevPrefs.getPreferences().getBoolean(USE_CONSOLE); ! } ! public static String getPylintArgs() { ! return PydevPrefs.getPreferences().getString(PYLINT_ARGS); ! } ! public static int getMaxPyLintDelta() { ! return PydevPrefs.getPreferences().getInt(MAX_PYLINT_DELTA); ! } ! ! ! public static int wSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_WARNINGS); ! } ! public static int eSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_ERRORS); ! } ! public static int fSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_FATAL); ! } ! public static int cSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_CODING_STANDARD); ! } ! public static int rSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_REFACTOR); ! } } \ No newline at end of file --- 53,276 ---- ! ! // errors ! public static final String SEVERITY_ERRORS = "SEVERITY_ERRORS"; ! ! public static final int DEFAULT_SEVERITY_ERRORS = IMarker.SEVERITY_ERROR; ! ! //warnings ! public static final String SEVERITY_WARNINGS = "SEVERITY_WARNINGS"; ! ! public static final int DEFAULT_SEVERITY_WARNINGS = IMarker.SEVERITY_WARNING; ! //fatal ! public static final String SEVERITY_FATAL = "SEVERITY_FATAL"; ! ! public static final int DEFAULT_SEVERITY_FATAL = IMarker.SEVERITY_ERROR; ! ! //coding std ! public static final String SEVERITY_CODING_STANDARD = "SEVERITY_CODING_STANDARD"; ! ! public static final int DEFAULT_SEVERITY_CODING_STANDARD = SEVERITY_IGNORE; ! ! //refactor ! public static final String SEVERITY_REFACTOR = "SEVERITY_REFACTOR"; ! ! public static final int DEFAULT_SEVERITY_REFACTOR = SEVERITY_IGNORE; ! ! //console ! public static final String USE_CONSOLE = "USE_CONSOLE"; ! public static final boolean DEFAULT_USE_CONSOLE = true; ! ! //args ! public static final String PYLINT_ARGS = "PYLINT_ARGS"; ! public static final String DEFAULT_PYLINT_ARGS = ""; ! ! //delta ! public static final String MAX_PYLINT_DELTA = "MAX_PYLINT_DELTA"; ! public static final int DEFAULT_MAX_PYLINT_DELTA = 4; ! public PyLintPrefPage() { ! super(FLAT); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Pylint"); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() ! */ ! protected void createFieldEditors() { ! final Composite p = getFieldEditorParent(); ! addField(new BooleanFieldEditor(USE_PYLINT, "Use pylint?", p)); ! addField(new BooleanFieldEditor(USE_CONSOLE, "Redirect Pylint output to console?", p)); ! addField(new IntegerFieldEditor(MAX_PYLINT_DELTA, "Max simultaneous processes for PyLint?", p)); ! FileFieldEditor fileField = new FileFieldEditor(PYLINT_FILE_LOCATION, "Location of pylint (lint.py):", true, p); ! addField(fileField); ! addField(new RadioGroupFieldEditor(SEVERITY_FATAL, "FATAL Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_ERRORS, "ERRORS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_WARNINGS, "WARNINGS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_CODING_STANDARD, "CONVENTIONS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_REFACTOR, "REFACTOR Severity", COLS, LABEL_AND_VALUE, p, true)); ! CustomizableFieldEditor stringFieldEditor = new CustomizableFieldEditor(PYLINT_ARGS, "Arguments to pass to pylint (customize its output).\n" ! + "The --include-ids=y is always included and does not appear here..", p); ! addField(stringFieldEditor); ! String w = ""; ! Button button = new Button(p, SWT.NONE); ! button.addSelectionListener(new SelectionListener(){ ! public void widgetSelected(SelectionEvent e) { ! final String w = "\n\nTo ignore some warning on a line in a file, you can put the comment: \n" + ! "#IGNORE:ID, so that the id is the warning that you want to ignore. \n" + ! "E.g.: if you have the code:\n\n" + ! "from foo import * #IGNORE:W0401\n\n" + ! "The wildcard import will be ignored.\n\n" + ! "NOTE:for warnings to appear in the problems view, you have\n" + ! "to set your filter to accept the org.python.pydev.pylintproblem type!\n\n" + ! "NOTE2: Make sure that your file is a valid module in the PYTHONPATH, because\n" + ! "pylint doesn't analyze the file itself, but the module itself (you should\n" + ! "be able to import it from python without giving the file path)."; ! ! MessageDialog.openInformation(p.getShell(), "Help", w); ! } ! public void widgetDefaultSelected(SelectionEvent e) { ! } ! ! }); ! button.setText("Click for help (ignoring errors and troubleshooting)"); ! GridData d = new GridData(); ! d.horizontalAlignment = GridData.FILL; ! d.grabExcessHorizontalSpace = true; ! button.setLayoutData(d); ! ! FieldEditor fe = new LabelFieldEditor("Help", w, p); ! addField(fe); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! /** ! * @return ! */ ! public static String getPyLintLocation() { ! return PydevPrefs.getPreferences().getString(PYLINT_FILE_LOCATION); ! } ! private static boolean communicatedOnce = false; ! /** ! * should we use py lint? ! * ! * @return ! */ ! public static boolean usePyLint() { ! boolean b = PydevPrefs.getPreferences().getBoolean(USE_PYLINT); ! if (!isPylintConfigured(PyLintPrefPage.getPyLintLocation())) { ! if (b && !communicatedOnce) { ! communicatedOnce = true; ! PydevPlugin.log("Unable to use pylint because it is not properly configured."); ! } ! return false; ! } ! return b; ! } ! /** ! * Checks if location of pylint is properly configured. ! */ ! public static boolean isPylintConfigured(String pylintLocation) { ! File pylint = new File(pylintLocation); ! if (!pylint.exists() && pylint.isFile()) { ! return false; ! } ! return true; ! } ! public static boolean useErrors() { ! return eSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useWarnings() { ! return wSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useFatal() { ! return fSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useCodingStandard() { ! return cSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useRefactorTips() { ! return rSeverity() != SEVERITY_IGNORE; ! } ! ! ! public static boolean useConsole() { ! return PydevPrefs.getPreferences().getBoolean(USE_CONSOLE); ! } ! public static String getPylintArgs() { ! return PydevPrefs.getPreferences().getString(PYLINT_ARGS); ! } ! public static int getMaxPyLintDelta() { ! return PydevPrefs.getPreferences().getInt(MAX_PYLINT_DELTA); ! } ! ! ! public static int wSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_WARNINGS); ! } ! public static int eSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_ERRORS); ! } ! public static int fSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_FATAL); ! } ! public static int cSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_CODING_STANDARD); ! } ! public static int rSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_REFACTOR); ! } } \ No newline at end of file |