Commit 9b80ea07 authored by Sven Brauch's avatar Sven Brauch

Fix all krazy issues which I think are worth fixing.

parent 9ef66b21
IGNORESUBS python-src,documentation_files,build
......@@ -34,4 +34,4 @@ target_link_libraries(kdev4pythoncompletion
install(TARGETS kdev4pythoncompletion DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
add_subdirectory(tests)
\ No newline at end of file
add_subdirectory(tests)
......@@ -5,21 +5,33 @@
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************
*/
#include <QProcess>
#include <QRegExp>
#include <KStandardDirs>
#include <KTextEditor/View>
#include "context.h"
#include "items/keyword.h"
#include "items/importfile.h"
#include "items/functiondeclaration.h"
#include "items/implementfunction.h"
#include "worker.h"
#include "helpers.h"
#include "duchain/pythoneditorintegrator.h"
#include "duchain/expressionvisitor.h"
#include "duchain/declarationbuilder.h"
#include "duchain/helpers.h"
#include "duchain/types/unsuretype.h"
#include "duchain/navigation/navigationwidget.h"
#include "parser/astbuilder.h"
#include <language/duchain/functiondeclaration.h>
#include <language/duchain/classdeclaration.h>
......@@ -35,21 +47,10 @@
#include <interfaces/idocumentcontroller.h>
#include <project/projectmodel.h>
#include "parser/astbuilder.h"
#include "duchain/pythoneditorintegrator.h"
#include "duchain/expressionvisitor.h"
#include "duchain/declarationbuilder.h"
#include "duchain/helpers.h"
#include "duchain/types/unsuretype.h"
#include "duchain/navigation/navigationwidget.h"
#include "worker.h"
#include "context.h"
#include "items/keyword.h"
#include "items/importfile.h"
#include "items/functiondeclaration.h"
#include "items/implementfunction.h"
#include "helpers.h"
#include <QProcess>
#include <QRegExp>
#include <KStandardDirs>
#include <KTextEditor/View>
using namespace KTextEditor;
using namespace KDevelop;
......@@ -73,7 +74,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::completionItems(bo
if ( m_operation != FunctionCallCompletion ) {
KeywordItem::Flags f = (KeywordItem::Flags) ( KeywordItem::ForceLineBeginning | KeywordItem::ImportantItem );
// TODO group those correctly so they appear at the top
if ( m_position.line == 0 && ( m_text.startsWith("#") || m_text.isEmpty() ) ) {
if ( m_position.line == 0 && ( m_text.startsWith('#') || m_text.isEmpty() ) ) {
QString i18ndescr = i18n("insert Shebang line");
resultingItems << CompletionTreeItemPointer(new KeywordItem(KDevelop::CodeCompletionContext::Ptr(this),
"#!/usr/bin/env python\n", i18ndescr, f));
......@@ -83,7 +84,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::completionItems(bo
"#!/usr/bin/env python3\n", i18ndescr, f));
}
// TODO fixme
else if ( m_position.line <= 1 && m_text.endsWith("#") ) {
else if ( m_position.line <= 1 && m_text.endsWith('#') ) {
resultingItems << CompletionTreeItemPointer(new KeywordItem(KDevelop::CodeCompletionContext::Ptr(this),
"# -*- Coding:utf-8 -*-\n\n", i18n("specify document encoding"), f));
}
......@@ -221,7 +222,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::completionItems(bo
QList<DeclarationDepthPair> declarations = c->allDeclarations(
CursorInRevision::invalid(), m_duContext->topContext(), false
);
foreach ( DeclarationDepthPair d, declarations ) {
foreach ( const DeclarationDepthPair& d, declarations ) {
if ( FunctionDeclaration* funcDecl = dynamic_cast<FunctionDeclaration*>(d.first) ) {
// python does not have overloads or similar, so comparing the function names is enough.
const IndexedString identifier = funcDecl->identifier().identifier();
......@@ -260,7 +261,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::completionItems(bo
QList<DeclarationDepthPair> validDeclarations;
ClassDeclaration* current = 0;
StructureType::Ptr type;
foreach ( DeclarationDepthPair d, m_duContext->topContext()->allDeclarations(CursorInRevision::invalid(), m_duContext->topContext()) ) {
foreach ( const DeclarationDepthPair d, m_duContext->topContext()->allDeclarations(CursorInRevision::invalid(), m_duContext->topContext()) ) {
if ( ( current = dynamic_cast<ClassDeclaration*>(d.first) ) ) {
if ( current->baseClassesSize() ) {
FOREACH_FUNCTION( const BaseClassInstance& base, current->baseClasses ) {
......@@ -287,7 +288,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::completionItems(bo
kDebug() << "InheritanceCompletion";
QList<DeclarationDepthPair> declarations = m_duContext->allDeclarations(m_position, m_duContext->topContext());
QList<DeclarationDepthPair> remainingDeclarations;
foreach ( DeclarationDepthPair d, declarations ) {
foreach ( const DeclarationDepthPair& d, declarations ) {
Declaration* r = Helper::resolveAliasDeclaration(d.first);
if ( r and r->identifier().identifier().str().contains("__kdevpythondocumentation_builtin") ) {
continue;
......@@ -336,7 +337,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::completionItems(bo
return QList<CompletionTreeItemPointer>();
}
QList<DeclarationDepthPair> declarations = m_duContext->allDeclarations(m_position, m_duContext->topContext());
foreach ( DeclarationDepthPair d, declarations ) {
foreach ( const DeclarationDepthPair& d, declarations ) {
if ( d.first and d.first->context()->type() == DUContext::Class ) {
declarations.removeAll(d);
}
......@@ -443,7 +444,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::getCompletionItems
// also, discard all magic functions from autocompletion
// TODO rework this, it's maybe not the most elegant solution possible
// TODO rework the magic functions thing, I want them sorted at the end of the list but KTE doesn't seem to allow that
foreach ( DeclarationDepthPair current, declarations ) {
foreach ( const DeclarationDepthPair& current, declarations ) {
if ( current.first->context() != builtinTopContext && ! current.first->identifier().identifier().str().startsWith("__") ) {
keepDeclarations.append(current);
}
......@@ -510,7 +511,7 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::findIncludeItems(I
// append all python files in the directory
foreach ( QFileInfo file, contents ) {
// TODO windows
if ( file.fileName().startsWith(".") ) {
if ( file.fileName().startsWith('.') ) {
continue;
}
kDebug() << " > CONTENT:" << file.absolutePath() << file.fileName();
......@@ -592,10 +593,10 @@ QList<CompletionTreeItemPointer> PythonCodeCompletionContext::includeItemsForSub
// Thus, we first generate a list of possible paths, then match them against those which actually exist
// and then gather all the items in those paths.
foreach (KUrl currentPath, searchPaths) {
foreach ( KUrl currentPath, searchPaths ) {
kDebug() << "Searching: " << currentPath << subdirs;
int identifiersUsed = 0;
foreach ( QString subdir, subdirs ) {
foreach ( const QString& subdir, subdirs ) {
currentPath.cd(subdir);
QFileInfo d(currentPath.path());
kDebug() << currentPath << d.exists() << d.isDir();
......
......@@ -183,7 +183,7 @@ QString ExpressionParser::popExpression(ExpressionParser::Status* status)
*status = EventualCallFound;
return QString();
}
foreach ( keyword kw, controlChars ) {
foreach ( const keyword& kw, controlChars ) {
if ( operatingOn.endsWith(kw.first) ) {
m_cursorPositionInString -= kw.first.length();
*status = kw.second;
......@@ -191,21 +191,21 @@ QString ExpressionParser::popExpression(ExpressionParser::Status* status)
}
}
if ( lastCharIsSpace ) {
foreach ( keyword kw, supportedKeywords ) {
foreach ( const keyword& kw, supportedKeywords ) {
if ( endsWithSeperatedKeyword(operatingOn, kw.first) ) {
m_cursorPositionInString -= kw.first.length();
*status = kw.second;
return QString();
}
}
foreach ( QString kw, miscKeywords ) {
foreach ( const QString& kw, miscKeywords ) {
if ( endsWithSeperatedKeyword(operatingOn, kw) ) {
m_cursorPositionInString -= kw.length();
*status = MeaninglessKeywordFound;
return QString();
}
}
foreach ( QString kw, noCompletionKeywords ) {
foreach ( const QString& kw, noCompletionKeywords ) {
if ( endsWithSeperatedKeyword(operatingOn, kw) ) {
m_cursorPositionInString -= kw.length();
*status = NoCompletionKeywordFound;
......
......@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************
*/
#include "implementfunction.h"
#include <language/codecompletion/codecompletionmodel.h>
#include <language/duchain/duchainutils.h>
#include <interfaces/icore.h>
......@@ -24,8 +26,6 @@
#include <KTextEditor/Document>
#include <KTextEditor/Editor>
#include "implementfunction.h"
using namespace KDevelop;
using namespace KTextEditor;
......
/*****************************************************************************
* Copyright (c) 2012 Sven Brauch <svenbrauch@googlemail.com> *
* *
* Permission is hereby granted, free of charge, to any person obtaining *
* a copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to *
* the following conditions: *
* *
* The above copyright notice and this permission notice shall be *
* included in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE *
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION *
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION *
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*****************************************************************************/
#ifndef PYTHONCOMPLETIONEXPORT_H
#define PYTHONCOMPLETIONEXPORT_H
......
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2012 Sven Brauch <svenbrauch@googlemail.com>
Much of the code is actually copied from cpp/codegen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
* This file is part of KDevelop *
* Copyright 2012 Sven Brauch <svenbrauch@googlemail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "simplerefactoring.h"
#include <helpers.h>
......@@ -27,7 +27,6 @@
#include <interfaces/idocumentcontroller.h>
#include <interfaces/iuicontroller.h>
#include <language/duchain/duchainlock.h>
#include <language/duchain/duchainlock.h>
#include <language/duchain/duchainutils.h>
#include <language/duchain/functiondefinition.h>
......@@ -207,7 +206,7 @@ void SimpleRefactoring::startInteractiveRename(KDevelop::IndexedDeclaration decl
// Since we don't yet know what the text should be replaced with, we just collect the top-contexts to process
SimpleRefactoringCollector* collector = new SimpleRefactoringCollector(decl);
QDialog dialog;
QPointer<QDialog> dialog = new QDialog();
QTabWidget tabWidget;
......@@ -222,8 +221,8 @@ void SimpleRefactoring::startInteractiveRename(KDevelop::IndexedDeclaration decl
QVBoxLayout verticalLayout;
QHBoxLayout actionsLayout;
dialog.setLayout(&verticalLayout);
dialog.setWindowTitle(i18n("Rename %1", declaration->toString()));
dialog->setLayout(&verticalLayout);
dialog->setWindowTitle(i18n("Rename %1", declaration->toString()));
QLabel newNameLabel(i18n("New name:"));
actionsLayout.addWidget(&newNameLabel);
......@@ -238,7 +237,7 @@ void SimpleRefactoring::startInteractiveRename(KDevelop::IndexedDeclaration decl
QPushButton goButton(i18n("Rename"));
goButton.setToolTip(i18n("Note: All overloaded functions, overloads, forward-declarations, etc. will be renamed too"));
actionsLayout.addWidget(&goButton);
connect(&goButton, SIGNAL(clicked(bool)), &dialog, SLOT(accept()));
connect(&goButton, SIGNAL(clicked(bool)), dialog, SLOT(accept()));
QPushButton cancelButton(i18n("Cancel"));
actionsLayout.addWidget(&cancelButton);
......@@ -251,12 +250,12 @@ void SimpleRefactoring::startInteractiveRename(KDevelop::IndexedDeclaration decl
verticalLayout.addWidget(&tabWidget);
connect(&cancelButton, SIGNAL(clicked(bool)), &dialog, SLOT(reject()));
connect(&cancelButton, SIGNAL(clicked(bool)), dialog, SLOT(reject()));
lock.unlock();
dialog.resize(750, 550);
dialog->resize(750, 550);
if ( dialog.exec() != QDialog::Accepted ) {
if ( dialog->exec() != QDialog::Accepted ) {
kDebug() << "stopped";
return;
}
......
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2012 <copyright holder> <email>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
* This file is part of KDevelop *
* Copyright 2012 Sven Brauch <svenbrauch@googlemail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef SIMPLEREFACTORING_H
#define SIMPLEREFACTORING_H
......
......@@ -16,13 +16,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "debugjob.h"
#include <KDebug>
#include <KStandardDirs>
#include <interfaces/idebugcontroller.h>
#include <interfaces/icore.h>
#include "debugjob.h"
#include <sublime/view.h>
#include <util/processlinemaker.h>
......
......@@ -324,8 +324,8 @@ void DebugSession::runToCursor()
KTextEditor::Cursor cursor = doc->cursorPosition();
if ( cursor.isValid() ) {
// TODO disable all other breakpoints
QString temporaryBreakpointLocation = doc->url().path() + QString(":") + QString::number(cursor.line() + 1);
InternalPdbCommand* temporaryBreakpointCmd = new InternalPdbCommand(0, 0, "tbreak " + temporaryBreakpointLocation + "\n");
QString temporaryBreakpointLocation = doc->url().path() + ':' + QString::number(cursor.line() + 1);
InternalPdbCommand* temporaryBreakpointCmd = new InternalPdbCommand(0, 0, "tbreak " + temporaryBreakpointLocation + '\n');
addCommand(temporaryBreakpointCmd);
addSimpleInternalCommand("continue");
updateLocation();
......@@ -376,7 +376,7 @@ void DebugSession::clearObjectTable()
void DebugSession::addSimpleUserCommand(const QString& cmd)
{
clearObjectTable();
UserPdbCommand* cmdObject = new UserPdbCommand(0, 0, cmd + "\n");
UserPdbCommand* cmdObject = new UserPdbCommand(0, 0, cmd + '\n');
Q_ASSERT(cmdObject->type() == PdbCommand::UserType);
addCommand(cmdObject);
}
......@@ -384,7 +384,7 @@ void DebugSession::addSimpleUserCommand(const QString& cmd)
void DebugSession::addSimpleInternalCommand(const QString& cmd)
{
Q_ASSERT( ! cmd.endsWith('\n') );
InternalPdbCommand* cmdObject = new InternalPdbCommand(0, 0, cmd + "\n");
InternalPdbCommand* cmdObject = new InternalPdbCommand(0, 0, cmd + '\n');
addCommand(cmdObject);
}
......@@ -409,20 +409,20 @@ void DebugSession::addBreakpoint(Breakpoint* bp)
{
QString location = bp->url().path() + ":" + QString::number(bp->line() + 1);
kDebug() << "adding breakpoint" << location;
runImmediately("break " + location + "\n");
runImmediately("break " + location + '\n');
}
void DebugSession::removeBreakpoint(Breakpoint* bp)
{
QString location = bp->url().path() + ":" + QString::number(bp->line() + 1);
kDebug() << "deleting breakpoint" << location;
runImmediately("clear " + location + "\n");
runImmediately("clear " + location + '\n');
}
void DebugSession::createVariable(Python::Variable* variable, QObject* callback, const char* callbackMethod)
{
kDebug() << "asked to create variable";
InternalPdbCommand* cmd = new InternalPdbCommand(variable, "dataFetched", ("print " + variable->expression() + "\n").toAscii());
InternalPdbCommand* cmd = new InternalPdbCommand(variable, "dataFetched", ("print " + variable->expression() + '\n').toAscii());
variable->m_notifyCreated = callback;
variable->m_notifyCreatedMethod = callbackMethod;
addCommand(cmd);
......
......@@ -66,7 +66,7 @@ void PdbFrameStackModel::framesFetched(QByteArray framelist)
location.setPatternSyntax(QRegExp::RegExp2);
if ( location.exactMatch(line) ) {
kDebug() << location.capturedTexts();
if ( location.capturedTexts().at(1) != "" ) {
if ( ! location.capturedTexts().at(1).isEmpty() ) {
m_debuggerAtFrame = framesCount;
}
currentFrame->file = location.capturedTexts().at(2);
......
......@@ -19,12 +19,11 @@
#include "pdblauncher.h"
#include "debugjob.h"
#include <util/executecompositejob.h>
#include <util/executecompositejob.h>
#include <executescript/iexecutescriptplugin.h>
#include <interfaces/launchconfigurationpage.h>
#include <interfaces/ilaunchconfiguration.h>
#include <interfaces/icore.h>
#include <interfaces/iplugincontroller.h>
#include <interfaces/icore.h>
#include <interfaces/iuicontroller.h>
......
/***************************************************************************
* This file is part of KDevelop *
* Copyright 2012 Sven Brauch <svenbrauch@googlemail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef PYTHONDEBUGEXPORT_H
#define PYTHONDEBUGEXPORT_H
......
......@@ -34,7 +34,7 @@ void Variable::dataFetched(QByteArray rawData)
QList<QByteArray> data = rawData.split('\n');
data.removeLast();
QByteArray value;
foreach ( const QByteArray item, data ) {
foreach ( const QByteArray& item, data ) {
value.append(item);
}
setValue(value);
......@@ -85,7 +85,7 @@ void Variable::moreChildrenFetched(QByteArray rawData)
i++;
continue;
}
QString childName = expression() + "_" + QString::number(i);
QString childName = expression() + '_' + QString::number(i);
QString realValue;
QString prettyName;
unsigned long int pythonId = 0;
......
......@@ -45,4 +45,4 @@ add_subdirectory(navigation)
add_subdirectory(tests)
add_subdirectory(types)
add_subdirectory(declarations)
\ No newline at end of file
add_subdirectory(declarations)
/*****************************************************************************
* Copyright (c) 2007 Piyush verma <piyush.verma@gmail.com> *
* Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
* Copyright 2010-2011 Sven Brauch <svenbrauch@googlemail.com> *
* Copyright 2010-2012 Sven Brauch <svenbrauch@googlemail.com> *
* *
* Permission is hereby granted, free of charge, to any person obtaining *
* a copy of this software and associated documentation files (the *
......@@ -22,6 +22,19 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION *
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*****************************************************************************/
#include "pythonlanguagesupport.h"
#include "pythoneditorintegrator.h"
#include "dumpchain.h"
#include "usebuilder.h"
#include "contextbuilder.h"
#include "pythonducontext.h"
#include "pythonparsejob.h"
#include "declarationbuilder.h"
#include "helpers.h"
#include <KStandardDirs>
#include <ktexteditor/smartrange.h>
#include <ktexteditor/smartinterface.h>
#include <ktexteditor/document.h>
......@@ -38,18 +51,6 @@
#include <interfaces/iproject.h>
#include <project/projectmodel.h>
#include <KStandardDirs>
#include "pythonlanguagesupport.h"
#include "pythoneditorintegrator.h"
#include "dumpchain.h"
#include "usebuilder.h"
#include "contextbuilder.h"
#include "pythonducontext.h"
#include "pythonparsejob.h"
#include "declarationbuilder.h"
#include "helpers.h"
using namespace KDevelop;
using namespace KTextEditor;
......
......@@ -22,9 +22,19 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION *
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*****************************************************************************/
#include <QByteArray>
#include <QtGlobal>
#include <KUrl>
#include "declarationbuilder.h"
#include "duchain/declarations/decorator.h"
#include "duchain/declarations/functiondeclaration.h"
#include "duchain/declarations/classdeclaration.h"
#include "types/variablelengthcontainer.h"
#include "types/hintedtype.h"
#include "types/unsuretype.h"
#include "types/indexedcontainer.h"
#include "contextbuilder.h"
#include "expressionvisitor.h"
#include "pythoneditorintegrator.h"
#include "helpers.h"
#include <language/duchain/functiondeclaration.h>
#include <language/duchain/declaration.h>
......@@ -39,18 +49,9 @@
#include <language/backgroundparser/parsejob.h>
#include <interfaces/ilanguagecontroller.h>
#include "duchain/declarations/decorator.h"
#include "contextbuilder.h"
#include "declarationbuilder.h"
#include "pythoneditorintegrator.h"
#include "expressionvisitor.h"
#include "helpers.h"
#include "types/variablelengthcontainer.h"
#include "types/hintedtype.h"
#include "types/unsuretype.h"
#include "types/indexedcontainer.h"
#include "duchain/declarations/functiondeclaration.h"
#include "duchain/declarations/classdeclaration.h"
#include <QByteArray>
#include <QtGlobal>
#include <KUrl>
using namespace KTextEditor;
using namespace KDevelop;
......@@ -484,7 +485,7 @@ Declaration* DeclarationBuilder::findDeclarationInContext(QStringList dottedName
Declaration* lastAccessedDeclaration = 0;
int i = 0;
int identifierCount = dottedNameIdentifier.length();
foreach ( QString currentIdentifier, dottedNameIdentifier ) {
foreach ( const QString& currentIdentifier, dottedNameIdentifier ) {
Q_ASSERT(currentContext);
i++;
QList<Declaration*> declarations = currentContext->findDeclarations(QualifiedIdentifier(currentIdentifier).first(),
......@@ -511,13 +512,13 @@ void DeclarationBuilder::visitImportFrom(ImportFromAst* node)
foreach ( AliasAst* name, node->names ) {
// iterate over all the names that are imported, like "from foo import bar as baz, bang as asdf"
if ( node->module ) {
moduleName = node->module->value + "." + name->name->value;
moduleName = node->module->value + '.' + name->name->value;
}
else {
moduleName = "." + name->name->value;
moduleName = '.' + name->name->value;
}
Identifier* declarationIdentifier = 0;
declarationName = "";
declarationName.clear();
if ( name->asName ) {
// use either the alias ("as foo"), or the object name itself if no "as" is given
declarationIdentifier = name->asName;
......
/***************************************************************************
* This file is part of KDevelop *
* Copyright 2012 Sven Brauch <svenbrauch@googlemail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef DECORATOR_H
#define DECORATOR_H
......
......@@ -53,7 +53,7 @@ void DumpChain::dump( DUContext * context, bool imported )
for( QMap<IndexedString, QList<RangeInRevision> >::const_iterator it = dec->uses().constBegin(); it != dec->uses().constEnd(); ++it )
{
kDebug() << QString((indent+1)*2, ' ') << "File:" << it.key().str();
foreach(RangeInRevision r, it.value())
foreach(const RangeInRevision& r, it.value())
{
kDebug() << QString((indent+2)*2, ' ') << "Use:" << context->transformFromLocalRevision(r).textRange();
}
......@@ -63,7 +63,7 @@ void DumpChain::dump( DUContext * context, bool imported )
++indent;
if (!imported)
{
foreach (const DUContext::Import parent, context->importedParentContexts())
foreach (const DUContext::Import& parent, context->importedParentContexts())
{
dump(parent.context(dynamic_cast<TopDUContext*>(context)), true);
}
......
......@@ -23,29 +23,27 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*****************************************************************************/
#include <KLocalizedString>
#include "expressionvisitor.h"
#include "types/indexedcontainer.h"
#include "types/variablelengthcontainer.h"
#include "declarations/functiondeclaration.h"
#include "pythonduchainexport.h"
#include "pythoneditorintegrator.h"
#include "helpers.h"
#include <language/duchain/types/unsuretype.h>
#include <language/duchain/types/integraltype.h>
#include <language/duchain/ducontext.h>
#include <language/duchain/declaration.h>
#include <language/interfaces/iproblem.h>
#include <language/duchain/types/typeregister.h>
#include <language/duchain/types/integraltype.h>
#include <language/duchain/types/typesystemdata.h>
#include <language/duchain/types/unsuretype.h>
#include <language/duchain/functiondeclaration.h>
#include <language/duchain/types/functiontype.h>
#include <language/duchain/declaration.h>
#include <language/duchain/functiondeclaration.h>
#include <language/duchain/classdeclaration.h>
#include <language/duchain/aliasdeclaration.h>
#include <language/duchain/ducontext.h>
#include <language/interfaces/iproblem.h>
#include "pythonduchainexport.h"
#include "expressionvisitor.h"
#include "pythoneditorintegrator.h"
#include "types/variablelengthcontainer.h"
#include "types/indexedcontainer.h"
#include "helpers.h"
#include "declarations/functiondeclaration.h"
#include <KLocalizedString>
using namespace KDevelop;
using namespace Python;
......
......@@ -51,8 +51,8 @@ using namespace KDevelop;
namespace Python {
QList<KUrl> Helper::cachedSearchPaths;
QString Helper::dataDir = QString::null;
QString Helper::documentationFile = QString::null;
QString Helper::dataDir;
QString Helper::documentationFile;