Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Titan Language Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
Eclipse Titan
Titan Language Server
Merge requests
!24
Project parsing 1: added outdated file collector
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Project parsing 1: added outdated file collector
ofc
into
main
Overview
0
Commits
1
Changes
1
Merged
Miklos Magyari
requested to merge
ofc
into
main
2 years ago
Overview
0
Commits
1
Changes
1
Expand
Signed-off-by: Miklos Magyari
miklos.magyari@sigmatechnology.com
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
e792e832
1 commit,
2 years ago
1 file
+
141
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
lsp/src/main/java/org/eclipse/titan/lsp/parsers/OutdatedFileCollector.java
0 → 100755
+
141
−
0
Options
/******************************************************************************
* Copyright (c) 2000-2023 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
package
org.eclipse.titan.lsp.parsers
;
import
java.io.IOException
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.FileVisitor
;
import
java.nio.file.Path
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.eclipse.titan.lsp.core.Project
;
import
org.eclipse.titan.lsp.core.ProjectItem
;
/**
* This class is a resource visitor collecting every file in the project which
* is not:
*
* <ul>
* <li>under the working directory.
* <li>excluded from build.
* <li>uptodate.
* </ul>
* Should be started only on a project.
*
* @see #analyzeAll(IFile, TTCN3Editor, IProgressMonitor)
*
* @author Kristof Szabados
* @author Miklos Magyari
*/
public
class
OutdatedFileCollector
implements
FileVisitor
<
Path
>
{
public
static
final
String
TRUE
=
"true"
;
private
static
final
String
DOT
=
"."
;
private
final
Project
project
;
private
final
Map
<
Path
,
String
>
uptodateFiles
;
private
final
Set
<
Path
>
highlySyntaxErroneousFiles
;
private
final
List
<
Path
>
asn1FilesToCheck
;
private
final
List
<
Path
>
cfgFilesToCheck
;
private
final
List
<
Path
>
ttcn3FilesToCheck
;
private
final
List
<
Path
>
ttcninFilesModified
;
private
final
Path
[]
workingDirectories
;
public
OutdatedFileCollector
(
final
Path
[]
workingDirectories
,
final
Map
<
Path
,
String
>
uptodateFiles
,
final
Set
<
Path
>
highlySyntaxErroneousFiles
)
{
this
.
uptodateFiles
=
uptodateFiles
;
this
.
highlySyntaxErroneousFiles
=
highlySyntaxErroneousFiles
;
this
.
asn1FilesToCheck
=
new
ArrayList
<>();
this
.
cfgFilesToCheck
=
new
ArrayList
<>();
this
.
ttcn3FilesToCheck
=
new
ArrayList
<>();
this
.
ttcninFilesModified
=
new
ArrayList
<>();
this
.
workingDirectories
=
workingDirectories
;
project
=
Project
.
INSTANCE
;
}
public
List
<
Path
>
getASN1FilesToCheck
()
{
return
asn1FilesToCheck
;
}
public
List
<
Path
>
getCFGFilesToCheck
()
{
return
cfgFilesToCheck
;
}
public
List
<
Path
>
getTTCN3FilesToCheck
()
{
return
ttcn3FilesToCheck
;
}
public
List
<
Path
>
getTtcninFilesModified
()
{
return
ttcninFilesModified
;
}
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
throws
IOException
{
for
(
final
Path
workingDirectory
:
workingDirectories
)
{
if
(
workingDirectory
.
equals
(
dir
))
{
return
FileVisitResult
.
TERMINATE
;
}
}
final
ProjectItem
item
=
project
.
getProjectItem
(
dir
);
if
(
item
.
isExcluded
())
{
return
FileVisitResult
.
TERMINATE
;
}
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
final
Path
filepath
=
file
.
getFileName
();
if
(
filepath
==
null
)
{
return
FileVisitResult
.
CONTINUE
;
}
final
String
filename
=
filepath
.
toString
();
if
(
filename
.
startsWith
(
DOT
))
{
return
FileVisitResult
.
CONTINUE
;
}
final
ProjectItem
item
=
project
.
getProjectItem
(
file
);
if
(
item
.
isExcluded
())
{
return
FileVisitResult
.
TERMINATE
;
}
String
extension
=
""
;
final
String
fullpath
=
file
.
toString
();
if
(
fullpath
.
contains
(
"."
))
{
extension
=
fullpath
.
substring
(
fullpath
.
lastIndexOf
(
"."
)
+
1
);
}
if
(!
uptodateFiles
.
containsKey
(
file
)
&&
!
highlySyntaxErroneousFiles
.
contains
(
file
))
{
if
(
GlobalParser
.
isSupportedTTCN3Extension
(
extension
))
{
ttcn3FilesToCheck
.
add
(
file
);
}
else
if
(
GlobalParser
.
SUPPORTED_CONFIG_FILE_EXTENSIONS
[
0
].
equals
(
extension
))
{
cfgFilesToCheck
.
add
(
file
);
}
else
if
(
GlobalParser
.
SUPPORTED_ASN1_EXTENSIONS
[
0
].
equals
(
extension
)
||
GlobalParser
.
SUPPORTED_ASN1_EXTENSIONS
[
1
].
equals
(
extension
))
{
asn1FilesToCheck
.
add
(
file
);
}
else
if
(
GlobalParser
.
TTCNIN_EXTENSION
.
equals
(
extension
))
{
ttcninFilesModified
.
add
(
file
);
}
}
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
exc
)
throws
IOException
{
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
exc
)
throws
IOException
{
return
FileVisitResult
.
CONTINUE
;
}
}
Loading