Changeset View
Changeset View
Standalone View
Standalone View
pythonlanguagesupport.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 149 | { | |||
---|---|---|---|---|---|
152 | autopep8.setDescription(i18n("Format source with the autopep8 formatter.")); | 152 | autopep8.setDescription(i18n("Format source with the autopep8 formatter.")); | ||
153 | autopep8.setOverrideSample("class klass:\n def method(arg1,arg2):\n a=3+5\n" | 153 | autopep8.setOverrideSample("class klass:\n def method(arg1,arg2):\n a=3+5\n" | ||
154 | "def function(arg,*vararg,**kwargs): return arg+kwarg[0]\nfunction(3, 5, 7)"); | 154 | "def function(arg,*vararg,**kwargs): return arg+kwarg[0]\nfunction(3, 5, 7)"); | ||
155 | using P = SourceFormatterStyle::MimeHighlightPair; | 155 | using P = SourceFormatterStyle::MimeHighlightPair; | ||
156 | autopep8.setMimeTypes(SourceFormatterStyle::MimeList{ P{"text/x-python", "Python"} }); | 156 | autopep8.setMimeTypes(SourceFormatterStyle::MimeList{ P{"text/x-python", "Python"} }); | ||
157 | QString autopep8path = QStandardPaths::findExecutable("autopep8"); | 157 | QString autopep8path = QStandardPaths::findExecutable("autopep8"); | ||
158 | if (autopep8path.isEmpty()) { | 158 | if (autopep8path.isEmpty()) { | ||
159 | // TODO: proper error handling/user notification | 159 | // TODO: proper error handling/user notification | ||
160 | qDebug() << "Could not find the autopep8 executable"; | 160 | qCDebug(KDEV_PYTHON) << "Could not find the autopep8 executable"; | ||
161 | autopep8path = "/usr/bin/autopep8"; | 161 | autopep8path = "/usr/bin/autopep8"; | ||
162 | } | 162 | } | ||
163 | autopep8.setContent(autopep8path + " -i $TMPFILE"); | 163 | autopep8.setContent(autopep8path + " -i $TMPFILE"); | ||
164 | 164 | | |||
165 | return SourceFormatterItemList{SourceFormatterStyleItem{"customscript", autopep8}}; | 165 | return SourceFormatterItemList{SourceFormatterStyleItem{"customscript", autopep8}}; | ||
166 | } | 166 | } | ||
167 | 167 | | |||
168 | KDevelop::ICodeHighlighting* LanguageSupport::codeHighlighting() const | 168 | KDevelop::ICodeHighlighting* LanguageSupport::codeHighlighting() const | ||
Show All 9 Lines | |||||
178 | int LanguageSupport::suggestedReparseDelayForChange(KTextEditor::Document* doc, const KTextEditor::Range& changedRange, | 178 | int LanguageSupport::suggestedReparseDelayForChange(KTextEditor::Document* doc, const KTextEditor::Range& changedRange, | ||
179 | const QString& changedText, bool /*removal*/) const | 179 | const QString& changedText, bool /*removal*/) const | ||
180 | { | 180 | { | ||
181 | if ( changedRange.start().line() != changedRange.end().line() ) { | 181 | if ( changedRange.start().line() != changedRange.end().line() ) { | ||
182 | // instant update | 182 | // instant update | ||
183 | return 0; | 183 | return 0; | ||
184 | } | 184 | } | ||
185 | if ( std::all_of(changedText.begin(), changedText.end(), [](const QChar& c) { return c.isSpace(); }) ) { | 185 | if ( std::all_of(changedText.begin(), changedText.end(), [](const QChar& c) { return c.isSpace(); }) ) { | ||
186 | qDebug() << changedText << changedRange.end().column() << doc->lineLength(changedRange.end().line()); | 186 | qCDebug(KDEV_PYTHON) << changedText << changedRange.end().column() << doc->lineLength(changedRange.end().line()); | ||
187 | if ( changedRange.end().column()-1 == doc->lineLength(changedRange.end().line()) ) { | 187 | if ( changedRange.end().column()-1 == doc->lineLength(changedRange.end().line()) ) { | ||
188 | return ILanguageSupport::NoUpdateRequired; | 188 | return ILanguageSupport::NoUpdateRequired; | ||
189 | } | 189 | } | ||
190 | } | 190 | } | ||
191 | return ILanguageSupport::DefaultDelay; | 191 | return ILanguageSupport::DefaultDelay; | ||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | 194 | | |||
Show All 36 Lines |