Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CUP Eclipse Plugin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr. Michael Petter
CUP Eclipse Plugin
Commits
5f596bfa
Commit
5f596bfa
authored
Dec 04, 2014
by
Johannes Roith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Fix potential bug in SetupJob.
- Fix jobs into their own files. - Minor changes.
parent
6583d816
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
83 deletions
+97
-83
CupPlugin/src/de/tum/in/www2/cupplugin/controller/CallbackJob.java
.../src/de/tum/in/www2/cupplugin/controller/CallbackJob.java
+30
-0
CupPlugin/src/de/tum/in/www2/cupplugin/controller/DocumentDidChangeJob.java
...um/in/www2/cupplugin/controller/DocumentDidChangeJob.java
+15
-83
CupPlugin/src/de/tum/in/www2/cupplugin/controller/SetupJob.java
...gin/src/de/tum/in/www2/cupplugin/controller/SetupJob.java
+52
-0
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/controller/CallbackJob.java
0 → 100644
View file @
5f596bfa
package
de.tum.in.www2.cupplugin.controller
;
import
java.util.List
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.ui.progress.UIJob
;
import
de.tum.in.www2.cupplugin.editors.CupTextEditor
;
class
CallbackJob
extends
UIJob
{
private
CupTextEditor
editor
=
null
;
private
List
<
JobStatus
>
jobStatusList
;
public
CallbackJob
(
CupTextEditor
editor
,
List
<
JobStatus
>
jobStatusList
)
{
super
(
""
+
editor
.
hashCode
());
this
.
editor
=
editor
;
this
.
jobStatusList
=
jobStatusList
;
}
@Override
public
IStatus
runInUIThread
(
IProgressMonitor
monitor
)
{
for
(
JobStatus
status:
jobStatusList
)
{
Controller
.
getInstance
(
editor
).
notifyObserversOfJobStatus
(
status
);
}
Controller
.
getInstance
(
editor
).
notifyChangeJobFinished
();
return
Status
.
OK_STATUS
;
}
}
\ No newline at end of file
CupPlugin/src/de/tum/in/www2/cupplugin/controller/DocumentDidChangeJob.java
View file @
5f596bfa
...
...
@@ -15,7 +15,6 @@ import org.eclipse.jface.text.DocumentEvent;
import
org.eclipse.jface.text.IDocument
;
import
org.eclipse.ui.part.FileEditorInput
;
import
org.eclipse.ui.progress.UIJob
;
import
org.eclipse.ui.texteditor.IDocumentProvider
;
import
de.in.tum.www2.cup.CupContext
;
import
de.in.tum.www2.cup.CupParser
;
...
...
@@ -25,24 +24,21 @@ import de.in.tum.www2.cup.internal.internal_error;
import
de.tum.in.www2.cupplugin.controller.Controller.JobsToDo
;
import
de.tum.in.www2.cupplugin.editors.CupEditorErrorReporter
;
import
de.tum.in.www2.cupplugin.editors.CupTextEditor
;
import
de.tum.in.www2.cupplugin.editors.RevisionManager
;
import
de.tum.in.www2.cupplugin.model.Model
;
public
class
DocumentDidChangeJob
extends
Job
{
boolean
iAmC
urrentlyRunning
=
false
;
boolean
c
urrentlyRunning
=
false
;
CupTextEditor
editor
=
null
;
private
List
<
DocumentEvent
>
documentEvents
;
private
EnumSet
<
JobsToDo
>
jobs
;
List
<
DocumentEvent
>
documentEvents
;
EnumSet
<
JobsToDo
>
jobs
;
String
codeText
;
private
ParserResult
result
;
private
CupContext
context
;
private
LALRResult
lalrResult
;
private
List
<
JobStatus
>
jobStatusList
;
private
String
codeText
;
// Revision Number for checks
public
long
revNumber
;
public
DocumentDidChangeJob
(
CupTextEditor
editor
)
{
...
...
@@ -52,14 +48,19 @@ public class DocumentDidChangeJob extends Job {
}
public
boolean
running
()
{
return
iAmC
urrentlyRunning
;
return
c
urrentlyRunning
;
}
@Override
protected
IStatus
run
(
IProgressMonitor
monitor
)
{
iAmC
urrentlyRunning
=
true
;
c
urrentlyRunning
=
true
;
SetupJob
setup
=
new
SetupJob
(
this
);
// TODO: this was moved here from the SetupJob.
// I think it's correct and safe here, but this TODO
// should only be removed, once we are sure.
jobStatusList
.
clear
();
SetupJob
setup
=
new
SetupJob
(
editor
,
revNumber
,
this
);
setup
.
setSystem
(
true
);
setup
.
schedule
();
try
{
...
...
@@ -90,12 +91,7 @@ public class DocumentDidChangeJob extends Job {
if
(
editor
==
null
)
return
Status
.
CANCEL_STATUS
;
IDocumentProvider
provider
=
editor
.
getDocumentProvider
();
if
(
provider
==
null
)
return
Status
.
CANCEL_STATUS
;
IDocument
document
=
provider
.
getDocument
(
editor
.
getEditorInput
());
IDocument
document
=
editor
.
getDocument
();
if
(
document
==
null
)
return
Status
.
CANCEL_STATUS
;
...
...
@@ -192,12 +188,10 @@ public class DocumentDidChangeJob extends Job {
errorReporter
.
pushToUIThread
();
/* System.out.println(jobs); TODO: REMOVE OUTPUT */
documentEvents
.
clear
();
jobs
.
clear
();
iAmC
urrentlyRunning
=
false
;
c
urrentlyRunning
=
false
;
CallbackJob
cb
=
new
CallbackJob
(
editor
,
jobStatusList
);
cb
.
setSystem
(
true
);
cb
.
schedule
();
...
...
@@ -205,68 +199,6 @@ public class DocumentDidChangeJob extends Job {
return
Status
.
OK_STATUS
;
}
static
class
CallbackJob
extends
UIJob
{
private
CupTextEditor
editor
=
null
;
private
List
<
JobStatus
>
jobStatusList
;
public
CallbackJob
(
CupTextEditor
editor
,
List
<
JobStatus
>
jobStatusList
)
{
super
(
""
+
editor
.
hashCode
());
this
.
editor
=
editor
;
this
.
jobStatusList
=
jobStatusList
;
}
@Override
public
IStatus
runInUIThread
(
IProgressMonitor
monitor
)
{
for
(
JobStatus
status:
jobStatusList
)
{
Controller
.
getInstance
(
editor
).
notifyObserversOfJobStatus
(
status
);
}
Controller
.
getInstance
(
editor
).
notifyChangeJobFinished
();
return
Status
.
OK_STATUS
;
}
}
class
SetupJob
extends
UIJob
{
private
DocumentDidChangeJob
documentDidChangeJob
;
public
SetupJob
(
DocumentDidChangeJob
documentDidChangeJob
)
{
super
(
"Parser Setup Job"
);
this
.
documentDidChangeJob
=
documentDidChangeJob
;
}
@Override
public
IStatus
runInUIThread
(
IProgressMonitor
monitor
)
{
Controller
controller
=
Controller
.
getInstance
(
editor
);
if
(
documentDidChangeJob
.
documentEvents
==
null
||
documentDidChangeJob
.
documentEvents
.
isEmpty
())
{
documentDidChangeJob
.
documentEvents
=
controller
.
popAllDocumentEvents
();
}
else
{
documentDidChangeJob
.
documentEvents
.
addAll
(
controller
.
popAllDocumentEvents
());
}
if
(
documentDidChangeJob
.
jobs
==
null
||
documentDidChangeJob
.
jobs
.
isEmpty
())
{
documentDidChangeJob
.
jobs
=
controller
.
popJobsToDo
();
}
else
{
documentDidChangeJob
.
jobs
.
addAll
(
controller
.
popJobsToDo
());
}
jobStatusList
.
clear
();
if
(
editor
==
null
||
editor
.
hasBeenDisposed
())
return
Status
.
CANCEL_STATUS
;
IDocument
document
=
editor
.
getDocument
();
if
(
revNumber
!=
RevisionManager
.
get
(
document
))
return
Status
.
CANCEL_STATUS
;
documentDidChangeJob
.
codeText
=
document
.
get
();
return
Status
.
OK_STATUS
;
}
}
}
CupPlugin/src/de/tum/in/www2/cupplugin/controller/SetupJob.java
0 → 100644
View file @
5f596bfa
package
de.tum.in.www2.cupplugin.controller
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.jface.text.IDocument
;
import
org.eclipse.ui.progress.UIJob
;
import
de.tum.in.www2.cupplugin.editors.CupTextEditor
;
import
de.tum.in.www2.cupplugin.editors.RevisionManager
;
class
SetupJob
extends
UIJob
{
private
DocumentDidChangeJob
ddcJob
;
private
CupTextEditor
editor
;
private
long
revision
;
public
SetupJob
(
CupTextEditor
editor
,
long
revision
,
DocumentDidChangeJob
documentDidChangeJob
)
{
super
(
"Parser Setup Job"
);
this
.
editor
=
editor
;
this
.
ddcJob
=
documentDidChangeJob
;
this
.
revision
=
revision
;
}
@Override
public
IStatus
runInUIThread
(
IProgressMonitor
monitor
)
{
Controller
controller
=
Controller
.
getInstance
(
editor
);
if
(
ddcJob
.
documentEvents
==
null
||
ddcJob
.
documentEvents
.
isEmpty
())
ddcJob
.
documentEvents
=
controller
.
popAllDocumentEvents
();
else
ddcJob
.
documentEvents
.
addAll
(
controller
.
popAllDocumentEvents
());
if
(
ddcJob
.
jobs
==
null
||
ddcJob
.
jobs
.
isEmpty
())
ddcJob
.
jobs
=
controller
.
popJobsToDo
();
else
ddcJob
.
jobs
.
addAll
(
controller
.
popJobsToDo
());
if
(
editor
==
null
||
editor
.
hasBeenDisposed
())
return
Status
.
CANCEL_STATUS
;
IDocument
document
=
editor
.
getDocument
();
if
(
revision
!=
RevisionManager
.
get
(
document
))
return
Status
.
CANCEL_STATUS
;
ddcJob
.
codeText
=
document
.
get
();
return
Status
.
OK_STATUS
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment