add methods to record edges as ambiguous

This commit is contained in:
mlangkabel
2019-05-06 17:22:20 +02:00
parent f14a8a0a19
commit f78a7186c1
13 changed files with 289 additions and 4 deletions
+3
View File
@@ -24,6 +24,7 @@
#include "CppSQLite3.h"
#include "StorageEdge.h"
#include "StorageElementComponent.h"
#include "StorageError.h"
#include "StorageFile.h"
#include "StorageLocalSymbol.h"
@@ -61,6 +62,7 @@ namespace sourcetrail
void rollbackTransaction();
void optimizeDatabaseMemory();
int addElementComponent(const StorageElementComponentData& storageElementComponentData);
int addNode(const StorageNodeData& storageNodeData);
void addSymbol(const StorageSymbol& storageSymbol);
void addFile(const StorageFile& storageFile);
@@ -102,6 +104,7 @@ namespace sourcetrail
mutable CppSQLite3DB m_database;
CppSQLite3Statement m_insertElementStatement;
CppSQLite3Statement m_insertElementComponentStatement;
CppSQLite3Statement m_findNodeStatement;
CppSQLite3Statement m_insertNodeStatement;
CppSQLite3Statement m_setNodeTypeStmt;
+34
View File
@@ -0,0 +1,34 @@
/*
* Copyright 2018 Coati Software KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
#define SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
namespace sourcetrail
{
/**
* Enum providing all possible values for kinds of node and edge components that can be stored to the Sourcetrail database.
*/
enum class ElementComponentKind : int
{
IS_AMBIGUOUS = 1 << 0
};
int elementComponentKindToInt(ElementComponentKind kind);
ElementComponentKind intToElementComponentKind(int i);
}
#endif // SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
+2 -1
View File
@@ -32,7 +32,8 @@ namespace sourcetrail
ATOMIC_RANGE = 5,
INDEXER_ERROR = 6,
FULLTEXT_SEARCH = 7,
SCREEN_SEARCH = 8
SCREEN_SEARCH = 8,
UNSOLVED = 9
};
int locationKindToInt(LocationKind kind);
+38
View File
@@ -22,6 +22,7 @@
#include "DefinitionKind.h"
#include "EdgeKind.h"
#include "ElementComponentKind.h"
#include "LocationKind.h"
#include "NameHierarchy.h"
#include "ReferenceKind.h"
@@ -349,6 +350,42 @@ namespace sourcetrail
*/
bool recordReferenceLocation(int referenceId, const SourceRange& location);
/**
* Marks a reference that is stored in the database as "ambiguous"
*
* This method allows to additional information for a reference to the database. Sourcetrail will
* display an "ambiguous" reference with a special style to emphasize that the existance of the
* reference is questionable. This method is intended to be called in situations when an indexed
* token may have meanings, all of which shall be recorded.
*
* param: referenceId - the id of the reference that shall be marked as ambiguous.
*
* return: true if successful. false on failure. getLastError() provides the error message.
*/
bool recordReferenceIsAmbiuous(int referenceId);
/**
* Stores a location between a specific context and an "unsolved" symbol to the database
*
* This method allows to store all available information to the database in the case that a symbol
* is referenced in a certain context but the referenced symbol could not be resolved to a concrete
* name. For each reference recorded by this method, Sourcetrail's graph view will display an edge
* that originates at the recorded context symbol and points to a node called "unsolved symbol".
* Furthermore Sourcetrail's code view will use a different highlight when the provided source range
* gets hovered.
*
* param: contextSymbolId - the id of the source of the recorded reference edge
* param: referenceKind - kind of the recorded reference edge
* param: location - the SourceRange that shall be recorded as location for the respective
* reference.
*
* return: referenceId - integer id of the stored reference. 0 on failure. getLastError()
* provides the error message.
*
* see: SourceRange
*/
int recordReferenceToUnsolvedSymhol(int contextSymbolId, ReferenceKind referenceKind, const SourceRange& location);
/**
* Stores a location for the usage of a symbol's name as qualifier to the database
*
@@ -475,6 +512,7 @@ namespace sourcetrail
int addFile(const std::string& filePath);
int addEdge(int sourceId, int targetId, EdgeKind edgeKind);
void addSourceLocation(int elementId, const SourceRange& location, LocationKind kind);
void addElementComponent(int elementId, ElementComponentKind kind, const std::string& data);
std::string m_projectFilePath;
std::string m_databaseFilePath;
+64
View File
@@ -0,0 +1,64 @@
/*
* Copyright 2018 Coati Software KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H
#define SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H
#include <string>
namespace sourcetrail
{
struct StorageElementComponentData
{
StorageElementComponentData()
: elementId(0)
, componentKind(0)
, data("")
{}
StorageElementComponentData(int elementId, int componentKind, std::string data)
: elementId(elementId)
, componentKind(componentKind)
, data(std::move(data))
{}
int elementId;
int componentKind;
std::string data;
};
struct StorageElementComponent : public StorageElementComponentData
{
StorageElementComponent()
: StorageElementComponentData()
, id(0)
{}
StorageElementComponent(int id, const StorageElementComponentData& data)
: StorageElementComponentData(data)
, id(id)
{}
StorageElementComponent(int id, int elementId, int componentKind, std::string data)
: StorageElementComponentData(elementId, componentKind, data)
, id(id)
{}
int id;
};
}
#endif // SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H