Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing filename validation performance regression in launch configuration #3

Merged
merged 2 commits into from Jun 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions org.epic.debug/src/org/epic/debug/ui/ProjectAndFileBlock.java
Expand Up @@ -134,14 +134,13 @@ public boolean isValid(ILaunchConfiguration config) {
setErrorMessage("Startup File is not specified");
return false;
}
String[] files = getPerlFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].equals(name)) {
return true;
}

if (! existsFile(name)) {
setErrorMessage("File does not exist or match to the project");
return false;
}
setErrorMessage("File does not exist or match to the project");
return false;

return true;
}

private void createScriptFileEditor(Composite parent) {
Expand Down Expand Up @@ -191,6 +190,18 @@ private String[] getPerlFiles() {
}
return ((PerlProjectVisitor) visitor).getList();
}

private boolean existsFile(String filename) {
String projectName = getSelectedProject();

if (projectName == null || projectName.length() == 0) {
return false;
}

IWorkspaceRoot workspaceRoot = PerlDebugPlugin.getWorkspace().getRoot();
IProject project = workspaceRoot.getProject(projectName);
return project.getFile(filename).exists();
}

protected void newProjectSelected()
{
Expand Down
Expand Up @@ -54,10 +54,10 @@ private void _testFile(String inFile, String outFile) throws IOException
buf.append(sub.getName());
buf.append(':');
buf.append(sub.getBlockLevel());
buf.append('\n');
buf.append(String.format("%n"));
}
buf.append('}');
buf.append('\n');
buf.append(String.format("%n"));
}

/*
Expand Down
Expand Up @@ -6,9 +6,10 @@

public class TestPerlPartitioner extends BaseTestCase
{
// this test expects unix newlines
public void testSyntax() throws Exception
{
Document doc = new Document(readFile("workspace/EPICTest/syntax.pl"));
Document doc = new Document(readFile("workspace/EPICTest/syntax.pl").replace("\r",""));
PerlPartitioner partitioner = new PerlPartitioner(new Log(), doc);

ITypedRegion[] partitioning =
Expand All @@ -30,7 +31,7 @@ public void testSyntax() throws Exception
buf.append('\n');
}

String expected = readFile("test.in/TestPerlPartitioner-expected.txt");
String expected = readFile("test.in/TestPerlPartitioner-expected.txt").replace("\r","");
assertEquals(expected, buf.toString());
//System.err.println(buf);
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ protected void brokenPipe(IOException e)
throws IOException
{
if (e.getMessage().indexOf("Broken pipe") == 0 ||
e.getMessage().indexOf("Die Pipe wurde beendet") == 0)
e.getMessage().indexOf("Die Pipe ") == 0)
{
PerlValidatorStub.gotBrokenPipe = true;
}
Expand Down
2 changes: 1 addition & 1 deletion org.epic.perleditor-test/test.properties
Expand Up @@ -2,7 +2,7 @@
# See README.txt.

# Path to the Perl interpreter
org.epic.perleditor-test.perl = /usr/bin/perl
org.epic.perleditor-test.perl = perl

# TestPerlMultiLexer is very machine-specific, disable it to avoid false alarms
org.epic.perleditor-test.TestPerlMultiLexer.enabled = false