use of org.python.pydev.shared_core.string.FastStringBuffer in project Pydev by fabioz.
the class TabNanny method createBadIndentForSpacesMessages.
/**
* Creates the errors that are related to a bad indentation (number of space chars is not ok).
* @param monitor
*/
private static void createBadIndentForSpacesMessages(IDocument doc, IAnalysisPreferences analysisPrefs, IIndentPrefs indentPrefs, ArrayList<IMessage> ret, List<IndentInfo> validsAre, IProgressMonitor monitor) {
int tabWidth = indentPrefs.getTabWidth();
// if we're analyzing the spaces, let's mark invalid indents (tabs are not searched for those because
// a tab always marks a full indent).
FastStringBuffer buffer = new FastStringBuffer();
for (IndentInfo indentation : validsAre) {
if (monitor.isCanceled()) {
return;
}
if (!indentation.hasNonIndentChars) {
// if it does not have more contents (its only whitespaces), let's keep on going!
continue;
}
String indentStr = indentation.indent;
if (indentStr.indexOf("\t") != -1) {
// the ones that appear in tabs and spaces should not be analyzed here (they'll have their own error messages).
continue;
}
int lenFound = indentStr.length();
int extraChars = lenFound % tabWidth;
if (extraChars != 0) {
Integer offset = indentation.startOffset;
int startLine = PySelection.getLineOfOffset(doc, offset) + 1;
int startCol = 1;
int endCol = startCol + lenFound;
buffer.clear();
ret.add(new Message(IAnalysisPreferences.TYPE_INDENTATION_PROBLEM, buffer.append("Bad Indentation (").append(lenFound).append(" spaces)").toString(), startLine, startLine, startCol, endCol, analysisPrefs));
}
}
}
use of org.python.pydev.shared_core.string.FastStringBuffer in project Pydev by fabioz.
the class Found method toString.
@Override
public String toString() {
FastStringBuffer buffer = new FastStringBuffer();
buffer.append("Found { (used:");
buffer.append(used);
buffer.append(") [");
for (GenAndTok g : found) {
buffer.appendObject(g);
buffer.append(" ");
}
buffer.append(" ]}");
return buffer.toString();
}
use of org.python.pydev.shared_core.string.FastStringBuffer in project Pydev by fabioz.
the class GenAndTok method toString.
@Override
public String toString() {
FastStringBuffer buffer = new FastStringBuffer();
buffer.append("GenAndTok [ ");
buffer.append(generator.getRepresentation());
buffer.append(" - ");
buffer.append(tok.getRepresentation());
buffer.append(" (scopeId:");
buffer.append(scopeId);
buffer.append(") ");
if (references.size() > 0) {
buffer.append(" (references:");
for (IToken ref : references) {
buffer.append(ref.getRepresentation());
buffer.append(",");
}
// remove the last comma
buffer.deleteLast();
buffer.append(") ");
}
buffer.append("]");
return buffer.toString();
}
use of org.python.pydev.shared_core.string.FastStringBuffer in project Pydev by fabioz.
the class TddCodeGenerationQuickFixParticipantTest method testCreate2.
public void testCreate2() throws Exception {
String s = "" + "class MyClass(object):\n" + " pass\n" + "def testName():\n" + " obj = MyClass()\n" + " obj.unimplementedFunction(a.x, 'Some comment in ticket.')\n" + "";
TddCodeGenerationQuickFixParticipant participant = new TddCodeGenerationQuickFixParticipant();
Document doc = new Document(s);
List<ICompletionProposalHandle> props = participant.getTddProps(new PySelection(doc, s.length() - 1), null, null, nature, null, s.length() - 1, null);
TddRefactorCompletionInModule proposal = (TddRefactorCompletionInModule) assertContains("Create unimplementedFunction method at MyClass (__module_not_in_the_pythonpath__)", props.toArray(new ICompletionProposalHandle[0]));
// Todo: check result of apply as string is breaking!
List<String> parametersAfterCall = proposal.getParametersAfterCall();
FastStringBuffer createParametersList = AbstractPyCreateClassOrMethodOrField.createParametersList(parametersAfterCall);
assertEquals("${x}, ${param1}", createParametersList.toString());
}
use of org.python.pydev.shared_core.string.FastStringBuffer in project Pydev by fabioz.
the class RefactoringRenameTestBase method setUp.
/**
* In the setUp, it initializes the files in the refactoring project
* @see com.python.pydev.analysis.refactoring.refactorer.refactorings.renamelocal.RefactoringLocalTestBase#setUp()
*/
@Override
public void setUp() throws Exception {
super.setUp();
if (filesInRefactoringProject == null) {
filesInRefactoringProject = PyFileListing.getPyFilesBelow(new File(TestDependent.TEST_COM_REFACTORING_PYSRC_LOC), new NullProgressMonitor(), true).getFoundPyFileInfos();
ArrayList<Tuple<List<ModulesKey>, IPythonNature>> iFiles = new ArrayList<Tuple<List<ModulesKey>, IPythonNature>>();
List<ModulesKey> modules = new ArrayList<ModulesKey>();
iFiles.add(new Tuple<List<ModulesKey>, IPythonNature>(modules, natureRefactoring));
FastStringBuffer tempBuf = new FastStringBuffer();
for (PyFileInfo info : filesInRefactoringProject) {
File f = info.getFile();
String modName = info.getModuleName(tempBuf);
ModulesKey modulesKey = new ModulesKey(modName, f);
modules.add(modulesKey);
SourceModule mod = (SourceModule) AbstractModule.createModule(modName, f, natureRefactoring, true);
// also create the additional info so that it can be used for finds
AbstractAdditionalTokensInfo additionalInfo = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(natureRefactoring);
additionalInfo.addAstInfo(mod.getAst(), modulesKey, false);
}
// RefactorerFindReferences.FORCED_RETURN = iFiles;
}
setUpConfigWorkspaceFiles();
}
Aggregations